Skip to content

cryptosbyte/PyTokAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTokAPI Module

This is a Python module that uses the requests package to send a request to TikTok's API, which returns the data from the API.

Download with Pip3:

$ pip3 install pytokapi 

Example:

import pytokapi

response = pytokapi.TikTok().getInfo(
  "https://www.tiktok.com/@..................../video/.........................."
)

print(info['version'])
# Should print TikTok's API version

When the .getInfo() function is called, it takes only 1 string parameter, which is the TikTok video's URL. Once that function is runned, it should return a JSON response which looks like the following.

Side Note: If the string is not given in the function's parameter, Python3 will automatically give an error. Additionally if the video URL is invalid, the system will throw an error as well (from the code).

// "req" is a variable (which is the request of the API) that is equal to a JSON response.
const req = [...] 
{
  "version": req["version"],
  "title": req["title"],
  "author": {
    "url": req["author_url"],
    "name": req["author_name"],
  },
  "provider": {
    "url": "https://www.tiktok.com",
    "name": "TikTok",
  },
  "video": {
    "html": {
      "embed": req["html"],
      "width": req["width"],
      "height": req["height"],
    },
    "height": req["thumbnail_height"],
    "url": req["thumbnail_url"],
    "width": req["thumbnail_width"],
  }