Skip to main content

Unofficial TikTok API Wrapper in Python

This is an unofficial TikTok Api python wrapper. I have an App using this API, and thus will constantly keep updating this wrapper
This implementation is inspired by TikTokApi, but runs faster.

Table of Contents

Getting Started

To get started using this API, follow the instructions below.

Installing

Pip

pip install PyTikTokAPI

Install from source

git clone https://github.com/avilash/TikTokAPI-Python.git
python setup.py install

Quick Start Guide

Import

from TikTokAPI import TikTokAPI

Get your keys from Cookie. You can get them from the Applications tab in Chrome developer console.
By default it used hardcoded values which may not work after some time.
The keys to extract are s_v_web_id and tt_webid

cookie = {
  "s_v_web_id": "<your_key>",
  "tt_webid": "<your_key>"
}

Get the most trending Videos on TikTok

api = TikTokAPI(cookie=cookie)
retval = api.getTrending(count=5)

Get a user by name

api = TikTokAPI(cookie=cookie)
user_obj = api.getUserByName("fcbarcelona")

Get videos of a user

api = TikTokAPI(cookie=cookie)
user_videos = api.getVideosByUserName("fcbarcelona")

Get likes of a user

api = TikTokAPI(cookie=cookie)
user_videos = api.getLikesByUserName("fcbarcelona")

Detailed Documentation

This section contains details about the parameters of each function and what it returns

Methods

Tiktok Class

Inputs

  • language - Self explanatory
  • region - Self explanatory
  • cookie - The TikTok Cookie containing the parameter s_v_web_id. If not provided, the parameter will be generated.
__init__(self, language='en', region='IN', cookie=None)

Inputs

  • count - Number of videos to fetch
getTrending(self, count=30)

Get User

Inputs

  • user_name - Username, eg - fcbarcelona
getUserByName(self, user_name)

Get Videos By Username

Inputs

  • user_name - Username, eg - fcbarcelona
  • count - Number of videos to fetch
getVideosByUserName(self, user_name, count=30)

Get Likes By Username

Inputs

  • user_name - Username, eg - fcbarcelona
  • count - Number of videos to fetch
getLikesByUserName(self, user_name, count=30)

Get Hashtag

Inputs

  • hashTag - HashTag, eg - #fcbarcelona
getHashTag(self, hashTag)

Get Videos By Hashtag

Inputs

  • hashTag - HashTag, eg - #fcbarcelona
  • count - Number of videos to fetch
getVideosByHashTag(self, hashTag, count=30)

Get Music

Inputs

  • music_id - Music Id, eg - 6704854531001289474
getMusic(self, music_id)

Get Videos By Music

Inputs

  • music_id - Music Id, eg - 6704854531001289474
  • count - Number of videos to fetch
getVideosByMusic(self, music_id, count=30)

Get Video By Id

Inputs

  • video_id - Video Id, eg - 6843481669886954757
getVideoById(self, video_id)

Download Video

Inputs

  • video_id - Video Id, eg - 6843481669886954757
  • save_path - Path where the downloaded video should be saved
downloadVideoById(self, video_id, save_path)

Download Video No Watermark

Inputs

  • video_id - Video Id, eg - 6843481669886954757
  • save_path - Path where the downloaded video should be saved
downloadVideoByIdNoWatermark(self, video_id, save_path)

Built With

Authors

License

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

Run on Repl.it

Metadata

Release files for PTTAPI 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PTTAPI 0.0.5
File Size Uploaded Provenance Actions
PTTAPI-0.0.5.tar.gz 58.1 kB Without provenance Details for PTTAPI-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PTTAPI 0.0.5
File Interpreter ABI Platform Actions
PTTAPI-0.0.5-py3-none-any.whl Python 3 none any Details for PTTAPI-0.0.5-py3-none-any.whl

Total release size: 115.4 kB

Release files / PTTAPI-0.0.5.tar.gz

Download URL PTTAPI-0.0.5.tar.gz
Size 58.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7491ad2027684ceb8141ce3b3a1e712a010aa9ceb04ed5e26ff131535740acc1
BLAKE2b-256 checksum
How to use checksums
2d6f05d48e6457b61cf9dfee33c9c5fdf66f6377191ec91fa3649590ffce5323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / PTTAPI-0.0.5-py3-none-any.whl

Download URL PTTAPI-0.0.5-py3-none-any.whl
Size 57.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3743e9a9271cf92e1304869b0d8d4b8e643ba79f2d3cfcee91d4a7cc2509bb7c
BLAKE2b-256 checksum
How to use checksums
46acc6ca19425b5cac27396fee8aa58ebbc6b26970f9a71d563b43383bc2b49c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for PTTAPI 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page