mcpField
T
tikhub-api-helper

tikhub-api-helper

github.com/liangdabiao数据与数据库130309 次安装16 周前更新
代码仓库

关于 tikhub-api-helper

tikhub-api-helper 是面向社交媒体数据查询的技能,可搜索 TikHub API 端点并通过脚本发起请求。它覆盖多个社交平台,适合需要查找接口并整理返回数据的工作流。

主要功能

  1. 01按关键词搜索 API
  2. 02按标签列出接口
  3. 03查看接口参数详情
  4. 04发送 API 请求并整理结果
  5. 05覆盖多个社交平台

适用场景

  1. 01获取用户资料
  2. 02查询视频详情与评论
  3. 03搜索视频或用户

安装

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

$npx skills add https://github.com/liangdabiao/tikhub_api_skill --skill tikhub-api-helper

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

附带文件api_client.pyapi_searcher.py

详细介绍

TikHub API 助手

帮助用户搜索、查找和调用 TikHub API 端点,以获取社交媒体数据。

快速入门

当用户询问 TikHub API 或想要获取社交媒体数据时:

  1. 搜索相关 API:使用搜索脚本
  2. 向用户展示可用选项及其参数
  3. 调用 API并传入适当的参数
  4. 向用户返回格式化结果

可用脚本

API 搜索器 - api_searcher.py

搜索并查找相关的 TikHub API 端点。

# Search by keyword
python api_searcher.py "user profile"
python api_searcher.py "视频评论"
python api_searcher.py "trending"

# List all APIs for a specific tag/category
python api_searcher.py tag:TikTok-Web-API
python api_searcher.py tag:Douyin-App-V3-API

# List popular/common APIs
python api_searcher.py popular

# List all available tags/categories
python api_searcher.py tags

# Get detailed info for a specific API
python api_searcher.py detail:tiktok_web_fetch_user_profile_get
API 客户端 - api_client.py

向 TikHub API 端点发送 HTTP 请求。

# Health check (no authentication required)
python api_client.py GET /api/v1/health/check

# Get user profile
python api_client.py GET /api/v1/tiktok/web/fetch_user_profile "sec_user_id=MS4wLjABAAAA..."

# Search for videos
python api_client.py GET /api/v1/tiktok/web/fetch_search_video "keyword=gaming"

# POST request with JSON body
python api_client.py POST /api/v1/tiktok/web/generate_xgnarly '{"url": "https://..."}'

支持的平台

平台标签名称可用 API
TikTok WebTikTok-Web-API58 个端点
TikTok AppTikTok-App-V3-API76 个端点
抖音 WebDouyin-Web-API76 个端点
抖音 AppDouyin-App-V3-API45 个端点
抖音搜索Douyin-Search-API20 个端点
抖音榜单Douyin-Billboard-API31 个端点
小红书 WebXiaohongshu-Web-API26 个端点
InstagramInstagram-V2-API26 个端点
YouTubeYouTube-Web-API16 个端点
TwitterTwitter-Web-API13 个端点
RedditReddit-APP-API23 个端点
BilibiliBilibili-Web-API24 个端点
微博Weibo-Web-V2-API33 个端点
知乎Zhihu-Web-API32 个端点

使用 python api_searcher.py tags 查看所有类别。

常见用例

获取用户个人资料
# TikTok user profile
python api_searcher.py "fetch user profile tiktok"
python api_client.py GET /api/v1/tiktok/web/fetch_user_profile "sec_user_id=USER_ID"
获取视频详情
# TikTok video details
python api_searcher.py "fetch post detail"
python api_client.py GET /api/v1/tiktok/web/fetch_post_detail "post_id=POST_ID"
搜索内容
# Search for videos/users
python api_searcher.py "search video"
python api_client.py GET /api/v1/tiktok/web/fetch_search_video "keyword=YOUR_KEYWORD"
获取评论
# Get video comments
python api_searcher.py "fetch comment"
python api_client.py GET /api/v1/tiktok/web/fetch_post_comment "post_id=POST_ID"

身份验证

API 请求使用用于开发的默认令牌。用于生产环境时,用户应:

  1. 从 TikHub User 获取 API 令牌
  2. 设置 TIKHUB_TOKEN 环境变量
  3. 或修改 api_client.py 中的 DEFAULT_TOKEN

请求格式:

{
  "Authorization": "Bearer YOUR_API_TOKEN"
}

基础 URL

  • 中国用户:https://api.tikhub.dev(可绕过 GFW)
  • 国际用户:https://api.tikhub.io

API 客户端会自动检测适用的 URL。如需覆盖,请修改客户端中的 use_china_domain 参数。

速率限制

  • QPS:每个端点每秒 10 个请求
  • 超时:30-60 秒
  • 重试:出错时最多重试 3 次

Claude 使用说明

使用 TikHub API 协助用户时:

  1. 了解用户目标:他们需要什么数据?来自哪个平台?
  2. 搜索相关 API:使用 api_searcher.py 和适当的关键词
  3. 提供选项:展示匹配的 API 及简要说明
  4. 指导设置参数:通过 detail:OPERATION_ID 查看所需参数
  5. 发送请求:使用 api_client.py 和用户提供的参数
  6. 格式化结果:以清晰易读的格式呈现 API 响应
工作流示例

用户:“我想获取某个 TikTok 用户的个人资料”

# Step 1: Search for the relevant API
python api_searcher.py "tiktok user profile"

# Step 2: Show results and confirm endpoint
# Found: GET /api/v1/tiktok/web/fetch_user_profile

# Step 3: Get detailed parameter info
python api_searcher.py detail:tiktok_web_fetch_user_profile_get

# Step 4: Make the API call with user's parameters
python api_client.py GET /api/v1/tiktok/web/fetch_user_profile "sec_user_id=MS4wLjABAAAA..."

# Step 5: Format and present results

错误处理

常见错误及解决方案:

错误解决方案
401 Unauthorized检查 API 令牌是否有效
429 Too Many Requests已超出速率限制,请等待后重试
Connection error检查网络;如果在中国大陆,请尝试使用中国域名
Missing parameter查看 API 详情,确认所需参数

参考资料

评论

支持 Markdown