Skip to main content

Unofficial TikTok API wrapper in Python

Project description

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)

Get Trending Videos

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

Project details


Download files

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

Source Distribution

PyTikTokAPI-0.0.5.tar.gz (57.9 kB view details)

Uploaded Source

File details

Details for the file PyTikTokAPI-0.0.5.tar.gz.

File metadata

  • Download URL: PyTikTokAPI-0.0.5.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for PyTikTokAPI-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a98c6f724d71b28a8fc3a9b43f8e5b7eca253ef5cde153384e88c33152a44287
MD5 160fb8d3e45163bb8527e3bcfc2a346d
BLAKE2b-256 8d050a7c367dc9ac0eb5c2f0d1f1c53f12c9081069df3b46e8144b1ea8eadf88

See more details on using hashes here.

Supported by

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