TikTokAPI-Python icon indicating copy to clipboard operation
TikTokAPI-Python copied to clipboard

The api randomly does not let me get data from the getVideosByUserName method

Open HerbeMalveillante opened this issue 3 years ago • 2 comments

I have a bot that retrieves the tik tok of an user every minute. But now It just gives this key error: line 118, in getVideosByUserName user_obj = user_data["userInfo"]["user"] KeyError: 'userInfo'

Here is my code :

def get_tikTok(username):
	api = TikTokAPI(cookie=None)
	videos_obj = api.getVideosByUserName(username, count=3)

HerbeMalveillante avatar Feb 25 '21 15:02 HerbeMalveillante

ok, try to extend the library, and make your own get video by user id and secu_id. Sinve the getVideoByUserName, calles 2 endpoints:

  1. the get user info endpoint
  2. get the user videos by user id and user secu id

this way you are pushing to much, and they might bann you. when they do that, you are going to miss the userInfo key, and that will be empty, so you will get this error. If you repeat this process for known users, save their user_id and secu_id to use later, this way you optimize the connections.

thanatos11 avatar Apr 01 '21 14:04 thanatos11

I am confuse on how I can do this, I am working on a school project and I am getting the same error as Harbe, can you show an example thanatos.

ghost avatar Apr 08 '21 01:04 ghost