A Python library for interacting with tiktok's metadata and downloading video's.
Project description
tiktok
A python library that uses requests to fetch data from tiktok videos, it works by sending requests to tiktok walking down it's internal paths, and returns json data!
It can also download tiktok videos, by using the download_video() function. it works by using data from get_metadata()function, which returns the data walked from tiktok's video metadata, which also contains video data. It sends a request to the cdn url!
The library bypasses bot protection by using an (ai-generated) user-agent that succesfully bypasses CDN using requests.session.get().
Usage:
It is easy to use the library by importing the TikTok class. Or, if you want control over everything, you can use the internal functions, since the TikTok class is just a wrapper around said internal functions.
to use internal functions:
from tiktok.fetcher import ttAPIFetcher
from tiktok.parser import ttAPIParser
parser = ttAPIParser()
fetcher = ttAPIFetcher()
unparsed = fetcher.get_metadata(url) # returns r.text
parsed = parser.parse(unparsed) # uses beautifulsoup to search for the metadata.
# returns the walked directory so you can just do:
title = parsed["title"]
author_nickname = parsed["author"]["nickname"]
print(title)
print(author_nickname)
# Download a video:
fetcher.download_video(data=parsed, output_file="name.mp4")
Use TikTok class:
from tiktok import TikTok
tt = TikTok()
data = tt.get_metadata(url) # does parsing for you and returns parsed data!
title = data["desc"]
author_nickname = data["author"]["nickname"]
# download a video:
tt.download_video(url, output_file="name.mp4") # defaults to "downloaded.mp4". Handles data extraction internally.
Installation:
pip install tiktok-sdk
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiktok_sdk-0.1.0.tar.gz.
File metadata
- Download URL: tiktok_sdk-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0006f251b6ba57886df637f61994757f7de6b1d24a4d0262646d5b9367e9aafd
|
|
| MD5 |
eef8184129ce9961e8769f6c723c0617
|
|
| BLAKE2b-256 |
e09bcc5d5c73ddf68f5aeacc40f1d9ddbeb9bb3207d7ec1115b86970f83fc9bb
|
File details
Details for the file tiktok_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tiktok_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da9e47c3ab95720603bd885a09ef05656fd7c78d73f1b6ab2e8381bf6aad0c26
|
|
| MD5 |
4c99843ccf4c401f4b4246a793740a5d
|
|
| BLAKE2b-256 |
797442d54828f4d2eee6c94e120264c5b2abbc71786506463fc478d73d1c26bc
|