TikHub-API-Python-SDK is a free, open source data extraction & web scraping project written in Python and released under Apache-2.0. It has 934 GitHub stars, 88 forks and 0 open issues, and was last pushed 1 months ago. On this registry it ranks #123 of 150 tracked projects in Data Extraction & Web Scraping, with 5 head-to-head comparisons available. It gained 35 stars over the last 30 tracked days.

What is TikHub-API-Python-SDK?

TikHub API Python SDK is the official Python client for the TikHub social media data API, giving developers, data scientists, and AI engineers programmatic access to more than 1,000 endpoints across 16 social platforms through a single API key.

What it is

TikHub API Python SDK is the official Python SDK for TikHub, a unified REST API that provides real-time access to more than 16 social media platforms, including TikTok, Douyin, Instagram, YouTube, Twitter/X, Xiaohongshu (Red Note), Bilibili, Weibo, Threads, LinkedIn, Reddit, Kuaishou, WeChat, Lemon8, and Zhihu. The package is published on PyPI as tikhub, distributed under the Apache-2.0 licence, and requires Python 3.9 or newer; the current release is 2.1.1. It exposes both a synchronous client, TikHub, and an asynchronous client, AsyncTikHub, and every endpoint is documented in an OpenAPI spec that is also testable through Swagger UI.

The concrete problem it solves is the cost of building and maintaining separate integrations for each platform. In the Data Extraction & Web Scraping category, teams normally write their own scrapers or private-API clients per platform, then keep them working as those services change. This SDK replaces that per-platform work with one typed client that covers video details, user profiles, comments, search results, live streams, trending content, and e-commerce analytics, so the integration surface stays in one place instead of sixteen.

Key capabilities

  • More than 1,000 endpoints across 16 platforms reachable through a single API key, with resource groups such as tiktok_web, tiktok_app_v3, douyin_web, douyin_search, instagram_v1, youtube_web, twitter_web, xiaohongshu_web, bilibili_web, weibo_web, kuaishou_web, and reddit_app.
  • Full endpoint coverage: 1010 of 1010 endpoints from OpenAPI spec V5.3.2, mechanically generated and verified.
  • Sync and async clients, TikHub and AsyncTikHub, expose identical APIs, so code can move between blocking and asyncio execution.
  • Type-safe output built on httpx and pydantic v2, reported as mypy --strict clean.
  • Production behaviour such as automatic retries with exponential backoff, rate-limit handling, and a structured error hierarchy with full debugging context.
  • Model Context Protocol integration for connecting AI agents such as Claude, LangChain, Coze, and n8n directly to social media data.
  • Access to datasets of more than 1 billion pre-collected, structured records alongside the live endpoints.

Who uses it and how

  • Developers, data scientists, and AI engineers who need structured social media data at scale rather than raw page scrapes.
  • Teams running AI training pipelines, influencer analytics, trend monitoring, sentiment analysis, market research, and competitive intelligence.
  • AI agent builders who wire Claude, LangChain, Coze, or n8n to social data through the MCP integration.
  • Analysts who need several platforms at once and would otherwise maintain separate clients for TikTok, Douyin, Instagram, and other services.

Getting started

Install the package with pip install tikhub on Python 3.9 or newer, obtain an API key from https://user.tikhub.io/login, export it as TIKHUB_API_KEY, and construct a client with TikHub(api_key="YOUR_API_KEY"). Source installs follow the same path via git clone and pip install -e ".[dev]".

How it compares

The only adjacent tool named in the facts is scrapy, which appears in the package topic list, but the two occupy different layers: scrapy is a general crawling framework a team runs itself, whereas this SDK is a typed client for the hosted TikHub REST API. No other comparable Python client for this multi-platform data API is named in the facts, so it stands largely alone in this registry.

When to use it — and when not to

Choosing it means depending on the hosted TikHub service: users need network access to the TikHub API and a valid API key, and the SDK itself does not perform crawling, so anyone who must self-host every data source and avoid a third-party API should look elsewhere. The registry shows one healthy signal in the form of zero open issues, but the README details the client rather than the service behind it, so the licence and pricing of the API itself are not established by these facts. The Apache-2.0 licence covers the SDK code only.

project readme (upstream, from github) — read inline

TikHub API Python SDK

GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests License

English | 中文 | Français | Español | 日本語

The official Python SDK for the TikHub social media data API — a unified REST API that provides real-time access to 16+ social media platforms including TikTok, Douyin, Instagram, YouTube, Twitter/X, Xiaohongshu (Red Note), Bilibili, Weibo, Threads, LinkedIn, Reddit, Kuaishou, WeChat, Lemon8, Zhihu, and more.

Built for developers, data scientists, and AI engineers who need structured social media data at scale — for AI training, influencer analytics, trend monitoring, sentiment analysis, market research, and competitive intelligence.

Why TikHub?

  • 1000+ endpoints across 16 platforms through a single API key
  • Real-time data — video details, user profiles, comments, search results, live streams, trending content, and e-commerce analytics
  • RESTful & OpenAPI-native — every endpoint is documented in the OpenAPI spec and testable via Swagger UI
  • MCP integration — connect AI agents (Claude, LangChain, Coze, n8n) directly to social media data via Model Context Protocol
  • Datasets available — 1B+ pre-collected, structured records for training and research

Why This SDK?

  • 100% endpoint coverage — 1010 / 1010 endpoints from OpenAPI spec V5.3.2, mechanically generated and verified
  • Sync + async — TikHub and AsyncTikHub clients with identical APIs
  • Production-ready — automatic retries with exponential backoff, rate-limit handling, structured error hierarchy with full debugging context
  • Type-safe — mypy --strict clean, built on httpx + pydantic v2
  • Zero config — flat kwargs, no config objects; set one env var and go

Version: 2.1.1 — Requires Python 3.9+

Supported Platforms

Platform Resource Endpoints
TikTok tiktok_web, tiktok_app_v3, tiktok_creator, tiktok_analytics, tiktok_ads, tiktok_shop_web 200+
Douyin douyin_web, douyin_app_v3, douyin_search, douyin_billboard, douyin_creator, douyin_xingtu 400+
Instagram instagram_v1, instagram_v2, instagram_v3 80+
YouTube youtube_web, youtube_web_v2 50+
Twitter / X twitter_web 13+
Xiaohongshu (Red Note) xiaohongshu_web, xiaohongshu_app (+ v2/v3 variants) 80+
Bilibili bilibili_web, bilibili_app 40+
Weibo weibo_web, weibo_web_v2, weibo_app 30+
Threads threads_web 10+
LinkedIn linkedin_web 10+
Reddit reddit_app 10+
Kuaishou kuaishou_web, kuaishou_app 20+
WeChat wechat_channels, wechat_media_platform_web 20+
Lemon8 lemon8_app 10+
Zhihu zhihu_web 30+
Others toutiao_web, toutiao_app, xigua_app_v2, pipixia_app, sora2 30+

Install

pip install tikhub

Requires Python 3.9+.

From source

git clone https://github.com/TikHub/TikHub-API-Python-SDK.git
cd TikHub-API-Python-SDK
pip install -e ".[dev]"
pytest -q

Get your API Key

  1. Go to https://user.tikhub.io/login and sign up / log in.
  2. Copy your API key from the dashboard.
  3. Set it as an environment variable or pass it directly:
export TIKHUB_API_KEY="YOUR_API_KEY"

Quickstart

from tikhub import TikHub

client = TikHub(api_key="YOUR_API_KEY")

# 1:1 with the OpenAPI spec — resource = tag, method = path basename
video = client.douyin_web.fetch_one_video(aweme_id="7251234567890123456")
print(video.aweme_detail.desc)

client.close()

Or with the recommended context manager:

with TikHub(api_key="YOUR_API_KEY") as client:
    health = client.health_check.check()
    print(health.status)

Async

import asyncio
from tikhub import AsyncTikHub

async def main():
    async with AsyncTikHub(api_key="YOUR_API_KEY") as client:
        video = await client.douyin_web.fetch_one_video(aweme_id="...")
        print(video.aweme_detail.desc)

asyncio.run(main())

Configuration

The constructor takes one required argument and a small handful of optional kwargs:

TikHub(
    api_key=None,        # str | None — defaults to $TIKHUB_API_KEY
    timeout=30,          # float | None — total request timeout in seconds
    base_url=None,       # str | None — only override for a private mirror

    # Advanced (rare):
    max_retries=3,
    proxy=None,
    user_agent=None,
    parse_response=True,
    http_client=None,    # bring your own httpx.Client
)

That's the entire configuration surface. There is no ClientConfig object — knobs are flat kwargs.

Naming rules

The SDK is mechanically derived from the TikHub OpenAPI spec. Two rules:

  1. Resource attribute = OpenAPI tag, lowercased, dashes → underscores, -API stripped. Douyin-Web-API → client.douyin_web. TikTok-App-V3-API → client.tiktok_app_v3.
  2. Method name = the last segment of the API path, verbatim. /api/v1/douyin/web/fetch_one_video → client.douyin_web.fetch_one_video(...).

Parameter names match the OpenAPI spec verbatim. If you can read the TikHub API docs, you already know how to use the SDK.

Status

100% endpoint coverage against TikHub OpenAPI spec V5.3.2.

Resources 52 (one per OpenAPI tag)
Endpoints 1010 / 1010
Tests 110 passing
Type-check mypy --strict clean across 71 source files
Lint ruff clean
Phase Scope State
0 Foundation: client, transport, errors, retries, pagination ✅ done
1 Codegen pipeline (scripts/refresh_spec.py, generate_resources.py, verify_coverage.py) ✅ done
2 Douyin + TikTok core (412 endpoints) ✅ done
3 Other Chinese platforms (302 endpoints) ✅ done
4 International platforms (234 endpoints) ✅ done
5 TikTok specialty + utilities (94 endpoints) ✅ done
6 Docs site, CLI, migration guide, release workflow ✅ done

The resource layer is mechanically generated from spec/openapi.json. To refresh after a TikHub spec update:

python scripts/refresh_spec.py        # pulls latest openapi.json, prints diff
python scripts/generate_resources.py  # regenerates all 52 resource files + clients
python scripts/generate_docs.py       # regenerates docs/reference.md
python scripts/verify_coverage.py     # asserts 100% coverage
pytest -q                             # 110 tests

CLI

A small console wrapper ships in the cli extra:

pip install "tikhub[cli]"
export TIKHUB_API_KEY="YOUR_API_KEY"

tikhub health                                 # ping the API
tikhub fetch https://v.douyin.com/abc/        # universal video URL parser
tikhub user info                              # plan + quota
tikhub user usage                             # today's request count

Every command prints JSON to stdout — pipe to jq or any other formatter.

Documentation

Full docs (mkdocs-material): authentication, async, errors, pagination, retries, logging, CLI, migration guide, naming rules, and the auto-generated reference for all 1010 endpoints.

pip install -e ".[docs]"
mkdocs serve            # http://127.0.0.1:8000

License

MIT.

Frequently asked questions

Is TikHub-API-Python-SDK free to use?

TikHub-API-Python-SDK is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does TikHub-API-Python-SDK do?

High-performance asynchronous Douyin(抖音) TikTok Xiaohongshu(小红书) Kuaishou(快手) Weibo(微博) Instagram YouTube(油管) Twitter(X) Captcha Solver(验证码解决器) Temp Mail(临时邮箱)

What is TikHub-API-Python-SDK written in?

TikHub-API-Python-SDK is primarily written in Python. Its source is publicly available at https://github.com/TikHub/TikHub-API-Python-SDK, and it has 934 GitHub stars.