tiktokapi

The Unofficial TikTok API Wrapper In Python

https://github.com/davidteather/tiktok-api

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary

Keywords

api download-tiktoks hacktoberfest python tik tiktok tiktok-api tiktok-automation tiktok-compilations tiktok-downloader tiktok-python tiktok-scraper tiktok-signature tiktok-trending-page tiktokapi tok trending
Last synced: 6 months ago · JSON representation ·

Repository

The Unofficial TikTok API Wrapper In Python

Basic Info
Statistics
  • Stars: 5,678
  • Watchers: 84
  • Forks: 1,088
  • Open Issues: 128
  • Releases: 121
Topics
api download-tiktoks hacktoberfest python tik tiktok tiktok-api tiktok-automation tiktok-compilations tiktok-downloader tiktok-python tiktok-scraper tiktok-signature tiktok-trending-page tiktokapi tok trending
Created over 6 years ago · Last pushed 10 months ago
Metadata Files
Readme Funding License Citation

README.md

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.

DOI LinkedIn Sponsor Me GitHub release (latest by date) GitHub Downloads Support Server

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.

TikApi
TikAPI is a paid TikTok API service providing a full out-of-the-box solution, making life easier for developers — trusted by 500+ companies.

Ensemble Data
EnsembleData is the leading API provider for scraping Tiktok, Instagram, Youtube, and more.
Trusted by the major influencer marketing and social media listening platforms.

TikTok Captcha Solver
TikTok Captcha Solver: Bypass any TikTok captcha in just two lines of code.
Scale your TikTok automation and get unblocked with SadCaptcha.

TikTok Captcha Solver
Cheap, Reliable Proxies: Supercharge your web scraping with fast, reliable proxies. Try 10 free datacenter proxies today!

Table of Contents

Upgrading from V5 to V6

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.

sh 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.

sh 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 successfuly 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.
  • 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

```py from TikTokApi import TikTokApi import asyncio import os

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

async def trendingvideos(): async with TikTokApi() as api: await api.createsessions(mstokens=[mstoken], numsessions=1, sleepafter=3, browser=os.getenv("TIKTOKBROWSER", "chromium")) async for video in api.trending.videos(count=30): print(video) print(video.asdict)

if name == "main": asyncio.run(trending_videos()) ```

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

sh 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.

Owner

  • Name: David Teather
  • Login: davidteather
  • Kind: user
  • Location: Chicago, IL
  • Company: @CrowdStrike

I like open source projects and making educational content | SWE @CrowdStrike

Citation (CITATION.cff)

cff-version: 1.2.0
authors:
  - family-names: "Teather"
    given-names: "David"
    orcid: "https://orcid.org/0000-0002-9467-4676"
title: "TikTokAPI"
url: "https://github.com/davidteather/tiktok-api"
version: 7.1.0
date-released: 2025-04-13

GitHub Events

Total
  • Create event: 5
  • Commit comment event: 1
  • Release event: 2
  • Issues event: 31
  • Watch event: 828
  • Delete event: 3
  • Issue comment event: 67
  • Push event: 19
  • Pull request review comment event: 7
  • Pull request review event: 8
  • Pull request event: 26
  • Fork event: 141
Last Year
  • Create event: 5
  • Commit comment event: 1
  • Release event: 2
  • Issues event: 31
  • Watch event: 828
  • Delete event: 3
  • Issue comment event: 67
  • Push event: 19
  • Pull request review comment event: 7
  • Pull request review event: 8
  • Pull request event: 26
  • Fork event: 141

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 559
  • Total Committers: 32
  • Avg Commits per committer: 17.469
  • Development Distribution Score (DDS): 0.567
Top Committers
Name Email Commits
David Teather 3****r@u****m 242
davidteather d****r@u****m 216
Michael D. Hoyle h****d@g****m 21
Vincent Demay v****t@d****t 17
Thomas Zronek t****s@z****t 12
shiqwang s****g@g****m 7
Ben West X****p@u****m 5
Reza Arifandie r****e@g****m 4
Michelle Bao m****o@M****l 4
Brian Schroeder b****n@a****m 3
Daniel Nash d****7@g****m 3
Óli Tómas o****s@o****m 2
AR a****a@h****t 2
Vladimir e****n@g****m 2
Isaac K 6****n@u****m 2
Coloradohusky 4****y@u****m 1
Abhijith NT a****4@g****m 1
J du Preez d****n@z****m 1
Dylan Caponi d****b@g****m 1
Michael Salaverry b****a@g****m 1
MStudioBuildInc 4****c@u****m 1
Josh Braden j****n@g****m 1
Sid Shardanand 5****y@u****m 1
Sam Hartmann 4****y@u****m 1
ctaity c****y@g****m 1
zoopzorp 2****p@u****m 1
dereklowlind d****d@g****m 1
dependabot-preview[bot] 2****]@u****m 1
Yoav Zimmerman y****n@g****m 1
dj2ball 3****l@u****m 1
and 2 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 267
  • Total pull requests: 76
  • Average time to close issues: 8 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 242
  • Total pull request authors: 40
  • Average comments per issue: 4.92
  • Average comments per pull request: 0.97
  • Merged pull requests: 57
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 33
  • Pull requests: 32
  • Average time to close issues: 2 days
  • Average time to close pull requests: about 2 months
  • Issue authors: 30
  • Pull request authors: 14
  • Average comments per issue: 0.36
  • Average comments per pull request: 0.59
  • Merged pull requests: 22
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • upintheairsheep (4)
  • lazezo2 (3)
  • nedoai (3)
  • lirankor (2)
  • Tsuyoshisaito601 (2)
  • ghost (2)
  • tlament (2)
  • M-Minkov (2)
  • barripdmx (2)
  • zakrian07 (2)
  • Incher25 (2)
  • davidteather (2)
  • Popesites (2)
  • AbubakrChan (2)
  • leegunwoo98 (2)
Pull Request Authors
  • davidteather (14)
  • gbiz123 (6)
  • bendavidsteel (5)
  • leegunwoo98 (5)
  • dronavallipranav (5)
  • trislee (4)
  • arhen (4)
  • ekorian (4)
  • joaovvbp (2)
  • oxue (2)
  • bgb10 (2)
  • stephenarosaj (2)
  • koki-ota0 (2)
  • Ben3056 (2)
  • lhphat02 (2)
Top Labels
Issue Labels
bug (164) feature_request (49) installation_help (25) stale (2) help wanted (1) good first issue (1) priority (1) discussion (1) information collecting (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 101,664 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 6
    (may contain duplicates)
  • Total versions: 127
  • Total maintainers: 2
pypi.org: tiktokapi

The Unofficial TikTok API Wrapper in Python 3.

  • Versions: 125
  • Dependent Packages: 0
  • Dependent Repositories: 5
  • Downloads: 101,644 Last month
Rankings
Stargazers count: 1.2%
Forks count: 1.3%
Downloads: 2.2%
Average: 4.3%
Dependent repos count: 6.6%
Dependent packages count: 10.1%
Maintainers (1)
Last synced: 6 months ago
pypi.org: tiktokapi-pyppeteer

The Unofficial TikTok API Wrapper But Pyppeteer in Python 3.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 11 Last month
Rankings
Stargazers count: 1.3%
Forks count: 1.3%
Dependent packages count: 10.0%
Average: 13.5%
Dependent repos count: 21.7%
Downloads: 33.3%
Maintainers (1)
Last synced: 6 months ago
pypi.org: tiktokapisix

The Unofficial TikTok API Wrapper in Python 3.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 9 Last month
Rankings
Dependent packages count: 9.4%
Average: 31.2%
Dependent repos count: 53.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • playwright *
  • requests *
  • selenium *
  • selenium_stealth *
setup.py pypi
  • requests *
.github/workflows/package-test.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • microsoft/playwright-github-action v1 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
Dockerfile docker
  • mcr.microsoft.com/playwright focal build