用户资料
获取单个或多个用户的公开资料(简介、粉丝数、头像等)。
单个用户
GET /twitter/user/{username_or_id}
路径参数
| 参数 | 说明 |
|---|---|
username_or_id | 不含 @ 的用户名,或数字用户 ID |
JavaScript 等语言请把大整数 ID 当 字符串 处理,使用响应里的
id_str。
请求示例
bash
# 按用户名
curl "https://twidata.wvovw.com/twitter/user/elonmusk" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"
# 按数字 ID
curl "https://twidata.wvovw.com/twitter/user/44196397" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json"成功响应(节选)
json
{
"id": 44196397,
"id_str": "44196397",
"name": "Elon Musk",
"screen_name": "elonmusk",
"location": "",
"url": null,
"description": "",
"protected": false,
"verified": true,
"followers_count": 166213974,
"friends_count": 506,
"listed_count": 149577,
"favourites_count": 37987,
"statuses_count": 34934,
"created_at": "2009-06-02T20:12:29.000000Z",
"profile_banner_url": "https://pbs.twimg.com/profile_banners/...",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/...",
"can_dm": false
}常用字段
| 字段 | 说明 |
|---|---|
id / id_str | 用户数字 ID(优先用 id_str) |
screen_name | 用户名(handle) |
name | 显示名 |
description | 简介 |
protected | 是否保护账号 |
followers_count | 粉丝数 |
friends_count | 关注数 |
statuses_count | 发推数 |
profile_image_url_https | 头像 |
计费
成功返回 1 个资料 ≈ 扣 1 点(默认单价)。
错误码
| HTTP | 含义 |
|---|---|
| 200 | 成功 |
| 401 / 402 | 鉴权失败 / 余额不足 |
| 404 | 用户不存在 |
| 422 | 参数错误 |
| 500 | 上游失败,可重试 |
批量:按 ID
POST /twitter/users-by-ids
单次最多 100 个 ID。
bash
curl -X POST "https://twidata.wvovw.com/twitter/users-by-ids" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"ids":["44196397","1319287761048723458"]}'响应形如 { "users": [ ... ] }。计费按返回的 users 条数。
批量:按用户名
POST /twitter/users-by-usernames
单次最多 100 个用户名(不含 @)。
bash
curl -X POST "https://twidata.wvovw.com/twitter/users-by-usernames" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"usernames":["elonmusk","OpenAI"]}'相关接口
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /twitter/user/{user_id}/followers | 粉丝列表(需数字 ID) |
| GET | /twitter/user/{user_id}/following | 关注列表 |
| GET | /twitter/user/{user_id}/verified-followers | 认证粉丝 |
| GET | /twitter/user/{username}/mentions | 被提及 |
| GET | /twitter/user/{user_id}/tweets | 用户推文 |
粉丝 / 关注详见 粉丝与关注。