Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

TikTok-Api

> 编程语言
Open source

The Unofficial TikTok API Wrapper In Python

6.5K stars0 likes3 views
WebsiteGitHub

About

The Unofficial TikTok API Wrapper In Python

Unofficial TikTok API in Python

This is an unofficial api wrapper for TikTok.com in python. With this api you are able to call most trending and fetch specific user information as well as much more.

This api is designed to retrieve data TikTok. It can not be used post or upload content to TikTok on the behalf of a user. It has no support for any user-authenticated routes, if you can't access it while being logged out on their website you can't access it here.

Sponsors

These sponsors have paid to be placed here or are my own affiliate links which I may earn a commission from, and beyond that I do not have any affiliation with them. The TikTokAPI package will always be free and open-source. If you wish to be a sponsor of this project check out my GitHub sponsors page.

</a>
<br>
<a href="https://www.ensembledata.com/?utm_source=github&utm_medium=githubpage&utm_campaign=david_thea_github&utm_id=david_thea_github" target="_blank">
    
    <b></b>
    

</a>
<br>
<a href="https://tikhub.io/?utm_source=github&utm_medium=readme&utm_campaign=tiktok_api&ref=github_davidteather_tiktokapi" target="_blank">
    
    <b></b>
    

</a>
<br>
<a href="https://go.dteather.com/webshare?src=tiktokapi&placement=readme" target="_blank">
    
    <b></b>
    

</a>

Table of Contents

  • Documentation
  • Getting Started
    • How to Support The Project
    • Installing
    • Common Issues
  • Quick Start Guide
    • Examples

Documentation

You can find the full documentation here

Getting Started

To get started using this API follow the instructions below.

Note: If you want to learn how to web scrape websites check my free and open-source course for learning everything web scraping

How to Support The Project

  • Star the repo
  • Consider sponsoring me on GitHub
  • Send me an email or a LinkedIn message telling me what you're using the API for, I really like hearing what people are using it for.
  • Submit PRs for issues :)

Installing

Note: Installation requires python3.9+

If you run into an issue please check the closed issues on the github, although feel free to re-open a new issue if you find an issue that's been closed for a few months. The codebase can and does run into similar issues as it has before, because TikTok changes things up.

bash
pip install TikTokApi
python -m playwright install

If you would prefer a video walk through of setting up this package YouTube video just for that. (is a version out of date, installation is the same though)

If you want a quick video to listen for TikTok Live events in python.

Docker Installation

Clone this repository onto a local machine (or just the Dockerfile since it installs TikTokApi from pip) then run the following commands.

bash
docker pull mcr.microsoft.com/playwright:focal
docker build . -t tiktokapi:latest
docker run -v TikTokApi --rm tiktokapi:latest python3 your_script.py

Note this assumes your script is named your_script.py and lives in the root of this directory.

Common Issues

  • EmptyResponseException - this means TikTok is blocking the request and detects you're a bot. This can be a problem with your setup or the library itself

    • you may need a proxy to successfully scrape TikTok, I've made a web scraping lesson explaining the differences of "tiers" of proxies, I've personally had success with webshare's residential proxies (affiliate link), but you might have success on their free data center IPs or a cheaper competitor.
    • not sure which proxy provider will work for you? This library integrates with my ProxyProviders package, which makes it easy to try out and switch between different proxy providers with a single line via create_sessions(proxy_provider=...). See examples/proxy_provider_example.py for usage.
  • Browser Has no Attribute - make sure you ran python3 -m playwright install, if your error persists try the playwright-python quickstart guide and diagnose issues from there.

  • API methods returning Coroutine - many of the API's methods are async so make sure your program awaits them for proper functionality

Quick Start Guide

Here's a quick bit of code to get the most recent trending videos on TikTok. There's more examples in the examples directory.

Note: If you want to learn how to web scrape websites check my free and open-source course for web scraping

python
from TikTokApi import TikTokApi
import asyncio
import os

ms_token = os.environ.get("ms_token", None) # get your own ms_token from your cookies on tiktok.com

async def trending_videos():
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, browser=os.getenv("TIKTOK_BROWSER", "chromium"))
        async for video in api.trending.videos(count=30):
            print(video)
            print(video.as_dict)

if __name__ == "__main__":
    asyncio.run(trending_videos())

To directly run the example scripts from the repository root, use the -m option on python.

bash
python -m examples.trending_example

You can access the full data dictionary the object was created from with .as_dict. On a video this may look like this. TikTok changes their structure from time to time so it's worth investigating the structure of the dictionary when you use this package.

Issues· 151 open

View all issuesOpen on GitHub
  • #1095

    Proxy not working

    bugUpdated Sep 9, 2026
  • #1159

    [FEATURE_REQUEST] - Function for users - get followers

    feature_requestUpdated Aug 26, 2026
  • #1311

    [BUG] 200 empty body response for user-level queries

    bugUpdated Jul 30, 2026
  • #1303

    Comment stickers: [Sticker] placeholder with no way to retrieve the sticker image URL

    bugUpdated May 25, 2026
  • #1300

    Փաստաբանական գրասենյակ

    bugUpdated May 18, 2026
  • #1157

    [QUESTION] - Can I get Tiktok video download url using TikTok-Api?

    feature_requestUpdated May 14, 2026
  • #1299

    laju.molla

    bugUpdated May 9, 2026
  • #1298

    [FEATURE_REQUEST] - What you want heremikeejeh

    feature_requestUpdated May 9, 2026
  • #1297

    [BUG] - Your Error Here

    bugUpdated May 8, 2026
  • #1290

    [BUG] - /api/user/detail

    bugUpdated Mar 31, 2026

> Tags

Pythonapidownload-tiktokshacktoberfestpython

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 24, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言