# 抖音 关键词搜索 API (douyin.search)

- Canonical page: https://everyinfra.com/douyin-api/search
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "douyin", "action": "search", "params": {...}}
- Price: $0.008333 per call ($8.33 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 10, max 50 per call
- Pagination: pass next_page_token back as page_token for the next page, other params unchanged; one call per page, tokens last 24 hours
- Mode: sync; add "mode": "async" for slow tasks

抖音关键词搜索按 `keyword` 检索视频，返回视频文案、话题标签、点赞评论分享收藏数、作者昵称与抖音号、作者粉丝数、发布时间，以及时长、封面和带签名的播放地址。它回答「这个话题下哪些视频在传播、是谁发的」，常用于选题和热点追踪、品牌声量抽样，以及从视频反查值得关注的创作者。

用 `sort` 按相关度、最新或点赞最多排序，用 `publish_time` 限定最近一天、一周或半年。判断热度请看 `like_count`、`comment_count`、`share_count`：抖音不公开播放量，`view_count` 不代表真实播放。`author_id` 可以直接用来读这个作者的主页和作品。账号的作品列表请改用用户内容那一页。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 视频搜索关键词，传一个字符串，如 咖啡拉花；用于搜索视频，不是账号昵称或视频 ID。 |
| page_token | not declared | no | not declared | 翻页令牌。从第一页开始翻：传空字符串 page_token=""；之后把上一页响应里的 next_page_token 原样传回取下一页，keyword、sort、publish_time 保持不变。每页算一次调用，按抖音的整页取、不截断：一页至少 limit 条（默认 10，最多 50；翻到底时可能更少），常常多出几条；抖音在相邻两页重复给的视频，已经给过的不再给。令牌 24 小时内有效，只能在同一账户、同一组参数下使用，过期或参数变了返回 422，从第一页重新开始即可；翻到底时响应里没有 next_page_token。不带 page_token 是单次调用：最多 limit 条，没有 next_page_token。 |
| publish_time | enum: half_year / one_day / one_week / unlimited | no | not declared | 视频搜索的发布时间窗：unlimited 不限时间（默认）、one_day 最近 24 小时、one_week 最近 7 天、half_year 最近 6 个月。 |
| sort | enum: most_liked / newest / relevance | no | not declared | 视频搜索排序：relevance 按相关度（默认）、newest 按最新发布、most_liked 按点赞最多。兼容旧值 general（同 relevance）和 latest（同 newest）。 |
| limit | integer (1–50) | no | 10 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| next_page_token | 翻页令牌（search / user_posts / comments / comment_replies / billboard_video_hot / billboard_low_fan_explosion / billboard_high_completion / billboard_account_search / music_search / billboard_rise_list / billboard_topic_hot）：作为下一次请求的 page_token 原样传回取下一页（其余参数不变，24 小时内有效）；同一页每行的值相同，响应顶层也有同一个 next_page_token。没有该字段即到底。评论翻页逐页覆盖全部顶层评论。 |
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| media_type | 媒体类型。 |
| video_url | 视频播放地址（带签名、会过期，要留存请及时下载）；图文笔记或来源没给时为 null。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| share_count | 分享/转发数。null 表示不公开，不等于 0。 |
| collect_count | 收藏数。null 表示不公开，不等于 0。 |
| view_count | 此字段不是真实播放量。抖音不对外公开视频播放量，多数结果里没有这个字段，有时为 0；判断视频热度请用 like_count（点赞）、comment_count（评论）、share_count（分享）、collect_count（收藏）。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_douyin_id | 作者抖音号。 |
| author_uid | 作者（评论里是评论者）的数字用户 ID；author_id 是 secUid，两者是同一个人的两种 ID。 |
| author_bio | 作者主页简介（search / user_posts / video 行上）。 |
| author_avatar_url | 作者头像链接：search / user_posts / video 行上是博主的，comments 行上是评论者的。 |
| author_follower_count | 作者粉丝数。null 表示不公开。 |
| cover_image_url | 封面图链接：search / user_posts 是作品封面，music_search / music_detail 是音乐封面，billboard_topic_hot 是话题配图。 |
| video_width | 视频画面宽度（像素）。 |
| video_height | 视频画面高度（像素）。 |
| duration_seconds | 时长，单位秒。非视频/音频内容为 null。 |
| region | 地区。 |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| image_urls | 图片链接数组，按平台展示顺序；没有图片时不出现这个字段。 |
| duration_sec | 视频时长（秒）。 |
| hashtag_ids | 作品话题 ID 列表，与 hashtags 同序一一对应（search / user_posts / video）。 |
| search_rank | 在这次关键词搜索结果里的名次（从 1 开始）：product_search 行是商品，search 行是作品，hashtag_search 行是话题。 |
| author_is_verified | 作者是否认证（search / user_posts / video 行上）。 |
| author_following_count | 作者关注数（search / user_posts / video 行上）。 |
| author_like_count | 作者主页获赞总数（search / user_posts / video / transcript）。 |
| author_video_count | 作者作品总数（search / user_posts / video 行上）。 |
| author_ip_location | 作者 IP 属地（平台强制展示）。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| music | 作品背景音乐：id、title（曲名）、author（演唱/作者）、is_original（是否原声）、duration_sec（秒）、cover_url、play_url（音频地址，可能会过期）；没有音乐信息时没有这个键。 |
| download_count | 作品下载数。 |
| forward_count | 作品转发数。 |
| is_pinned | 是否置顶（作品行：作者主页置顶作品；trending：榜单置顶词）。 |
| is_ad | 是否为广告作品。 |
| video_tags | 平台给作品打的内容分类标签（如「美食」「探店」）。 |
| video_resolution | 视频清晰度档位原文（如 720p）。 |
| animated_cover_url | 动态封面链接。 |
| city | 城市：作品行（search / user_posts / video）是作品发布城市，平台给的是拼音写法（如 Suzhou）；xingtu_creator_rankings 是达人所在城市。 |
| city_code | 作品发布城市的行政区划代码（如 320500）。 |
| location | 作品定位的地点（POI）：id、name、category（地点分类）、address、district、city、province、country、city_code、latitude、longitude、cover_url、popularity_text（如 327人想去）、view_count、post_count（该地点下的作品数）、collect_count、visitor_count；作品没带定位时没有这个键。 |
| text_language | 作品文案语言代码（如 zh；un 表示未识别）。 |
| video_bitrates | 各清晰度播放地址：[{quality（清晰度名）, bitrate（码率，bps）, fps, is_h265（是否 H.265 编码）, url}]；地址带签名、会过期（见 video_url_expires_at）。 |
| download_url | 作品视频的下载地址（带签名、会过期）。 |
| has_watermark | 平台对这条作品视频文件的水印标记（true 表示带水印）。 |
| video_url_expires_at | 播放与下载地址的失效时间（ISO 8601，UTC）；之后要重新取。 |
| permissions | 作者给作品设的权限：can_comment（可评论）、can_download（可下载）、can_duet（可合拍）、can_stitch（可拼接）、can_share（可分享）、can_repost（可转发）、can_save（可保存）；只含平台给了的项。 |
| author_gender | 作者性别（male / female / unknown，作者自己填的）。 |
| author_age | 作者年龄（作者公开了才有）。 |

## 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": "search",
  "params": {
    "keyword": "城市骑行"
  }
}'
```

```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": "search",
        "params": {
            "keyword": "城市骑行",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "douyin",
  "action": "search",
  "results": [
    {
      "id": "•••",
      "url": "https://www.douyin.com/video/7635624004494435825",
      "text": "一个人的解压方式 夜晚 骑行 听歌 晚风和自由#骑行",
      "media_type": "video",
      "like_count": 1578935,
      "comment_count": 26631,
      "share_count": 228957,
      "collect_count": 117174,
      "view_count": 0,
      "author_name": "•••",
      "author_id": "•••",
      "author_douyin_id": "•••",
      "author_follower_count": 9028,
      "region": "CN",
      "posted_at": "2026-05-03T11:20:52+00:00",
      "platform": "douyin",
      "duration_sec": 8,
      "hashtags": [
        "骑行"
      ]
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": 1,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 为什么拿不到播放量？

抖音不对外公开播放量，结果里的 `view_count` 不代表真实播放，不能拿来判断视频有没有人看。比较热度请用 `like_count`、`comment_count` 和 `share_count`，并结合发布时间看。`collect_count` 收藏数也可以加进对比。`view_count` 在多数结果里没有这个字段，有时是 0，两种情况都不是真实播放。点赞、评论、分享、收藏数为 null 表示不公开，不等于 0，算平均值前先剔除 null，别当成 0 计入。

### 搜索结果能按时间筛选吗？

可以。`publish_time` 取 `one_day`、`one_week` 或 `half_year`，只看对应时间窗内发布的视频，默认 `unlimited` 不限时间；再把 `sort` 设为 `newest`，就按发布时间倒序排列。三档依次是最近 24 小时、7 天和 6 个月。`sort` 默认 `relevance`，`most_liked` 按点赞最多；旧值 general 和 latest 仍然兼容，分别等同 `relevance` 和 `newest`。盯刚发出的视频，用 `one_day` 加 `newest` 最直接。

### 一次最多 50 条，怎么拿到更多结果？

翻页。第一次请求把 `page_token` 传成空字符串，之后把响应里的 `next_page_token` 原样传回，`keyword`、`sort`、`publish_time` 保持不变。每页算一次调用，一页至少 `limit` 条；抖音在相邻两页重复给的视频不会再给一遍。整页取、不截断，常常多出几条。翻到底时响应里没有 `next_page_token`，令牌 24 小时内有效。令牌只能在同一账户、同一组参数下使用，过期或参数变了返回 422，从第一页重新开始即可。

## 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
