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) Build Status GitHub Downloads  Support Server

Getting Started

To get started using this api follow the instructions below.

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

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.

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.

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.

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

Please don’t open an issue if you’re experiencing one of these just comment if the provided solution do not work for you.

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

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.

from TikTokApi import TikTokApi

# Watch https://www.youtube.com/watch?v=-uCt1x8kINQ for a brief setup tutorial
with TikTokApi() as api:
    for trending_video in api.trending.videos(count=50):
        # Prints the author's username of the trending video.
        print(trending_video.author.username)

Note: Jupyter (ipynb) only works on linux, see microsoft/playwright-python #178

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

python -m examples.get_trending

You can access the dictionary type of an object using .as_dict. On a video this may look like this, although TikTok changes their structure from time to time so it’s worth investigating the structure of the dictionary when you use this package.

Upgrading from V4 to V5

All changes will be noted on #803 if you want more information.

Motivation

This package has been difficult to maintain due to it’s structure, difficult to work with since the user of the package must write parsing methods to extract information from dictionaries, more memory intensive than it needs to be (although this can be further improved), and in general just difficult to work with for new users.

As a result, I’ve decided to at least attempt to remedy some of these issues, the biggest changes are that

  1. The package has shifted to using classes for different TikTok objects resulting in an easier, higher-level programming experience.
  2. All methods that used to return a list of objects have been switched to using iterators, to hopefully decrease memory utilization for most users.

Upgrading Examples

Accessing Dictionary on Objects (similar to V4)

You’ll probably need to use this beyond just for legacy support, since not all attributes are parsed out and attached to the different objects.

You may want to use this as a workaround for legacy applications while you upgrade the rest of the app. I’d suggest that you do eventually upgrade to using the higher-level approach fully.

user = api.user(username='therock')
user.as_dict # -> dict of the user_object
for video in user.videos():
    video.as_dict # -> dict of TikTok's video object as found when requesting the videos endpoint

Here’s a few more examples that help illustrate the differences in the flow of the usage of the package with V5.

# V4
api = TikTokApi.get_instance()
trending_videos = api.by_trending()

#V5.1
with TikTokApi() as api: # .get_instance no longer exists
    for trending_video in api.trending.videos():
        # do something

Where in V4 you had to extract information yourself, the package now handles that for you. So it’s much easier to do chained related function calls.

# V4
trending_videos = api.by_trending()
for video in trending_videos:
    # The dictionary responses are also different depending on what endpoint you got them from
    # So, it's usually more painful than this to deal with
    trending_user = api.get_user(id=video['author']['id'], secUid=video['author']['secUid'])


# V5
# This is more complicated than above, but it illustrates the simplified approach
for trending_video in api.trending.videos():
    user_stats = trending_video.author.info_full['stats']
    if user_stats['followerCount'] >= 10000:
        # maybe save the user in a database

Subscribe to our channel and do not miss new collections of tools in various areas of Information Security.

  Posted by: @ESPYER

Facebook
Twitter
LinkedIn

The Thrilling Adventure of Digital Sleuthing with IRBIS

In the rapidly expanding digital world, IRBIS stands out as a revolutionary online platform for gathering digital intelligence. It offers a host of powerful tools, including deep web searches, facial recognition, and social media analysis, making the process of uncovering hidden insights on the internet simple yet efficient. What sets IRBIS apart is its use of proxy server technology, exemplified by providers like Oxylabs.io. This feature enhances privacy, speed, and access to geo-blocked content, making IRBIS an invaluable tool for both professionals and tech enthusiasts. Using IRBIS is akin to becoming a digital detective, equipped with a cutting-edge toolkit that makes the exploration of the online world an exhilarating experience.

Read More »

Unveiling the Power of Facial Recognition

Discover how the advanced facial recognition technology of Botodetective can revolutionize online investigations. With the ability to search for information about individuals using just their face picture, Botodetective offers a powerful tool for uncovering online presence and conducting thorough investigations. Dive into the world of AI-driven facial recognition and explore how this innovative technology is reshaping the landscape of online investigations. Unleash the potential of Botodetective and unlock a wealth of information with just a simple face picture. Stay ahead of the game and gain valuable insights into individuals’ online activities. Upgrade your investigative capabilities today with Botodetective’s facial recognition feature.

Read More »

Mystic Faces Revealed: Crack the Code of the Unknown with Facial Photo Search

Unleash the Epic Secrets: Master the Art of Discovery with Irbis.espysys.com

Are you curious to delve deeper into the lives of the people you encounter? With Irbis.espysys.com, you have the ultimate tool at your fingertips. This eye-catching article introduces the power of Irbis.espysys.com, an innovative platform that allows you to gather information about others based on phone numbers, names, email addresses, and even photos.

Discover the thrill of uncovering hidden truths about your date or satisfying your curiosity about someone you’ve crossed paths with on the street. Dive into the world of Irbis and witness its advanced facial recognition technology that can identify individuals and provide valuable insights.

Learn how to responsibly navigate this powerful tool and respect the privacy of others as you unlock the secrets that lie beneath the surface. Explore a world of endless possibilities, backed by a secure and encrypted environment.

Join us on this exciting journey and let Irbis.espysys.com become your guide in unraveling the mysteries that surround us. Unleash the epic secrets and master the art of discovery today!

Read More »

The Atypical OSINT Guide

This article explores the OffcierCia non-typical OSINT guide on GitHub, which is a library of materials for learning how to conduct open source intelligence (OSINT) investigations. The guide is intended for bored professionals and provides a wide range of unusual OSINT techniques and tools. The article covers the various sections of the guide, including immersive and gamified learning, training and practicing, external data, and more. It also includes a disclaimer that all information is for educational purposes only and based on public sources. The article aims to inform readers about this valuable resource for improving their OSINT skills.

Read More »

Revolutionize Your Instagram Game with AutoGPT-Social

Introducing AutoGPT-Social, an AI-powered tool designed to revolutionize your Instagram content strategy. By automatically generating eye-catching images, captions, and hashtags, this innovative bot optimizes posting schedules based on real-time feedback to maximize engagement. With customizable post frequency settings and automatic hashtag discovery, AutoGPT-Social simplifies content creation, helping you attract likes and followers with ease. To get started, visit the project’s GitHub page: https://github.com/WillReynolds5/AutoGPT-Social. Please use the bot responsibly and at your own risk.

#AutoGPTSocial #InstagramGrowth #AIContentGenerator #MaximizeEngagement

Read More »
dating

Is Your Date Who They Say They Are?

This article highlights the importance of background checks not just for employers, but for individuals as well. It explains how background checks can be helpful for online dating, childcare, and renting out property. The article also mentions ClearCheck.io, a website that offers background check services with an easy-to-use platform and informative blog. The article emphasizes that conducting a background check can provide peace of mind and help make informed decisions about the people in your life.

Read More »