X / Twitter API
X / Twitter 用户帖子 API
按用户名获取 X (Twitter) 账号主页“帖子”标签页的时间线。结果按主页顺序排列:置顶帖子可能排在最前,其后按时间倒序排列本人发布的帖子、转帖、引用和作者自发帖子串的后续帖子。
POST/v1/run/twitter.user_posts
可用率
99.88%
30d · 21,075 次调用
请求数
21,077
30d · 按周,近 12 周
响应时间
2.2s
中位数 · 30d
服务商网络
按流量排序的服务商
服务商
每次请求封顶 US$0.00211 条结果US$0.000210 条结果US$0.001120 条结果US$0.0021(封顶)按实际返回的内容计费。调低返回数量上限即可少付,而且无论返回多少,单次请求都不会超过封顶价。
试一试
发出你的第一个请求
requireFieldsarray可选;省略时路由不变,由最便宜的数据源处理。列出本次请求必须能返回的输出字段,例如 `isPinned` 或 `isReply`,请求就只会由能返回全部这些字段的数据源处理。未列出的字段,只要处理请求的数据源有,仍会照常返回。这可能提高你的价格:最便宜的数据源无法返回某个列出的字段时,会改由更贵的数据源处理,并按它的价格报价和扣费。如果某条推文确实没有某个列出的字段,该字段仍可能缺失。如果列出的字段组合没有任何单一数据源能同时返回,请求会作为无效输入被拒绝,不扣费。在分页遍历中,它只作用于第一页;后续页面沿用该页选定的数据源,按当时的报价计费。
示例响应
免费运行只返回前 3 条结果。为密钥充值即可获得完整响应。
{
"data": {
"nextCursor": "example",
"tweets": [
{
"authorHandle": "alex_rivera",
"authorId": "Alex Rivera",
"authorImage": "https://example.com/image.jpg",
"authorName": "Alex Rivera",
"bookmarks": 42,
"conversationId": "a1b2c3d4",
"createdUtc": 12.5,
"id": "a1b2c3d4",
"isPinned": true,
"isReply": true,
"lang": "en",
"likes": 12500,
"media": [
{
"height": 42,
"type": "general",
"url": "https://example.com/page",
"videoUrl": "https://example.com/page",
"width": 1024
}
],
"quotes": 42,
"replies": 42,
"retweets": 42,
"source": "https://example.com/page",
"text": "A short example description of this item.",
"url": "https://example.com/page",
"views": 12500
}
]
},
"found": true,
"reason": "not_found"
}响应类型定义
interface TwitterUserPostsResponse {
data: {
nextCursor: string | null;
tweets: {
authorHandle?: string;
authorId?: string;
authorImage?: string;
authorName?: string;
bookmarks: number;
conversationId?: string;
createdUtc: number;
id: string;
isPinned: boolean | null;
isReply?: boolean;
lang?: string;
likes: number;
media?: {
height?: number;
type: string;
url: string;
videoUrl?: string;
width?: number;
}[];
quotes?: number;
replies: number;
retweets: number;
source?: string;
text: string;
url: string;
views: number;
}[];
} | null;
found: boolean;
reason?: "not_found" | "suspended";
}完整的参数与响应参考:这个接口的每个字段、类型和示例。
参考
请求、响应与价格
最近验证于 2026-09-29 · 可用率和延迟按 30d 统计POST /v1/run/twitter.user_posts
curl -X POST https://api.getanyapi.com/v1/run/twitter.user_posts \
-H "Authorization: Bearer $ANYAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"handle":"levelsio"}'| 字段 | 类型 | 示例值 |
|---|---|---|
| 请求体 | ||
| handle | string | "levelsio"Twitter/X 用户名,不带开头的 @。 |
| cursor | string | 来自上一次响应 nextCursor 的不透明分页游标。获取第一页时省略。 |
| requireFields | array | 可选;省略时路由不变,由最便宜的数据源处理。列出本次请求必须能返回的输出字段,例如 `isPinned` 或 `isReply`,请求就只会由能返回全部这些字段的数据源处理。未列出的字段,只要处理请求的数据源有,仍会照常返回。这可能提高你的价格:最便宜的数据源无法返回某个列出的字段时,会改由更贵的数据源处理,并按它的价格报价和扣费。如果某条推文确实没有某个列出的字段,该字段仍可能缺失。如果列出的字段组合没有任何单一数据源能同时返回,请求会作为无效输入被拒绝,不扣费。在分页遍历中,它只作用于第一页;后续页面沿用该页选定的数据源,按当时的报价计费。 |
| 响应 | ||
| data | object | The Posts-tab timeline page, or null when the account was not found. |
| data.nextCursor | string | Opaque cursor for the next native Posts-tab page, or null when no more pages are available. |
| data.tweets | object[] | Posts in profile order. A pinned post may appear before otherwise reverse-chronological results. Populated whenever the provider has data for the entity. |
| data.tweets[].authorHandle | string | Handle of the account that posted. |
| data.tweets[].authorId | string | Numeric X user id of the account that posted, as a string. |
| data.tweets[].authorImage | string | Avatar image URL of the account that posted. |
| data.tweets[].authorName | string | Display name of the account that posted. |
| data.tweets[].bookmarks | integer | Number of bookmarks. |
| data.tweets[].conversationId | string | Id of the conversation the post belongs to, as a string. |
| data.tweets[].createdUtc | number | UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds. Populated whenever the provider has data for the entity. |
| data.tweets[].id | string | The post's numeric tweet ID, represented as a string. Populated whenever the provider has data for the entity. |
| data.tweets[].isPinned可设为必填 | boolean | Whether X marks the post as pinned on the profile, or null when the serving source does not publish it. |
| data.tweets[].isReply可设为必填 | boolean | Whether X marks the record as a reply. Certified Posts-tab captures use this for self-thread continuations. |
| data.tweets[].lang | string | Language code reported for the post, when available. |
| data.tweets[].likes | integer | Number of likes. |
| data.tweets[].media | object[] | Photo, video, and GIF attachments on the post. Empty when the post has none. |
| data.tweets[].media[].height | integer | |
| data.tweets[].media[].type | string | One of photo, video, or gif. |
| data.tweets[].media[].url | string | Image URL. For a video or GIF this is the poster/thumbnail frame. X media URLs on pbs.twimg.com are publicly fetchable without authentication; append ?name=orig for the full-resolution original. |
| data.tweets[].media[].videoUrl | string | Playable video file URL. Present only for video and gif items. |
| data.tweets[].media[].width | integer | |
| data.tweets[].quotes | integer | Number of quote posts. |
| data.tweets[].replies | integer | Number of replies. |
| data.tweets[].retweets | integer | Number of reposts or retweets. |
| data.tweets[].source | string | Client the post was sent from, e.g. "Twitter Web App". |
| data.tweets[].text | string | The post text. Empty for media-only posts. Populated whenever the provider has data for the entity. |
| data.tweets[].url | string | Canonical x.com URL of the post. Populated whenever the provider has data for the entity. |
| data.tweets[].views | integer | Number of views. |
| found | boolean | Whether the account's Posts-tab timeline was returned. |
| reason | "not_found" | "suspended" | Present only when `found` is false, and says why there is no result. `not_found`: the source states the target does not exist, or returned nothing for it. `suspended`: the platform has suspended the account. A `found: false` answer is a successful call, not an error, and `costUsd` is what it actually cost. |
| 价格 | ||
| 每次请求价格 | USD | US$0.0005 |
| 价格(/千次请求) | USD | US$0.50 |
常见问题
关于 X / Twitter 用户帖子 API
AnyAPI 的 X / Twitter 用户帖子 API 只需一次 POST 请求 /v1/run/twitter.user_posts,就以统一格式的 JSON 返回 X / Twitter 数据。按用户名获取 X (Twitter) 账号主页“帖子”标签页的时间线。结果按主页顺序排列:置顶帖子可能排在最前,其后按时间倒序排列本人发布的帖子、转帖、引用和作者自发帖子串的后续帖子。AnyAPI 会在 3 个数据源之间路由每个请求,某个数据源失败时自动切换。费用:每千次请求 US$0.50 起,以美元计价,无需订阅,也没有每月最低消费。过去 30 天,通过 AnyAPI 发起的 X / Twitter 用户帖子 API 调用中有 99.9% 成功,响应时间中位数为 2.2 秒,共测量 21,075 次调用。
费用:每千次请求 US$0.50 起,以美元计价,无需订阅,也没有每月最低消费。你只需为一个美元钱包充值,每次调用从中扣费。部分由钱包付费的失败请求会产生处理费用,我们按成本原价转嫁,不加价;错误响应会显示收取的金额。
按用户名获取 X (Twitter) 账号主页“帖子”标签页的时间线。结果按主页顺序排列:置顶帖子可能排在最前,其后按时间倒序排列本人发布的帖子、转帖、引用和作者自发帖子串的后续帖子。响应是统一格式的 JSON,外层结构与每个 AnyAPI 接口相同,所以解析另一个接口只需换一个 URL,别的都不用改。
过去 30 天,通过 AnyAPI 发起的 X / Twitter 用户帖子 API 调用中有 99.9% 成功,响应时间中位数为 2.2 秒,共测量 21,075 次调用。这些是 AnyAPI 对经过网关的流量的自有测量,持续重新计算,并非公开承诺的服务等级目标。