X / Twitter API
X / Twitter 搜索 API
使用完整的 X (Twitter) 高级搜索语法搜索(from:、since:、until:、min_faves: 等操作符可直接写在查询中),获取结构化推文,包含正文、作者、互动数据和游标分页。limit 是每页上限;原生页面约含 20 条推文,除非 requireSinglePage 选择了批量数据源。
POST/v1/run/twitter.search
可用率
99.99%
30d · 99,938 次调用
请求数
99,971
30d · 按周,近 12 周
响应时间
1.5s
中位数 · 30d
服务商网络
按流量排序的服务商
服务商
每次请求封顶 US$0.00511 条结果US$0.000225 条结果US$0.002650 条结果US$0.0051(封顶)按实际返回的内容计费。调低返回数量上限即可少付,而且无论返回多少,单次请求都不会超过封顶价。
每次请求封顶 US$0.01541 条结果US$0.0046225 条结果US$0.009950 条结果US$0.0154(封顶)按实际返回的内容计费。调低返回数量上限即可少付,而且无论返回多少,单次请求都不会超过封顶价。
试一试
发出你的第一个请求
requireFieldsarray可选;省略时路由不变,由最便宜的数据源处理。列出本次请求必须能返回的输出字段,例如 `nextCursor`,请求就只会由能返回全部这些字段的数据源处理。未列出的字段,只要处理请求的数据源有,仍会照常返回。这可能提高你的价格:最便宜的数据源无法返回某个列出的字段时,会改由更贵的数据源处理,并按它的价格报价和扣费。如果某条帖子确实没有某个列出的字段,该字段仍可能缺失。如果列出的字段组合没有任何单一数据源能同时返回,请求会作为无效输入被拒绝,不扣费。在分页遍历中,它只作用于第一页;后续页面沿用该页选定的数据源,按当时的报价计费。
示例响应
免费运行只返回前 3 条结果。为密钥充值即可获得完整响应。
{
"data": {
"authorFollowers": 12500,
"authorId": "Alex Rivera",
"authorImage": "https://example.com/image.jpg",
"items": [
{
"authorName": "Alex Rivera",
"authorUsername": "alex_rivera",
"authorVerified": true,
"bookmarkCount": 12500,
"conversationId": "a1b2c3d4",
"createdUtc": 12.5,
"id": "a1b2c3d4",
"inReplyToId": "a1b2c3d4",
"isReply": true,
"lang": "en",
"likeCount": 12500,
"media": [
{
"height": 42,
"type": "general",
"url": "https://example.com/page",
"videoUrl": "https://example.com/page",
"width": 1024
}
],
"quoteCount": 12500,
"replyCount": 12500,
"retweetCount": 12500,
"text": "A short example description of this item.",
"url": "https://example.com/page",
"viewCount": 12500
}
],
"nextCursor": "example"
},
"found": true,
"reason": "not_found"
}响应类型定义
interface TwitterSearchResponse {
data: {
authorFollowers?: number;
authorId?: string;
authorImage?: string;
items: {
authorName?: string;
authorUsername?: string;
authorVerified?: boolean;
bookmarkCount?: number;
conversationId?: string;
createdUtc?: number;
id: string;
inReplyToId?: string | null;
isReply?: boolean;
lang?: string;
likeCount?: number;
media?: {
height?: number;
type: string;
url: string;
videoUrl?: string;
width?: number;
}[];
quoteCount?: number;
replyCount?: number;
retweetCount?: number;
text: string;
url: string;
viewCount?: number | null;
}[];
nextCursor?: string | null;
} | null;
found: boolean;
reason?: "not_found";
}完整的参数与响应参考:这个接口的每个字段、类型和示例。
参考
请求、响应与价格
最近验证于 2026-09-29 · 可用率和延迟按 30d 统计POST /v1/run/twitter.search
curl -X POST https://api.getanyapi.com/v1/run/twitter.search \
-H "Authorization: Bearer $ANYAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"openai"}'| 字段 | 类型 | 示例值 |
|---|---|---|
| 请求体 | ||
| query | string | "openai"使用 X (Twitter) 高级搜索语法的查询。重要:多个裸词之间是 AND 关系,推文必须包含每一个词,所以一串松散相关的关键词什么也匹配不到;请使用一个简短短语,或在备选词之间用 OR(例如 'anyapi OR getanyapi')。当操作符跟在 OR 列表之后时,请用括号括住列表,例如 '(anyapi OR getanyapi) -filter:replies':不加括号时 X 只把操作符应用到最后一个备选词,因此这类查询会被拒绝,不扣费,并返回修正后的查询。你可以直接在查询中嵌入 X 高级搜索操作符来筛选结果:from:username 和 to:username(作者或接收者)、since:YYYY-MM-DD 和 until:YYYY-MM-DD(日期范围)、min_faves:N、min_retweets:N、min_replies:N(互动下限)、"exact phrase"、用 -term 排除、filter:media、filter:links 和 -filter:replies(内容筛选)、lang:en、near:city 以及 geocode:lat,long,radius。示例:'from:OpenAI'、'AI agents min_faves:500 -filter:replies'、'nvidia since:2026-01-01 until:2026-03-01'。没有匹配的查询会返回空的 items 数组;尽量用最少的词来确定主题。 |
| cursor | string | 来自上一次响应 nextCursor 的不透明分页游标。第一页请省略;传入它以获取下一页搜索结果。 |
| limit | integer | 每页返回结果的最大数量(1-50,默认 20)。服务商可能返回更小的原生页面;更多结果请沿 nextCursor 继续获取。 |
| queryType | enum | 要返回哪些帖子:'Latest'(最新优先,默认)、'Top'(最热门)、'Photos'(含图片的最新帖子)或 'Videos'(含视频的最新帖子)。Photos 和 Videos 会按你写的查询搜索,并在其后加上 filter:images 或 filter:videos,因此价格与 Latest 搜索相同。 |
| requireFields | array | 可选;省略时路由不变,由最便宜的数据源处理。列出本次请求必须能返回的输出字段,例如 `nextCursor`,请求就只会由能返回全部这些字段的数据源处理。未列出的字段,只要处理请求的数据源有,仍会照常返回。这可能提高你的价格:最便宜的数据源无法返回某个列出的字段时,会改由更贵的数据源处理,并按它的价格报价和扣费。如果某条帖子确实没有某个列出的字段,该字段仍可能缺失。如果列出的字段组合没有任何单一数据源能同时返回,请求会作为无效输入被拒绝,不扣费。在分页遍历中,它只作用于第一页;后续页面沿用该页选定的数据源,按当时的报价计费。 |
| requireSinglePage | boolean | 设为 true 可在一个响应中获取最多 limit 条结果,而不是按服务商原生页面返回;需要时由批量服务商处理。 |
| 响应 | ||
| data | object | |
| data.authorFollowers | integer | Follower count of the account that posted. |
| data.authorId | string | Numeric X user id of the account that posted, as a string. |
| data.authorImage | string | Avatar image URL of the account that posted. |
| data.items | object[] | Tweet records: text, author profile, timestamp, and engagement metrics (likes, retweets, replies, views). Populated whenever the provider has data for the entity. |
| data.items[].authorName | string | Populated whenever the provider has data for the entity. |
| data.items[].authorUsername | string | Populated whenever the provider has data for the entity. |
| data.items[].authorVerified | boolean | |
| data.items[].bookmarkCount | integer | |
| data.items[].conversationId | string | |
| data.items[].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.items[].id | string | Populated whenever the provider has data for the entity. |
| data.items[].inReplyToId | string | Id of the post this post directly replies to, as a string, or null when the post is not a reply. |
| data.items[].isReply | boolean | |
| data.items[].lang | string | |
| data.items[].likeCount | integer | |
| data.items[].media | object[] | Photo, video, and GIF attachments on the post. Empty when the post has none. |
| data.items[].media[].height | integer | Pixel height of the media item, when the lane reports it. |
| data.items[].media[].type | string | One of photo, video, or gif. |
| data.items[].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.items[].media[].videoUrl | string | Playable video file URL. Present only for video and gif items. |
| data.items[].media[].width | integer | Pixel width of the media item, when the lane reports it. |
| data.items[].quoteCount | integer | |
| data.items[].replyCount | integer | |
| data.items[].retweetCount | integer | |
| data.items[].text | string | Populated whenever the provider has data for the entity. |
| data.items[].url | string | Populated whenever the provider has data for the entity. |
| data.items[].viewCount | integer | Number of views. Null when the source does not report it, as for posts older than X view counts. |
| data.nextCursor可设为必填 | string | Opaque cursor for the next page of search results, or null when there are no more. Pass it back as cursor to continue. |
| found | boolean | |
| reason | "not_found" | 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. A `found: false` answer is a successful call, not an error, and `costUsd` is what it actually cost. |
| 价格 | ||
| 每次请求价格 | USD | US$0.00065 |
| 价格(/千次请求) | USD | US$0.65 |
常见问题
关于 X / Twitter 搜索 API
AnyAPI 的 X / Twitter 搜索 API 只需一次 POST 请求 /v1/run/twitter.search,就以统一格式的 JSON 返回 X / Twitter 数据。使用完整的 X (Twitter) 高级搜索语法搜索(from:、since:、until:、min_faves: 等操作符可直接写在查询中),获取结构化推文,包含正文、作者、互动数据和游标分页。limit 是每页上限;原生页面约含 20 条推文,除非 requireSinglePage 选择了批量数据源。AnyAPI 会在 4 个数据源之间路由每个请求,某个数据源失败时自动切换。费用:每千次请求 US$0.65 起,以美元计价,无需订阅,也没有每月最低消费。过去 30 天,通过 AnyAPI 发起的 X / Twitter 搜索 API 调用中有 100.0% 成功,响应时间中位数为 1.5 秒,共测量 99,938 次调用。
费用:每千次请求 US$0.65 起,以美元计价,无需订阅,也没有每月最低消费。你只需为一个美元钱包充值,每次调用从中扣费。部分由钱包付费的失败请求会产生处理费用,我们按成本原价转嫁,不加价;错误响应会显示收取的金额。
使用完整的 X (Twitter) 高级搜索语法搜索(from:、since:、until:、min_faves: 等操作符可直接写在查询中),获取结构化推文,包含正文、作者、互动数据和游标分页。limit 是每页上限;原生页面约含 20 条推文,除非 requireSinglePage 选择了批量数据源。响应是统一格式的 JSON,外层结构与每个 AnyAPI 接口相同,所以解析另一个接口只需换一个 URL,别的都不用改。
过去 30 天,通过 AnyAPI 发起的 X / Twitter 搜索 API 调用中有 100.0% 成功,响应时间中位数为 1.5 秒,共测量 99,938 次调用。这些是 AnyAPI 对经过网关的流量的自有测量,持续重新计算,并非公开承诺的服务等级目标。