TikTok-Api icon indicating copy to clipboard operation
TikTok-Api copied to clipboard

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

Open calvin-walters opened this issue 1 year ago • 4 comments

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?

calvin-walters avatar Feb 15 '24 22:02 calvin-walters

Same error

angelopouloschristos avatar Feb 19 '24 13:02 angelopouloschristos

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

angelopouloschristos avatar Feb 19 '24 13:02 angelopouloschristos

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 avatar Apr 01 '24 17:04 Kkordik

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

Kkordik avatar Apr 01 '24 19:04 Kkordik