# X (Twitter) 热榜 API (twitter.trending)

- Canonical page: https://everyinfra.com/twitter-api/trending
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "twitter", "action": "trending", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list
- Mode: sync; add "mode": "async" for slow tasks

X (Twitter) 热榜按地区读取 X 上的趋势话题，每条带话题名称、榜单名次、讨论量、统计时段和采集时刻。它回答「这个国家或全球眼下在讨论什么」，适合品牌和公关团队追踪热点、寻找借势时机，媒体和研究者记录各地的话题变化。

`country` 填地区代码，例如 us、jp、br，不传时默认 world 全球榜；部分英文国名也能识别，识别不了的输入会回落到全球榜而不报错，传参前请核对拼写。`country` 只选地区，不能查某一天的历史榜单。趋势变化快，用 `collected_at` 判断数据新鲜度；`volume` 是讨论量，要结合 `period` 的统计时段看。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| country | not declared | no | not declared | trending 的地区代码，world 为全球默认；支持 us、ca、mx、uk/gb、fr、de、it、es、pt、nl、dk、at、be、ch、gr、ru、tr、kr、sg、id、ph、vn、th、au、il、ae、sa、ar、br、eg、ng、ke、za、jp。部分英文国名也能识别，未识别的输入按全球榜返回；不是历史日期或用户所在地过滤。 |
| limit | integer (1–) | no | not declared | 这次调用最多返回的条数，整数，至少为 1；不传按默认值，实际返回可能少于这个数。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| name | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| rank | 趋势榜名次。 |
| volume | 话题讨论量。 |
| period | 统计时段。 |
| collected_at | 该条数据的抓取时刻。趋势变化快，用它判断新鲜度。 |
| 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": "twitter",
  "action": "trending",
  "params": {}
}'
```

```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": "twitter",
        "action": "trending",
        "params": {},
    },
    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; the list keeps the first 2 of 50. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "twitter",
  "action": "trending",
  "results": [
    {
      "id": "#ガルアワ2026AW",
      "name": "#ガルアワ2026AW",
      "rank": 1,
      "volume": "",
      "period": "Live",
      "collected_at": "2026-09-26T10:43:06.684000+00:00",
      "platform": "twitter"
    },
    {
      "id": "#格付けチェック",
      "name": "#格付けチェック",
      "rank": 2,
      "volume": "",
      "period": "Live",
      "collected_at": "2026-09-26T10:43:06.684000+00:00",
      "platform": "twitter"
    }
  ],
  "count": 50,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `country` 支持哪些地区？

填地区代码，不传时默认 world 全球榜。支持 us、ca、mx、uk 或 gb、fr、de、it、es、pt、nl、dk、at、be、ch、gr、ru、tr、kr、sg、id、ph、vn、th、au、il、ae、sa、ar、br、eg、ng、ke、za、jp；部分英文国名也能识别，识别不了的输入会回落到全球榜。

### 能查过去某一天的热榜吗？

不能。这个能力返回的是 `collected_at` 那一刻采集到的趋势榜；`country` 只选地区，不是历史日期，也不按用户所在地过滤。要做历史对比，需要定期读取并按 `collected_at` 存档，自己积累时间序列。

### `rank`、`volume` 和 `period` 怎么一起看？

`rank` 是话题在趋势榜上的名次，`volume` 是话题讨论量，`period` 是这份数据的统计时段。比较不同话题的讨论量时，先确认它们的 `period` 相同；同一话题在不同时刻的数据，用 `collected_at` 区分先后。

## Also

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