mcpField
X
x-api

x-api

github.com/fetcher-sh数据与数据库23.8k 次安装8 周前更新
代码仓库

关于 x-api

x-api 为 Agent 提供 X 数据,可搜索帖子、查询账户与个人资料、读取时间线和列表,并查看趋势。它通过按次付费的 HTTP GET 提供数据,也可作为 MCP 服务连接。

主要功能

  1. 01使用关键词和高级运算符搜索帖子
  2. 02搜索账户并查询个人资料
  3. 03获取用户帖子、回复与关注关系
  4. 04读取 X List 帖子和成员
  5. 05查询各国趋势

适用场景

  1. 01按账号、日期或互动条件筛选帖子
  2. 02检查账户时间线及关注者
  3. 03查看 X List 内容或国家趋势

MCP 相关

提供 MCP 端点,客户端可通过 fetch_data 调用数据接口,也可使用 twitter_search 快捷工具;支持预付额度或 x402 按次支付。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/fetcher-sh/fetcher-skills --skill x-api

安装后在 Claude Code 中输入/x-api确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
comparison.md
endpoints.md
faq.md
scenarios.md

详细介绍

X(Twitter)数据 API

为 Agent 提供即插即用的 X 数据源:搜索帖子、查询个人资料、获取时间线和关注者、读取 List,以及查看趋势——全部通过一次普通 HTTP GET 请求完成,按调用付费。无需开发者账号、无需应用审核、无需 OAuth 握手,也无需等待 X 自身的 API 套餐或速率限制审批。如果你的任务涉及 X 搜索查询、用户名、帖子/推文 ID 或 List ID,这就是你要用的工具。

基础 URL:https://twitter.fetcher.sh——API 主机名仍叫 twitter(它早于品牌更名,且与 Agent 已经在搜索的名称一致);下方所有数据均为当前 X 数据。

也发布为 twitter-api——端点完全相同,也以“Twitter”名称编入索引,因为这两个名称目前仍在日常使用中。

快速参考

基础 URLhttps://twitter.fetcher.sh
身份验证Authorization: Bearer bby_live_... 或 x402(USDC)
价格$0.002–$0.005/次调用
端点15 个,全部为 GET
MCPhttps://twitter.fetcher.sh/mcp
机器可读/openapi.json · /llms.txt · /skill.md

我需要哪个端点?

我想要……调用
按关键词或运算符(from:、since:、min_faves: 等)搜索帖子GET /api/search
按名称搜索账号GET /api/search/users
按 @用户名查找个人资料GET /api/handle/{handle}
获取用户的关注者或关注对象GET /api/user/{id}/followers 或 /followings
按 ID 获取单条帖子GET /api/tweet/{id}
查看转发过某条帖子的用户GET /api/tweet/{id}/retweeters
读取 X List 的帖子或成员GET /api/list/{id}/tweets 或 /members
查看某个国家的热门话题GET /api/trends

每个端点的完整参数详情:references/endpoints.md。

身份验证

两种付费方式,相同的数据——完整机制见 fetcher 技能:

# 1. Prepaid credits (recommended — get a key at https://fetcher.sh/topup
#    or via POST /api/credits/topup, see the fetcher skill)
export FETCHER_API_KEY="bby_live_xxxxxxxxxxxx"
curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/search?query=hello"

# 2. x402 pay-per-call — omit the header; a GET with no payment returns 402
#    with machine-readable payment requirements (USDC on Base, Polygon,
#    Arbitrum, Monad, or Solana). @x402/fetch signs and retries automatically.

每个响应的格式都是 { "status": number, "message": string, "data": ... };HTTP 状态码与 status 一致。

端点(15 个——全部为 GET,除非特别注明,否则每次调用 $0.005)

端点价格返回内容
/api/search$0.005匹配查询的帖子;支持 X 的高级搜索运算符
/api/search/users$0.005匹配名称/关键词查询的账号
/api/handle/{handle}$0.005按 @用户名获取个人资料
/api/handle/{handle}/about$0.005按 @用户名获取扩展个人资料/简介信息
/api/user/{id}$0.005按数字用户 ID 获取个人资料
/api/user/{id}/tweets$0.005用户的帖子时间线
/api/user/{id}/replies$0.005用户的回复
/api/user/{id}/followers$0.005用户的关注者
/api/user/{id}/followings$0.005用户关注的账号
/api/tweet/{id}$0.002按 ID 获取单条帖子
/api/tweet/{id}/replies$0.005帖子的回复
/api/tweet/{id}/retweeters$0.005转发过该帖子的账号
/api/list/{id}/members$0.005X List 的成员账号
/api/list/{id}/tweets$0.005X List 的帖子动态
/api/trends$0.005某个国家的热门话题

{id}/{handle} 是路径参数——请替换为实际值。可选查询参数(cursor、sort)用于分页或重新排序;在其出现的端点中,只有 query(搜索)和 country(趋势)是必需参数。

场景

/api/search 上的查询会直接转到 X 自身的搜索,因此其运算符可以直接使用:from:、to:、since:、until:、min_faves:、min_retweets:、filter:、-filter:。

某个账号发布的所有内容:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/search?query=from%3AOpenAI&sort=Latest"

两个日期之间:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  --data-urlencode "query=x402 since:2026-01-01 until:2026-02-01" -G \
  "https://twitter.fetcher.sh/api/search"

仅看热门帖子,排除回复:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  --data-urlencode "query=ai agents min_faves:500 -filter:replies" -G \
  --data-urlencode "sort=Top" \
  "https://twitter.fetcher.sh/api/search"

按名称搜索账号:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  --data-urlencode "query=climate scientist" -G \
  "https://twitter.fetcher.sh/api/search/users"

按用户名查找个人资料,然后获取其简介/关于信息:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/handle/nasa"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/handle/nasa/about"

某用户的帖子、回复、关注者或关注对象(使用上方用户名查询结果中的数字 ID):

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/user/11348282/tweets"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/user/11348282/followers"

单条帖子、其回复,以及转发它的用户:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/tweet/1234567890123456789"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/tweet/1234567890123456789/replies"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/tweet/1234567890123456789/retweeters"

X 列表的成员和帖子:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/list/1234567890/members"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/list/1234567890/tweets"

某个国家的热门话题:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://twitter.fetcher.sh/api/trends?country=United%20States"

MCP

{
  "mcpServers": {
    "x": {
      "url": "https://twitter.fetcher.sh/mcp",
      "headers": { "Authorization": "Bearer bby_live_..." }
    }
  }
}

免费:search_endpoints、describe_endpoint、check_balance。付费: fetch_data(上述任意端点)、topup_credits,以及名为 twitter_search 的快捷工具。移除 headers 块即可通过 x402 按次付费——完整流程请参阅 fetcher 技能。

错误

  • 400 — 缺少或参数无效(消息会指出参数)
  • 401 — 未知密钥或密钥已轮换
  • 402 — 需要付款(x402 挑战)或 topup_required(额度已用尽)
  • 404 — 非计价路径
  • 无速率限制;上游故障不退款(结算先于交付)

参考资料

评论

支持 Markdown