mcpField
T
tiktok-api

tiktok-api

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

关于 tiktok-api

TikTok API 是通过 HTTP GET 端点获取 TikTok 帖子、个人资料、评论和发现类信息流的技能,适用于数据检索与研究工作流。可用 Bearer 密钥额度或 x402 按次付费,并提供 MCP 端点。

主要功能

  1. 01带筛选条件的关键词帖子搜索
  2. 02个人资料与关注者查询
  3. 03帖子评论和回复查询
  4. 04话题标签、声音及位置信息流
  5. 05Bearer 额度或 x402 付款

适用场景

  1. 01查找关键词相关的近期或热门帖子
  2. 02查看个人资料的帖子和关注者
  3. 03获取评论及评论回复
  4. 04追踪使用特定话题标签或声音的帖子

MCP 相关

它通过 `https://tiktok.fetcher.sh/mcp` 向 MCP 客户端提供 TikTok 数据端点。MCP 工具包括端点发现和余额查询,以及付费数据检索和额度充值。

安装

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

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

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

包含的文件

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

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

详细介绍

TikTok API

按需获取 TikTok 数据:按关键词搜索帖子并按排序方式/日期筛选、通过用户名查询个人资料、获取粉丝和关注列表、话题标签和音乐/声音信息流、按地点查询帖子,以及评论串——每次调用只需发送一个普通 HTTP GET 请求,按使用量付费。无需登录、会话 Cookie、浏览器自动化或 TikTok 开发者应用审核。

基础 URL:https://tiktok.fetcher.sh

快速参考

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

我需要哪个端点?

我想要……调用
按关键词搜索帖子(可选按最多赞/最新排序)GET /api/post/search
通过分享链接查询帖子GET /api/post?url=...
通过 @用户名查询个人资料GET /api/user/handle/{username}
获取用户的帖子、粉丝或关注列表GET /api/user/{id}/posts / /followers / /followings
获取帖子的评论GET /api/post/{id}/comments
查找某个话题标签下的帖子GET /api/hashtag/{id}/posts
查找使用特定声音的帖子GET /api/music/{id}/posts

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

身份验证

两种付费方式,数据相同——完整使用方式见 fetcher skill:

# 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://tiktok.fetcher.sh/api/post/search?keyword=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 一致。

端点(13 个——全部为 GET,每次调用 $0.004)

端点返回内容
/api/post/search符合关键词的帖子;支持排序和日期范围筛选
/api/post根据分享链接解析出的单条帖子
/api/post/{id}根据 ID 获取单条帖子
/api/post/{id}/comments帖子的评论
/api/post/{id}/comments/{commentId}/replies对评论的回复
/api/user/handle/{username}通过 @用户名查询个人资料
/api/user/{id}/posts用户的帖子
/api/user/{id}/followers用户的粉丝
/api/user/{id}/followings用户关注的账号
/api/hashtag/handle/{name}根据名称获取话题标签元数据
/api/hashtag/{id}/posts话题标签下的帖子
/api/music/{id}/posts使用某个声音/音乐曲目的帖子
/api/location/{locationId}/posts标记在某个地点的帖子

{id} / {username} / {name} 是路径参数。可选查询参数(cursor、region)用于分页或限定地理范围;keyword(搜索)和 url(查询帖子)在相应场景中为必填项。

使用场景

本月获赞最多的帖子:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  --data-urlencode "keyword=ai agent" -G \
  --data-urlencode "sortType=MOST_LIKED" \
  --data-urlencode "dateRange=THIS_MONTH" \
  "https://tiktok.fetcher.sh/api/post/search"

昨天发布,按最新优先排序:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  --data-urlencode "keyword=crypto payments" -G \
  --data-urlencode "sortType=DATE_POSTED" \
  --data-urlencode "dateRange=YESTERDAY" \
  "https://tiktok.fetcher.sh/api/post/search"

其他 sortType 值:RELEVANCE。其他 dateRange 值:ALL_TIME、 THIS_WEEK、LAST_THREE_MONTHS、LAST_SIX_MONTHS。

通过分享链接或直接通过 ID 查询帖子:

curl -H "Authorization: Bearer $FETCHER_API_KEY" -G \
  --data-urlencode "url=https://www.tiktok.com/@username/video/1234567890123456789" \
  "https://tiktok.fetcher.sh/api/post"

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

帖子的评论和评论回复:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/post/1234567890123456789/comments"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/post/1234567890123456789/comments/9876543210/replies"

通过 @用户名查询个人资料,然后获取其帖子、粉丝和关注列表:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/user/handle/khaby.lame"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/user/6935741396776976390/posts"

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

获取话题标签的元数据,然后获取其帖子:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/hashtag/handle/fyp"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/hashtag/1234567890/posts"

获取使用特定声音的帖子,以及来自某个地点的帖子:

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/music/1234567890123456789/posts"

curl -H "Authorization: Bearer $FETCHER_API_KEY" \
  "https://tiktok.fetcher.sh/api/location/1234567890123456789/posts"

MCP

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

免费:search_endpoints、describe_endpoint、check_balance。付费: fetch_data(以上任意端点)、topup_credits,以及命名快捷工具 tiktok_post_search。移除 headers 代码块即可使用 x402 按次付费——完整流程见 fetcher skill。

错误

  • 400 — 参数缺失/无效(消息会指出具体参数)
  • 401 — 密钥未知或已轮换
  • 402 — 需要付款(x402 挑战)或 topup_required(积分 已用完)
  • 404 — 非定价路径
  • 不限速;上游故障不退款(结算先于数据交付)

参考

评论

支持 Markdown