Download Markdown

Data Access Path · 6/7

Recommended reading order, not completion status. Optional steps can be skipped.

View all steps

Before you start: Read content first; for uploaded images/files confirm assets permission, or skip if no downloads are needed.

Download Images & Attachments

For some documents, MarsYoo has stored copies of images, audio, video or files. By the end of this page you can list and download them.

A document’s assets are original platform links and may stop working. Attachments here are copies we stored and can download reliably. Not every original link has a copy.

Requires assets field access.

List attachments

Bash
curl -sS "$WHALE_BASE_URL/v1/documents/$DOCUMENT_ID/attachments?limit=50" \
  -H "Authorization: Bearer $WHALE_API_KEY"
JSON
{
  "attachments": [
    {
      "asset_id": "asset_01K...",
      "source_platform": "xiaohongshu",
      "role": "cover",
      "origin_url": "https://source.example.com/cover.jpg",
      "filename": "cover.jpg",
      "media_type": "image",
      "mime_type": "image/jpeg",
      "size_bytes": 248133,
      "status": "ready",
      "created_at": "2026-10-14T08:00:00Z"
    }
  ],
  "next_cursor": ""
}
FieldMeaning
asset_idAttachment ID, used to download
media_typeimage, video, audio, document or other
rolecover (at most one per document), inline (image in the body), gallery (one item in a gallery), media (the video or audio itself)
origin_urlThe original platform link, for provenance only
statusAlways ready in the list; only fully stored files are listed
  • limit is 1 to 100, default 50.
  • When next_cursor isn’t empty, pass it as after for the next page.
  • An empty list can mean no files were stored, or storage is still in progress.
  • Only the current version’s attachments are available.

To show a cover, download the attachment with role cover; it’s more reliable than document.cover.url or origin_url.

Download a file

Get a download link first, then download:

Bash
ASSET_ID="asset_01K..."
 
DOWNLOAD_URL=$(curl -sS "$WHALE_BASE_URL/v1/documents/$DOCUMENT_ID/attachments/$ASSET_ID/download" \
  -H "Authorization: Bearer $WHALE_API_KEY" | jq -er '.url')
 
curl -sS -o cover.jpg "$DOWNLOAD_URL"

The endpoint returns {"url": "...", "expires_in": 300}:

  • The link is valid for 300 seconds; request a new one after that.
  • Don’t send your API key when downloading.
  • Don’t store the link long-term or write it to public logs.

When something fails

An attachment still being stored returns 409 attachment_incomplete; retry later. Other errors: Error codes.

Completion check: Retrieve and download available files without persisting short-lived URLs; next configure limits, retries and error handling.