davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.52k stars 928 forks source link

cause of "EmptyResponseException: None -> TikTok returned an empty response" error #1116

Open calvin-walters opened 4 months ago

calvin-walters commented 4 months ago

Does anyone know what the cause of the ultra-common "EmptyResponseException: None -> TikTok returned an empty response" error is?

This article states that "TikTok's free APIs have usage restrictions. The commercial content API allows a maximum of 600 requests per day."

Is the "EmptyResponseException: None -> TikTok returned an empty response" error caused by a rate limit?

angelopouloschristos commented 4 months ago

Same error

angelopouloschristos commented 4 months ago

Temporary fix to it : in "tiktok.py" line 206, change headless=True, to false.

Kkordik commented 3 months ago

Temporary fix to it : in "tiktok.py" line 206, change headless=True, to false.

Or you can simply specify headless=False at api.create_sessions() :

from TikTokApi import TikTokApi
import asyncio
import os

ms_token = os.environ.get("ms_token", None) # get your own ms_token from your cookies on tiktok.com

async def trending_videos():
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3, headless=False)
        async for video in api.trending.videos(count=30):
            print(video)
            print(video.as_dict)

asyncio.run(trending_videos())

This worked for me. But I hope will be better fix

Kkordik commented 3 months ago

View the working solution at: https://github.com/davidteather/TikTok-Api/issues/1090#issuecomment-2030409545