Skip to main content

The Unoffical TikTok API Wrapper in Python 3.

Project description

Unoffical TikTok API in Python

This is an unoffical api wrapper for tiktok.com in python. With this api you are able to call most trending and fetch specific user information.

GitHub release (latest by date) Build Status GitHub PyPI - Downloads

Important Information

  • If this API stops working for any reason open an issue.
  • Feel free to mention @davidteather in an issue you open, because I might not see it otherwise.

Getting Started

To get started using this api follow the instructions below.

It is quite a long installation process just for a TikTok api, the first release can be found here and is not as suitable for long term projects, however it may be easier for a day of scraping TikTok, as the installation is much easier.

Despite this, I still recommend you follow this process and use the latest version.

Installing

If you need help installing or run into some error, please open an issue. I will try to help out as much as I can.

Tested with python 3.7.3

pip install TikTokApi

Or install directly from this GitHub repo.

  • You do need to have java installed
  • Download browsermob-proxy here
  • You must add browsermob-proxy/bin to your environment path.
  • Firefox must be installed.
  • You must download the latest geckodriver from mozilla, and include the .exe in your path.

Quick Start Guide

Here's a quick bit of code to get the most recent trending on TikTok

from tiktok import TikTokapi

api = TikTokapi(path_to_browsermob_directory)
# path_to_browsermob_directory - String - should be the path from the directory you are running from the code to the extracted zip file of [browsermob-proxy](https://bmp.lightbody.net/)
# Will Get the 10 most recent trending on the tiktok trending page
api.trending(10)

Detailed Documentation

The TikTok class
# Variable set like
api = TikTokapi(path_to_browsermob_directory, headless=False)

path_to_browsermob_directory - String - should be the path from the directory you are running from the code to the extracted zip file of browsermob-proxy headless - True/False - True means it will run a headless firefox browser, could be detected by TikTok, however it is more convienent. Default = False.

The Trending Method
# Where count is how many result you want
# Verbose is optional, default=0. Set it to 1 to get more information
api.trending(count, verbose)

Trending returns an array of json objects. Example structure here JSON object tree here

The userPosts Method
# Where count is how many results you want
# Verbose is optional, default=0. Set it to 1 to get more information
# userid is the tiktok userid, can be found through response json tree or in the tiktok url
api.userPosts(userid, count, verbose)

Since this isn't an offical TikTok API the TikTok servers don't know what to do. This method specifically will throw a lot of errors if you have verbose on. It takes a lot longer than trending, however it will still end up working. Just give it a few minutes.

Trending returns an array of json objects. Example structure here It has the same JSON object tree as trending. It's here anyways.

Built With

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TikTokApi-2.1.4.2.tar.gz (4.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page