# 微博 话题搜索 API (weibo.topic_search)

- Canonical page: https://everyinfra.com/weibo-api/topic_search
- Endpoint: POST /api/v1/social with {"platform": "weibo", "action": "topic_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

微博话题搜索按 `keyword` 找话题，每个话题一行：标题 `title`、链接、文字内容 `text`、封面图 `cover_image_url`，以及阅读数 `read_count` 和讨论数 `discuss_count`。它回答「围绕这个词，微博上有哪些话题、哪个更热」，适合追热点、挑选要参与的话题，也适合评估一个品牌词或产品词的话题声量。

搜的是 #话题#，不是账号，也不是微博正文，例如搜 小米汽车 返回的是相关话题。每个话题自带的封面图和文字内容，做热点看板时可以直接拿来当卡片的配图和说明。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 按关键词找微博话题，例如 小米汽车；返回 #话题# 的阅读数、讨论数。 |
| page_token | not declared | no | not declared | 翻页令牌。第一页不传；之后把上一页响应里的 next_page_token 原样传回取下一页，其余参数不变。每页最多 20 个话题，每页算一次调用；翻到底时响应里没有 next_page_token。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| cover_image_url | 封面图。 |
| discuss_count | 话题讨论数（topic_search）。 |
| read_count | 话题阅读数（topic_search）。 |
| next_page_token | 翻页令牌（user_search、user_posts、topic_search、user_post_search）：作为下一次请求的 page_token 原样传回取下一页；同一页每行的值相同，响应顶层也有同一个 next_page_token。没有该字段即到底。 |
| 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": "weibo",
  "action": "topic_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": "weibo",
        "action": "topic_search",
        "params": {
            "keyword": "科技",
        },
    },
    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": "weibo",
  "action": "topic_search",
  "results": [
    {
      "title": …,
      "url": …,
      "text": …,
      "cover_image_url": …,
      "discuss_count": …,
      "read_count": …,
      "next_page_token": …,
      "platform": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 话题搜索和账号搜索怎么选？

想知道一个词下有哪些话题、各自阅读和讨论有多少，用话题搜索；想找叫这个名字的微博账号，用账号搜索。那一页返回用户 ID、简介、粉丝数和认证说明，话题搜索的 `text` 则是话题的文字内容，账号搜索没有这一项。两页的请求写法一样，都是 `keyword` 加可选的 `page_token`。

### 怎么跟踪一个话题的热度变化？

定期用同一个 `keyword` 搜一次，把每个话题的 `read_count`、`discuss_count` 连同读取时间记下，再用 `url` 把前后两次的同一个话题对上，两次读数一减，就是这段时间新增的阅读和讨论。

### `read_count` 和 `discuss_count` 怎么一起看？

`read_count` 是话题的阅读数，`discuss_count` 是讨论数。用讨论数除以阅读数，可以粗看一个话题是只被浏览的多，还是参与讨论的多；两个数都只出现在话题搜索里，账号搜索的结果没有。

## Also

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