# X (Twitter) 按 ID 批量查资料 API (twitter.profiles_by_ids)

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

X 按 ID 批量查资料用 `user_ids` 一次查最多 20 个账号，可以传数字用户 ID 数组，也可以传逗号分隔的字符串。每行是一个账号的资料：`username`、`display_name`、`location`、`is_verified`、`is_protected`、`affiliation` 和 `created_at` 等。它回答「手上这批数字 ID 分别是谁」，适合把名单里的 ID 还原成账号，或批量核对认证和受保护状态。

数字用户 ID 是账号的稳定标识，X 官方一次最多可取 100 个，这里的上限是 20 个。账号所在国家和改名记录不在这一页，要用「关于此账号」那一页，它一次读一个用户名。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| user_ids | not declared | yes | not declared | 数字用户 ID 数组（或逗号分隔的字符串），一次 1–20 个；按一次调用计费，不按个数。 |
| limit | integer (1–20) | no | 20 | 这次调用最多返回的条数，整数，1–20；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| user_id | 用户在原平台的唯一 ID。 |
| username | 用户名（@handle）。 |
| display_name | 显示名，可能与 username 不同。 |
| url | 该记录在原平台上的可访问链接。 |
| location | 地理位置描述，原文透传，格式随平台而异。 |
| is_verified | 是否为平台认证账号（蓝V等）。null 表示无法判定。 |
| is_protected | 账号是否为受保护状态（推文仅粉丝可见）。 |
| affiliation | 账号挂的机构标签（如员工账号挂的公司名「X」）；没挂时没有这个字段。 |
| avatar_url | 头像图片链接。部分平台给的是带尺寸参数的 CDN 链接，可能有时效。 |
| created_at | 创建时间，格式同 posted_at。 |
| account_status | 账号状态，正常是 active（被封或停用时为其他值）。 |
| 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": "profiles_by_ids",
  "params": {
    "user_ids": [
      "44196397",
      "11348282"
    ]
  }
}'
```

```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": "profiles_by_ids",
        "params": {
            "user_ids": [
                "44196397",
                "11348282",
            ],
        },
    },
    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": "profiles_by_ids",
  "results": [
    {
      "user_id": …,
      "username": …,
      "display_name": …,
      "url": …,
      "location": …,
      "is_verified": …,
      "is_protected": …,
      "affiliation": …,
      "avatar_url": …,
      "created_at": …,
      "account_status": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 一次最多能查几个 ID，怎么计费？

一次 1–20 个，数组或逗号分隔的字符串都行，按一次调用计费，不按个数。所以一批名单尽量凑满 20 个再调，调用次数更少。

### `location` 是账号真实所在地吗？

不能这样理解。它是原文透传的地理位置描述，格式随平台而异，没有准确性标记。要 X 在「关于此账号」页给出的所在国家和准确性判断，用账号所在地与改名记录那一页。

### 怎么判断账号还正常？

看 `account_status`，正常是 active，被封或停用时是其他值。`is_protected` 为真表示推文仅粉丝可见，`is_verified` 为 null 表示无法判定。名单清洗时先按这三个字段分组，再决定哪些账号值得继续读。

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