2025 · Solo · Open source
TikTok API
A production-ready FastAPI wrapper around the unofficial TikTok library: API-key auth, per-endpoint rate limits, token rotation.
Architecture
Mission
The unofficial TikTok library works until you try to run it as a service: sessions expire, endpoints throttle, and nobody wants to babysit it. This wraps trending, users, videos, hashtags, search, and sounds behind a FastAPI service that behaves like an API you could bill for.
For whom: people building on TikTok data without an official partner key. Constraints: API-key auth, per-endpoint rate limiting, automatic token rotation with health monitoring, and short-link resolution.
Manifest
| Layer | Choice | Version | Why |
|---|---|---|---|
| services | FastAPI | — | Typed models, async handlers, OpenAPI docs. |
| agents | Playwright | — | Drives the sessions the unofficial library needs. |
| data | Redis | — | Rate-limit budgets and response caching. |
| infra | Docker + nginx | — | One compose file to run it anywhere. |
Decisions
FastAPI over Flask. Typed request models and OpenAPI for free.
Playwright-backed sessions with rotation. A pool of tokens, each health-checked, rotated before it dies rather than after.
Redis for rate limits and caches. Per-endpoint budgets, so a hashtag crawl cannot starve search.
nginx in front, Docker around it. Deployable in one compose file.
Impact
- Docker Hub pulls
- 635
- Endpoints
- 6 groups
- Commits
- 11
635 image pulls on Docker Hub from an 11-commit project. Enough people had the same problem.
What broke
Nothing reported yet, which for an unofficial wrapper means it has not been running long enough. The first thing I would fix: token health is checked on a timer, so a token that dies between checks still serves a few failed requests before rotation kicks in. Rotating on the first upstream failure is the next change.
Ship log
- First commit
- Image published to Docker Hub
- Now: 635 pulls