用 Python 获取 X(推特)用户的推文

传用户名,用 data.next 每页 20 条往下翻。10 页 200 条推文,10 次调用、$0.02;据报道用 X 官方按量付费 API 读 200 条约 $1。

更新于 2026-11-22·本页 Markdown

翻完全部推文

screen_name 填不带 @ 的用户名。存的是数字用户 ID 的话传 rest_id,这么长的 ID 会保持字符串,避免被四舍五入。data.next 里的游标原样传回。

X(推特)用户推文·GET /v1/x/posts/list·$0.002 / 次

curl "https://xtikapi.com/v1/x/posts/list?screen_name=NASA" \
  -H "Authorization: Bearer YOUR_API_KEY"
录制的真实返回(列表只保留前两条)
{
  "data": {
    "items": [
      {
        "id": "5197244563152330773",
        "text": "Example text",
        "author": {
          "id": "41089034",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 92213506
        },
        "createdAt": "2026-11-18T21:40:00.000Z",
        "likeCount": 1521,
        "commentCount": 63,
        "shareCount": 243,
        "viewCount": 218599,
        "url": "https://example.com/link"
      },
      {
        "id": "5197231336585028234",
        "text": "Example text",
        "author": {
          "id": "41089034",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 92213506
        },
        "createdAt": "2026-11-18T20:47:24.000Z",
        "likeCount": 506,
        "commentCount": 41,
        "shareCount": 53,
        "viewCount": 193300,
        "url": "https://example.com/link"
      }
    ],
    "has_more": true,
    "next": {
      "cursor": "DAAHCgABHXc0…"
    }
  },
  "meta": {
    "request_id": "example",
    "endpoint": "x.posts.list",
    "normalized": true,
    "unavailable": [
      "cover"
    ],
    "billing": {
      "charged": true,
      "amount": 0.002,
      "balance": 4.98
    }
  }
}

这个例子花多少钱

调用次数:10
单价:$0.002
小计:$0.02
合计
调用次数:10
单价:—
小计:$0.02

失败和超时不收费。验证过邮箱的新账号送 $0.50 试用额度,够跑完这个例子。

要注意的地方

  • 2026-11-22 实测每页 20 条,第二页没有重复。
  • 每条推文带点赞、回复、转推和浏览量;没有图片或视频的推文,meta.unavailable 里会写 cover。
  • 和 X 官方的对比见我们关于 X API 价格的问答页,有出处。

用到的接口

X(推特)的更多内容

常见问题

用 XTikAPI 做这件事要花多少钱?

按本文的例子是 10 次调用,共 $0.02。失败和超时不收费;验证过邮箱的新账号送 $0.50 试用额度。

需要 X 开发者账号吗?

不需要。用本站的 API key 读公开推文,不用开发者后台、应用审核或月费套餐。