Package: tikhub
待更新 - 2023年4月27日TikHub_APIEnglish|简体中文简介TikHub是抖音与TikTok非官方的RESTful API平台。我们提供的API只能获取公开数据，即任何人都可以通过浏览器及APP等访问抖音或TikTok以获取它们。如果您有任何建议或者需求，请联系我们，更多的功能正在开发中，敬请期待！鉴权接口文档中带有🔒的接口需要在请求头中携带Token才可调用。调用这些接口会使用你账户中的剩余请求次数！fromtikhub.__main__import*# 初始化（Initialization)api=API(email='EMAIL@EXAMPLE.COM',password='PASSWORD',proxy=None,)购买Website(🚧ing):https://tikhub.ioDiscord(💳buy):https://discord.gg/KnWCrgCERqGithub:https://github.com/TikHubIOEmail:tikhub.io@proton.meWeChat/微信: 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.pyInstallpipinstalltikhubUsagefromtikhub.__main__import*asyncdefasync_test()->None:# 异步测试/Async testtiktok_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 headerr=awaitapi.user_login()print("Running test : API.user_login()")print(r)# 获取TikHub用户信息/Get TikHub user informationprint("Running test : API.get_user_info()")r=awaitapi.get_user_info()print(r)print("\nRunning ALL TikTok methods test...\n")# 获取单个视频数据/Get single video dataprint("Running test : API.get_tiktok_video_data()")r=awaitapi.get_tiktok_video_data(tiktok_url)# print(r)# 获取获取用户主页的所有视频数据/Get all video data on the user's homepageprint("Running test : API.get_tiktok_profile_videos()")r=awaitapi.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 homepageprint("Running test : API.get_tiktok_profile_liked_videos()")r=awaitapi.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 videoprint("Running test : API.get_tiktok_video_comments()")r=awaitapi.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 pageprint("Running test : API.get_tiktok_music_videos()")r=awaitapi.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 dataprint("Running test : API.get_douyin_video_data()")r=awaitapi.get_douyin_video_data(douyin_url)# 获取获取用户主页的所有视频数据/Get all video data on the user's homepageprint("Running test : API.get_douyin_profile_videos()")r=awaitapi.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 homepageprint("Running test : API.get_douyin_profile_liked_videos()")r=awaitapi.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 videoprint("Running test : API.get_douyin_video_comments()")r=awaitapi.get_douyin_video_comments(douyin_url,cursor=None,count=None,get_all=False)print(f'Get{len(r)}comments from video')# 总耗时/Total timetotal_time=round(time.time()-start_time,2)print("\nTest completed, total time:{}s".format(total_time))if__name__=='__main__':api=API(email='EMAIL@EXAMPLE.COM',password='PASSWORD',proxy=None,)asyncio.run(async_test())