# 抖音 作品下载链接 API (douyin.media_links)

- Canonical page: [https://everyinfra.com/douyin-api/media_links](https://everyinfra.com/douyin-api/media_links?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "douyin", "action": "media_links", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Billing unit: each element in `urls` counts as one call; the number of elements you send sets the charge
- Returns: list
- Mode: sync only; everything it returns (every target of a batch, or every SKU of a product) is read in one call, and "mode": "async" returns 422 before any charge

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=douyin&action=media_links

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| urls | not declared | yes | not declared | 要取下载链接的视频，一次最多 20 个，数组，同一项只能出现一次；按个数计费，每个算一次，没取到的退回。返回行带 input，原样是你传的那一项，用来对回去。每项是 抖音视频：纯数字视频 ID，或含这个 ID 的视频链接（https://www.douyin.com/video/<视频ID>）；不收短链和分享口令。 |
| fresh | not declared | no | not declared | true 时不用缓存、当场重新取链接（链接带签名，会过期，过期时间看 expires_at）；默认 false。 |
| limit | integer (1–) | no | not declared | 这次调用最多返回的条数，整数，至少为 1；不传按默认值，实际返回可能少于这个数。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| media_type | 媒体类型。 |
| video_url | 视频播放地址（带签名、会过期，要留存请及时下载）；图文笔记或来源没给时为 null。 |
| video_url_expires_at | 播放与下载地址的失效时间（ISO 8601，UTC）；之后要重新取。 |
| video_width | 视频画面宽度（像素）。 |
| video_height | 视频画面高度（像素）。 |
| video_size_bytes | 视频文件大小（字节，media_links）。 |
| has_watermark | 平台对这条作品视频文件的水印标记（true 表示带水印）。 |
| best_stream | 码率最高的那一路视频流（media_links）：{url, bitrate（bps）, width, height, size_bytes, expires_at（失效时间）}。 |
| stream_count | 这条视频一共有几路不同清晰度的流（media_links）。 |
| cover_image_url | 封面图链接：search / user_posts / posts_batch / related_posts / mix_posts / music_posts / media_links 是作品封面，music_search / music_detail 是音乐封面，billboard_topic_hot 是话题配图，user_mixes 是合集封面，live_room 是直播间封面；带签名的会过期。 |
| covers | 各种封面图（media_links）：[{url, width, height, expires_at}]；第一张同 cover_image_url。 |
| image_urls | 图片链接数组，按平台展示顺序；没有图片时不出现这个字段。 |
| audio_url | 音频地址：transcript 是视频音轨（mp3），music_search、music_detail 是这段音乐的播放地址，media_links 是作品配乐的地址；可能会过期。 |
| request_headers | 下载这些链接时要带的请求头（media_links），例如 {"Referer": "https://www.douyin.com/"}；不带可能被拒。 |
| expires_at | 这一行里最早失效的那个链接的失效时间（media_links，ISO 8601，UTC）；过了要重新取（fresh=true）。 |
| fetched_at | 这些链接取到的时间（media_links，ISO 8601，UTC）；没传 fresh 时可能是缓存里的。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| input | 这一行对应的你传的那一项（posts_batch、profiles_batch、media_links 的 urls 里原样那个值），用来把结果对回去。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "douyin",
  "action": "media_links",
  "params": {
    "urls": [
      "https://www.douyin.com/video/<VIDEO_ID_A>"
    ]
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "douyin",
        "action": "media_links",
        "params": {
            "urls": [
                "https://www.douyin.com/video/<VIDEO_ID_A>",
            ],
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "douyin",
  "action": "media_links",
  "results": [
    {
      "id": …,
      "url": …,
      "media_type": …,
      "video_url": …,
      "video_url_expires_at": …,
      "video_width": …,
      "video_height": …,
      "video_size_bytes": …,
      "has_watermark": …,
      "best_stream": …,
      "stream_count": …,
      "cover_image_url": …,
      "covers": …,
      "image_urls": …,
      "audio_url": …,
      "request_headers": …,
      "expires_at": …,
      "fetched_at": …,
      "platform": …,
      "input": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=douyin
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
