# X 账号关注 API

> 某个账号关注的人，最近关注的在前，每页 200 个：用户名、名称、简介、粉丝数和发帖数。

网页版：https://okdata.online/zh/apis/x/users/following/list/

- **接口**：`GET /v1/x/users/following/list`
- **ID**：`x.users.following.list`
- **价格**：$0.0001/条 · 每次最多 $0.02
- **返回**：一页约 200 个账号（`data.items`，Account 对象）
- **状态**：预览
- **适合**：找博主、竞品监控

## 价格

按返回条数计费：每条 $0.0001，每次至少按 1 条、最多按 $0.02（200 条）收费。1,000 个账号共 $0.10。空页按 1 条计费；失败的调用不扣费。

## 参数

| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| `username` | string | 是 |  | X 用户名，带不带 @ 都行。（例：`WHO`） |
| `cursor` | string | 否 |  | 上一次返回的 page.next_cursor，原样传回。每翻一页都是一次单独的调用。 |
| `view` | string: compact / standard / full | 否 | `standard` | 返回多少字段。full 会在 ext 里带上平台特有字段。 |
| `fields` | string[] | 否 |  | 只保留这些字段，按路径写（如 author.name），用来省 token。放在查询参数里时用逗号分隔。 |

cursor、view、fields 的用法见 [请求说明](https://okdata.online/zh/docs/requests/)。

## 返回字段

每一条都是一个 [Account](https://okdata.online/zh/docs/objects/account/)。

| 字段 | 类型 | 说明 |
|---|---|---|
| `id` | string | 账号在平台上的 ID。 |
| `url` | string | 主页链接。 |
| `username` | string \| null | 用户名（平台有的话）。 |
| `name` | string | 昵称。 |
| `bio` | string \| null | 简介。 |
| `avatar_url` | string \| null | 头像图片地址。 |
| `verified` | boolean \| null | 平台是否显示认证标识。 |
| `followers` | integer \| null | 粉丝数。 |
| `following` | integer \| null | 关注数。 |
| `posts` | integer \| null | 发布的作品、笔记或文章数。 |
| `likes` | integer \| null | 累计获赞（平台展示的话）。 |
| `ext` | object | 平台特有字段，只在 view=full 时返回。 |

## 请求示例

### cURL

```bash
curl -G "https://api.okdata.online/v1/x/users/following/list" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'username=WHO'
```

### Python

```python
import os
import requests

resp = requests.get(
    "https://api.okdata.online/v1/x/users/following/list",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"username": "WHO"},
    timeout=60,
)
body = resp.json()
if body["code"] != "ok":
    raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")

for row in body["data"]["items"]:
    print(row["name"], row["followers"])
print("cost: $" + body["meta"]["billing"]["amount"])
```

### TypeScript

```ts
const url = new URL('https://api.okdata.online/v1/x/users/following/list');
url.searchParams.set('username', "WHO");

const res = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OKDATA_API_KEY}`,
  },
});
const body = await res.json();
if (body.code !== 'ok') throw new Error(`${body.code}: ${body.message}`);

for (const row of body.data.items) {
  console.log(row.name, row.followers);
}
console.log('cost: $' + body.meta.billing.amount);
```

### MCP

```json
{
  "name": "call",
  "arguments": {
    "capability": "x.users.following.list",
    "username": "WHO"
  }
}
```

或者对接好 MCP 的智能体直接说：

> 用「X 账号关注」查这个账号的粉丝数，说说它主要发什么。

## 返回示例

```json
{
  "code": "ok",
  "request_id": "0f6c2a8e-4b1d-4e0a-9a51-3c7d2b9e1f20",
  "data": {
    "items": [
      {
        "id": "1450012345678901248",
        "url": "https://x.com/trailkit",
        "username": "trailkit",
        "name": "Trail Kit",
        "bio": "Light packs, long walks.",
        "avatar_url": "https://cdn.example.com/avatar/trailkit.jpg",
        "verified": true,
        "followers": 182300,
        "following": 312,
        "posts": 486,
        "likes": null
      }
    ]
  },
  "page": {
    "next_cursor": "eyJvIjoyMH0",
    "has_more": true
  },
  "warnings": [],
  "meta": {
    "capability": "x.users.following.list",
    "billing": {
      "amount": "0.0001",
      "currency": "USD",
      "balance_after": "9.9999"
    },
    "unavailable": {},
    "cached": false,
    "replayed": false,
    "fetched_at": "2026-11-11T08:00:00Z"
  }
}
```

## 错误

所有错误同一种结构：code、request_id、message 和 message_zh（每个 code 一句固定的话）、charged、retry、retry_after_seconds、param 和 docs_url，具体问题写在 problems 里。错误不扣费；只有 settlement_unknown 的扣费结果要查询后才知道。完整列表：https://okdata.online/zh/docs/errors/

## 常见问题

### X 账号关注接口多少钱？

按返回条数计费：每条 $0.0001，每次至少按 1 条、最多按 $0.02（200 条）收费。1,000 个账号共 $0.10。空页按 1 条计费；失败的调用不扣费。

### 怎么翻页？

把返回里的 page.next_cursor 原样作为 cursor 参数传回去。page.has_more 为 false 时就没有下一页了。每一页都是一次 $0.0001 的调用。

### 需要X（推特）账号、Cookie 或扫码登录吗？

不需要。只要带上 okdata 的 API key。返回的是X（推特）上的公开数据，不会用到你自己的X（推特）账号。

### 调用失败会扣费吗？

不会。所有错误都会返回 charged: false；只有超时返回 charged: null，表示结果还没确定。带同一个 Idempotency-Key 重发，绝不会重复扣费。

### X（推特）不展示某个字段怎么办？

这个字段会是 null，meta.unavailable 里会列出它和原因：platform（平台本来就不展示）或 capability（我们暂时取不到）。

## X（推特）的其他接口

- [X 帖子详情](https://okdata.online/zh/apis/x/posts/get/)：$0.0003/次
- [X 帖子搜索](https://okdata.online/zh/apis/x/posts/search/)：$0.002/次 · 每页约 20 条帖子
- [X 账号信息](https://okdata.online/zh/apis/x/users/get/)：$0.0004/条 · 每次最多 $0.04
- [X 账号帖子列表](https://okdata.online/zh/apis/x/users/posts/list/)：$0.002/次 · 每页约 20 条帖子
- [X 趋势](https://okdata.online/zh/apis/x/trends/list/)：$0.009/次 · 每页约 30 条榜单
- [X 帖子回复](https://okdata.online/zh/apis/x/posts/replies/list/)：$0.002/次 · 每页约 35 条帖子
- [X 帖子引用](https://okdata.online/zh/apis/x/posts/quotes/list/)：$0.0003/条 · 每次最多 $0.006
- [X 帖子转推用户](https://okdata.online/zh/apis/x/posts/retweeters/list/)：$0.002/次 · 每页约 100 个账号
- [X 长文](https://okdata.online/zh/apis/x/posts/article/get/)：$0.002/次
- [X 对话串](https://okdata.online/zh/apis/x/threads/posts/list/)：$0.0003/条 · 每次最多 $0.015
- [X 账号搜索](https://okdata.online/zh/apis/x/users/search/)：$0.0004/条 · 每次最多 $0.008
- [X 账号粉丝](https://okdata.online/zh/apis/x/users/followers/list/)：$0.0001/条 · 每次最多 $0.02
- [X 账号被提及](https://okdata.online/zh/apis/x/users/mentions/list/)：$0.0003/条 · 每次最多 $0.006
- [X 列表帖子](https://okdata.online/zh/apis/x/lists/posts/list/)：$0.002/次 · 每页约 100 条帖子
- [X 列表成员](https://okdata.online/zh/apis/x/lists/members/list/)：$0.0004/条 · 每次最多 $0.008
- [X 列表关注者](https://okdata.online/zh/apis/x/lists/followers/list/)：$0.0004/条 · 每次最多 $0.008
- [X 社群资料](https://okdata.online/zh/apis/x/communities/get/)：$0.0004/次
- [X 社群帖子](https://okdata.online/zh/apis/x/communities/posts/list/)：$0.0003/条 · 每次最多 $0.006
- [X 社群成员](https://okdata.online/zh/apis/x/communities/members/list/)：$0.0004/条 · 每次最多 $0.008

## 概要

- **简称**：X 账号关注
- **英文名**：X account following API
- **也叫**：推特关注、关注名单
- **分类**：[社交媒体](https://okdata.online/zh/categories/social/)
- **状态**：预览。还可能调整，改动会提前公告。
- **价格**：$0.0001（约 ¥0.00071） / 条 · 每次最多 $0.02
- **返回**：每页约 200 个账号，带翻下一页的游标
- **调用出错时**：不收费。一个数据源出错就换下一个；出错和超时都不扣费。

## 什么时候收费

- 返回了数据：每条 $0.0001，按返回条数收
- 参数不合法、出错、超时：不收费

| 情况 | 收费 |
|---|---|
| 每翻一页 | 另算一次调用，按条数计费 |
| 单次最高扣费 | $0.02 |
| 成功调用至少收 | $0.0004 |
| 空结果 | $0.0004 |
| 查无此项（平台上没有） | 不收费 |
| 参数不合法、出错、超时 | 不收费 |
| 24 小时内带同一个 Idempotency-Key 重试 | 只扣一次 |

调用失败不收费；空结果收 $0.0004；查无此项不收费。

价格取自价目表版本 1b273c48fea9634e。 [这个平台的全部价格](https://okdata.online/zh/pricing/x/)

- 新账号送 $0.10 试用额度，不用绑卡：够这个接口取 1000 个账号。
- 1,000 个账号共 $0.10。

## 已知限制

- 每页约 200 个账号，条数由平台决定，没有每页条数参数。
- 翻下一页时把 `page.next_cursor` 作为 `cursor` 传回。游标 24 小时内有效。`page.has_more` 为 false 时就没有下一页了。

## 各视图返回的字段

“视图”一列是字段最早出现的 `view`：`compact` 只返回 compact 字段，`standard` 再加上 standard 字段，`full` 返回全部。默认是 `standard`。

- `compact`：`id`, `url`, `username`, `name`, `bio`, `followers`, `following`, `posts`, `likes`
- `standard`：`avatar_url`, `verified`
- `full`：`ext`

## 这个接口的常见报错

| 状态码 | 代码 | 含义 | 是否扣费 | 能否重试 |
|---|---|---|---|---|
| 400 | `invalid_params` | 参数缺失、类型或取值不对，或者请求方法不对。problems 列出每一处问题，param 是第一个出错的参数。 | 否 | 修正后重试 |
| 400 | `cursor_mismatch` | cursor 发到了别的接口，或者参数和它所在那一页不一样（view 和 fields 可以变）。 | 否 | 修正后重试 |
| 401 | `unauthorized` | Key 缺失、格式不对、已撤销、已停用或已过期（知道原因时 reason 会写明）。 | 否 | 不要重试 |
| 402 | `insufficient_balance` | 余额（available）不够这次调用的最高费用（required）。 | 否 | 修正后重试 |
| 404 | `not_found` | 内容、账号或页面不存在或不公开。charge_when_not_found 大于 0 的接口会对这个结果计费（数据源也向我们收了钱）：这时返回体里 charged 为 true，并给出 amount。 | 否 | 不要重试 |
| 410 | `cursor_expired` | cursor 超过了这个接口的有效期（page.cursor_expires_at 写了到期时间）。 | 否 | 不要重试 |
| 429 | `rate_limited` | 账号这一分钟请求太多（reason: rate），或同时进行的调用太多（reason: concurrency）。 | 否 | 可以重试 |
| 500 | `settlement_unknown` | 数据已返回，但没能确认是否扣费。 | 查询后才知道 | 用同一个 Idempotency-Key 重试 |
| 502 | `upstream_failed` | 这个接口的所有数据源这次都失败了。 | 否 | 可以重试 |
| 503 | `capability_paused` | 这个接口暂时停用了，这次没有执行。 | 否 | 可以重试 |
| 504 | `timeout` | 数据没有及时返回。预扣已退回，这次没有扣费。 | 否 | 可以重试 |

[全部错误码](https://okdata.online/zh/docs/errors/)

## 在你的 AI 里用

> 先读 https://okdata.online/zh/apis/x/users/following/list.md，再用 okdata 帮我调这个接口，key 在环境变量 OKDATA_API_KEY 里。用「X 账号关注」查这个账号的粉丝数，说说它主要发什么。

## X（推特）的接口分组

- [X（推特）列表 API](https://okdata.online/zh/apis/x/lists/)：X 列表帖子 $0.002、X 列表成员 $0.0004、X 列表关注者 $0.0004
- [X（推特）社区 API](https://okdata.online/zh/apis/x/communities/)：X 社群资料 $0.0004、X 社群帖子 $0.0003、X 社群成员 $0.0004
