# TikTok 话题搜索 API (tiktok.hashtag_search)

- Canonical page: https://everyinfra.com/tiktok-api/hashtag_search
- Endpoint: POST /api/v1/social with {"platform": "tiktok", "action": "hashtag_search", "params": {...}}
- Price: $0.000806 per call ($0.81 per 1,000 requests); failed and empty results are not charged
- Returns: list, one page of up to 20 per call; the number of rows varies from page to page and a short page is not the end (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page; no next_page_token means the end)
- 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

TikTok 话题搜索按 `keyword` 找名字相近的话题标签，每个话题带 `hashtag_id`、不带 # 的 `hashtag_name`、简介 `description`、视频数 `video_count` 和播放数 `view_count`。它回答「围绕这个词，TikTok 上有哪些话题、体量各有多大」，适合投话题之前先摸一遍候选，或者比较几个相近话题哪个更值得跟。

返回的是话题，不是视频：拿到 `hashtag_name` 后，交给话题内容那一页的话题名参数，才能读到话题下的视频。音乐搜索同样按 `keyword` 查，只是返回歌曲，搜歌别用这一页。每页最多 20 个话题，条数不固定，令牌 24 小时内有效。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 要找话题的关键词，如 fitness；返回名字相近的话题标签和各自的视频数、播放数，不是视频。 |
| page_token | not declared | no | not declared | 翻页令牌：把上一次响应里的 next_page_token 原样传回，拿下一页；不传从第一页开始。令牌 24 小时有效，每页算一次调用。每页最多 20 个话题。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| hashtag_id | 话题 ID（hashtag_search、trending_hashtags）。 |
| hashtag_name | 话题名，不带 #（hashtag_search、trending_hashtags）。 |
| url | 该记录在原平台上的可访问链接。 |
| description | 简介或描述，通常比 text 短。 |
| video_count | 视频数。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| next_page_token | platform-native meaning |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## 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": "tiktok",
  "action": "hashtag_search",
  "params": {
    "keyword": "coffee"
  }
}'
```

```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": "tiktok",
        "action": "hashtag_search",
        "params": {
            "keyword": "coffee",
        },
    },
    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": "tiktok",
  "action": "hashtag_search",
  "results": [
    {
      "hashtag_id": …,
      "hashtag_name": …,
      "url": …,
      "description": …,
      "video_count": …,
      "view_count": …,
      "next_page_token": …,
      "platform": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 搜到话题后，怎么看话题下的视频？

取结果里的 `hashtag_name`，填进话题内容那一页的话题名参数，那一页带不带 # 都行。结果里的 `url` 是话题本身的链接，不是视频链接。

### `video_count` 和 `view_count` 分别是什么？

`video_count` 是话题下的视频数，`view_count` 是播放数，后者为 null 表示不公开，不等于 0。比较几个相近话题时两个数一起看，视频数大的话题，播放数不一定也大。

### 名字相近的几个话题，怎么分清各自讲什么？

先读 `description`，它是话题的简介或描述，名字相近的话题靠它能看出讲的是不是同一件事；拿不准再打开 `url` 看话题页。存档时用 `hashtag_id` 做标识，`hashtag_name` 不带 #，要展示成标签时自己补上。

## Also

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