项目作者: cryptosbyte

项目描述 :
TikTok API Video Wrapper
高级语言: Python
项目地址: git://github.com/cryptosbyte/PyTokAPI.git
创建时间: 2021-05-02T00:52:49Z
项目社区:https://github.com/cryptosbyte/PyTokAPI

开源协议:MIT License

下载


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:

  1. $ pip3 install pytokapi

Example:

  1. import pytokapi
  2. response = pytokapi.TikTok().getInfo(
  3. "https://www.tiktok.com/@..................../video/.........................."
  4. )
  5. print(info['version'])
  6. # 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).

  1. // "req" is a variable (which is the request of the API) that is equal to a JSON response.
  2. const req = [...]
  3. {
  4. "version": req["version"],
  5. "title": req["title"],
  6. "author": {
  7. "url": req["author_url"],
  8. "name": req["author_name"],
  9. },
  10. "provider": {
  11. "url": "https://www.tiktok.com",
  12. "name": "TikTok",
  13. },
  14. "video": {
  15. "html": {
  16. "embed": req["html"],
  17. "width": req["width"],
  18. "height": req["height"],
  19. },
  20. "height": req["thumbnail_height"],
  21. "url": req["thumbnail_url"],
  22. "width": req["thumbnail_width"],
  23. }