用 Python 批量获取 TikTok 视频评论

先用一次搜索找到视频,再按每页约 20 条翻完评论。实测 10 页拿到 200 条评论,加上搜索共 11 次调用,$0.022。

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

第 1 步:找到视频

按关键词搜索 TikTok,每条结果的 id 就是评论接口要的视频 ID。手上已经有视频链接的话可以跳过,链接里 /video/ 后面那串数字就是 ID。

TikTok 视频搜索·GET /v1/tiktok/videos/search·$0.002 / 次

curl "https://xtikapi.com/v1/tiktok/videos/search?keyword=camping+coffee" \
  -H "Authorization: Bearer YOUR_API_KEY"
录制的真实返回(列表只保留前两条)
{
  "data": {
    "items": [
      {
        "id": "0779509297655120597",
        "url": "https://example.com/link",
        "text": "Example text",
        "author": {
          "id": "xx1xxxxxxxxxxx-xxxxxxxxxxxx5xxxx37x9x6xxx_xxxxxx76xxxxxxxxxxx0xxx30x02xxxxx2",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 118728
        },
        "createdAt": "2026-11-07T13:41:13.000Z",
        "likeCount": 257030,
        "commentCount": 385,
        "shareCount": 24319,
        "viewCount": 2152698,
        "cover": "https://example.com/image.jpg"
      },
      {
        "id": "0776986179814197990",
        "url": "https://example.com/link",
        "text": "Example text",
        "author": {
          "id": "xx1xxxxxxxxx5xxxxxxxxxxx7xxx0xxxxxxx4-xxxxxxxxxxxxxxxx55xxxxx5x0xxxxxxxx9xxx",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 53345
        },
        "createdAt": "2026-10-31T12:06:19.000Z",
        "likeCount": 625844,
        "commentCount": 1046,
        "shareCount": 63850,
        "viewCount": 8935392,
        "cover": "https://example.com/image.jpg"
      }
    ],
    "has_more": true,
    "next": {
      "cursor": 20
    }
  },
  "meta": {
    "request_id": "example",
    "endpoint": "tiktok.videos.search",
    "normalized": true,
    "unavailable": [],
    "billing": {
      "charged": true,
      "amount": 0.002,
      "balance": 4.98
    }
  }
}

第 2 步:翻完每一页评论

把视频 ID 传给 id。每页约 20 条,循环把 data.next 加到参数里,直到它为 null。每一页算一次调用。

TikTok 视频评论·GET /v1/tiktok/comments/list·$0.002 / 次

curl "https://xtikapi.com/v1/tiktok/comments/list?id=7708408003065580831" \
  -H "Authorization: Bearer YOUR_API_KEY"
录制的真实返回(列表只保留前两条)
{
  "data": {
    "items": [
      {
        "id": "0772508255858426293",
        "text": "Example text",
        "author": {
          "id": "xx1xxxxxxxxx8xxx1xxxxxxxxxxxxxxxxxxxxx_xxxx7xx4xxxx3xxxxxxxxxxxxxxxxxxxxxx0x",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 0,
          "description": "Example text"
        },
        "createdAt": "2026-11-15T15:38:44.000Z",
        "likeCount": 349,
        "replyCount": 5
      },
      {
        "id": "0773410572235817260",
        "text": "Example text",
        "author": {
          "id": "xx1xxxxxxxxxxx5xxxxxxxxx653x-1x2xx2xx8xxxx4xxx_xxxxxx1xx4xxxxxx5xxx7xxxxxx1x",
          "username": "example_user",
          "name": "Example name",
          "avatar": "https://example.com/image.jpg",
          "followers": 0,
          "description": "Example text"
        },
        "createdAt": "2026-11-18T02:39:24.000Z",
        "likeCount": 2,
        "replyCount": 0
      }
    ],
    "has_more": true,
    "next": {
      "cursor": 20
    }
  },
  "meta": {
    "request_id": "example",
    "endpoint": "tiktok.comments.list",
    "normalized": true,
    "unavailable": [],
    "billing": {
      "charged": true,
      "amount": 0.002,
      "balance": 4.98
    }
  }
}

这个例子花多少钱

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

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

要注意的地方

  • 2026-11-22 实测每页 20 条评论。
  • 不含楼中楼回复,要的话用 tiktok.comment_replies.list,传视频 id 和评论的 id(作为 comment_id)。
  • 两次调用之间可能有新评论进来,合并多页时按 id 去重。

用到的接口

TikTok的更多内容

常见问题

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

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

需要申请 TikTok Research API 吗?

不需要。用本站的 API key 直接读公开评论,没有申请和审核。