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.
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
- Python 3.7 - The web framework used
Authors
- David Teather - Initial work - davidteather
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
File details
Details for the file TikTokApi-2.1.4.2.tar.gz
.
File metadata
- Download URL: TikTokApi-2.1.4.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bbce3f9cf11bbf3c76fd728338171b4f19ed6515f212f56fd5057f1e32c55d5 |
|
MD5 | 5e8ce2c131f4d01d1f0a14b1164c1df5 |
|
BLAKE2b-256 | 864e50e38275a0cc6a333f53eb86be17e686c48af3a1838d192d894c4e28762f |