Skip to content

High-performance asynchronous Douyin and TikTok unofficial API based on TikHub API.

License

Notifications You must be signed in to change notification settings

bowerliu/Douyin-TikTok-API-Python-SDK

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

待更新 - 2023年4月27日

简介

TikHub是抖音与TikTok非官方的RESTful API平台。

我们提供的API只能获取公开数据,即任何人都可以通过浏览器及APP等访问抖音或TikTok以获取它们。

如果您有任何建议或者需求,请联系我们,更多的功能正在开发中,敬请期待!


鉴权

接口文档中带有🔒的接口需要在请求头中携带Token才可调用。

调用这些接口会使用你账户中的剩余请求次数!

from tikhub.__main__ import *

# 初始化(Initialization)
api = API(
    email='[email protected]',
    password='PASSWORD',
    proxy=None,
)

购买

Website(🚧ing): https://tikhub.io

Discord(💳buy): https://discord.gg/KnWCrgCERq

Github: https://github.com/TikHubIO

Email: [email protected]

WeChat/微信: Evil-Bot


公告

TikHub的API将使用免费加付费的形式运行。

登录后,通过点击以下链接可以免费试用7天,包含2000次API请求,只限新用户。

https://api.tikhub.io/promotion/claim?promotion_id=1

登录后,通过点击以下链接进行签到可以随机获得50-100次API请求,每24小时可签到一次。

https://api.tikhub.io/promotion/daily_check_in

使用示例

查看test.py

  • Install
pip install tikhub
  • Usage
from tikhub.__main__ import *


async def async_test() -> None:
    # 异步测试/Async test

    tiktok_url = 'https://www.tiktok.com/@evil0ctal/video/7156033831819037994'

    tiktok_music_url = 'https://www.tiktok.com/music/original-sound-7128362040359488261'

    douyin_url = 'https://www.douyin.com/video/7153585499477757192'

    douyin_user_url = 'https://www.douyin.com/user/MS4wLjABAAAAaNJuvXC83kL5nhaZHubKdjsRJQovgz58wXzlLnJUsslG-Kb24TM1QJlf_2HMaUJk'

    print("Test start...\n")
    start_time = time.time()

    # 获取TikHub请求头/Get TikHub request header
    r = await api.user_login()
    print("Running test : API.user_login()")
    print(r)

    # 获取TikHub用户信息/Get TikHub user information
    print("Running test : API.get_user_info()")
    r = await api.get_user_info()
    print(r)

    print("\nRunning ALL TikTok methods test...\n")

    # 获取单个视频数据/Get single video data
    print("Running test : API.get_tiktok_video_data()")
    r = await api.get_tiktok_video_data(tiktok_url)
    # print(r)

    # 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
    print("Running test : API.get_tiktok_profile_videos()")
    r = await api.get_tiktok_profile_videos(tiktok_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} videos from profile')

    # 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
    print("Running test : API.get_tiktok_profile_liked_videos()")
    r = await api.get_tiktok_profile_liked_videos(tiktok_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} liked videos from profile')

    # 获取TikTok视频的所有评论数据/Get all comment data of TikTok video
    print("Running test : API.get_tiktok_video_comments()")
    r = await api.get_tiktok_video_comments(tiktok_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} comments from video')

    # 获取音乐页面上的所有(理论上能抓取到的)视频数据/Get all (theoretically) video data on the music page
    print("Running test : API.get_tiktok_music_videos()")
    r = await api.get_tiktok_music_videos(tiktok_music_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} videos from music')

    print("\nRunning ALL Douyin methods test...\n")

    # 获取单个视频数据/Get single video data
    print("Running test : API.get_douyin_video_data()")
    r = await api.get_douyin_video_data(douyin_url)

    # 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
    print("Running test : API.get_douyin_profile_videos()")
    r = await api.get_douyin_profile_videos(douyin_user_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} videos from profile')

    # 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
    print("Running test : API.get_douyin_profile_liked_videos()")
    r = await api.get_douyin_profile_liked_videos(douyin_user_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} liked videos from profile')

    # 获取抖音视频的所有评论数据/Get all comment data of Douyin video
    print("Running test : API.get_douyin_video_comments()")
    r = await api.get_douyin_video_comments(douyin_url, cursor=None, count=None, get_all=False)
    print(f'Get {len(r)} comments from video')

    # 总耗时/Total time
    total_time = round(time.time() - start_time, 2)
    print("\nTest completed, total time: {}s".format(total_time))


if __name__ == '__main__':
    api = API(
        email='[email protected]',
        password='PASSWORD',
        proxy=None,
    )
    asyncio.run(async_test())

About

High-performance asynchronous Douyin and TikTok unofficial API based on TikHub API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%