# X (Twitter) 用户搜索 API (twitter.search_users)

- Canonical page: https://everyinfra.com/twitter-api/search_users
- Endpoint: POST /api/v1/social with {"platform": "twitter", "action": "search_users", "params": {...}}
- Price: $0.000556 per call ($0.56 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` 找账号，匹配用户名、显示名和简介，对应 X 搜索的「用户」页，返回的是账号，不是帖子。每行带粉丝数、关注数、发帖数，以及这一页独有的头像 `avatar_url`、认证标识 `is_verified` 和创建时间 `created_at`。它回答「这个领域有哪些账号」，适合搭 KOL 候选名单，或者核对同名账号。

`keyword` 可以填话题（如 ai agents）、人名或用户名。一页大约 20 个账号，某一页偏少也可能还有下一页，继续翻要带上 `page_token`，令牌 24 小时内有效。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 搜账号用的关键词：话题（如 ai agents）、人名或用户名，按用户名、显示名和简介匹配（X 搜索的「用户」页）；返回账号，不返回帖子。 |
| page_token | not declared | no | not declared | 翻页令牌：把上一次响应里的 next_page_token 原样传回，拿下一页；不传从第一页开始。令牌 24 小时有效，每页算一次调用。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| next_page_token | platform-native meaning |
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| username | 用户名（@handle）。 |
| url | 该记录在原平台上的可访问链接。 |
| name | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| avatar_url | 头像图片链接。部分平台给的是带尺寸参数的 CDN 链接，可能有时效。 |
| follower_count | 粉丝数。null 表示不公开，不等于 0。 |
| following_count | 关注数。null 表示不公开，不等于 0。 |
| post_count | 发布内容总数。null 表示不公开，不等于 0。 |
| is_verified | 是否为平台认证账号（蓝V等）。null 表示无法判定。 |
| created_at | 创建时间，格式同 posted_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": "search_users",
  "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": "twitter",
        "action": "search_users",
        "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": "twitter",
  "action": "search_users",
  "results": [
    {
      "next_page_token": …,
      "id": …,
      "username": …,
      "url": …,
      "name": …,
      "text": …,
      "avatar_url": …,
      "follower_count": …,
      "following_count": …,
      "post_count": …,
      "is_verified": …,
      "created_at": …,
      "platform": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 这一页搜出来的是账号还是帖子？

是账号。`keyword` 按用户名、显示名和简介匹配，返回的每一行都是一个账号。想搜帖子正文，要用关键词搜索那一页，这一页不返回帖子。返回的账号带 `follower_count`、`following_count` 和 `post_count`，三者为 null 都是没公开，不是零。

### `is_verified` 是 null 怎么办？

null 表示无法判定，不等于账号没有认证。整理 KOL 名单时，把 true、false 和 null 分成三类，null 的账号打开 `url` 人工看一眼，再决定要不要留。`created_at` 的格式和帖子的发布时间一致，可以按注册时间把新号和老号分开看。

### 搜到候选账号之后下一步做什么？

把结果里的 `username` 交给用户内容那一页，读它发的帖子，看这个账号实际在聊什么；需要看它的受众，就交给粉丝列表。头像链接 `avatar_url` 可能会过期，需要留存就当场下载。

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