TikTok-Api: [BUG] - ERROR:root:Converting response to JSON failed response is below (probably empty)

So yesterday my code worked fine, saved it and got to it today again. None of my programs using tiktokAPI are working. I am getting the same bug on all of them.

A clear and concise description of what the bug is.

Please insert the code that is throwing errors or is giving you weird unexpected results.

from TikTokApi import TikTokApi
api = TikTokApi.get_instance()

TikTokUserName = "danielhow01"
results = 500


UserLikedVideos = api.userLikedbyUsername(username=TikTokUserName, count=results)


for tiktok in UserLikedVideos:  
    Like_File = open("linksToLikedVideos.json", "a")
    idOfLikedVideo = tiktok['id']
    usernameOfLikedVideo = tiktok['author']['uniqueId']
    Like_File.write("\nhttps://www.tiktok.com/@" + usernameOfLikedVideo + "/video/" + idOfLikedVideo)
    Like_File.close()


print(idOfLikedVideo)
print(usernameOfLikedVideo)

Expected behavior

Well, the ID and username of 500 liked videos from a user are writen to a file. I added “https://www.tiktok.com/@” etc to make it a link.

Error Trace (if any)

Put the error trace below if there’s any error thrown.

ERROR:root:Expecting value: line 1 column 1 (char 0)
ERROR:root:Converting response to JSON failed response is below (probably empty)
Traceback (most recent call last):
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\TikTokApi\tiktok.py", line 162, in getData
    return r.json()
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Robin/Desktop/PyCharmProjects/TikTokV2/Get TikTok by URL.py", line 7, in <module>
    test = api.getTikTokById(id = Id, language='en', proxy=None)        # test is een dict
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\TikTokApi\tiktok.py", line 894, in getTikTokById
    return self.getData(url=api_url, **kwargs)
  File "C:\Users\Robin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\TikTokApi\tiktok.py", line 169, in getData
    raise Exception("Invalid Response")
Exception: Invalid Response

Desktop (please complete the following information):

  • OS: Windows 10
  • TikTokApi Version 3.7.7

Additional context Downloaded it yesterday, excuse me for my bad english and code. I am not a pro.

Is this some sort of TikTok banned me for accessing there info to much to quick?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.89. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Also seeing this. Here’s hoping @davidteather can get around it. If you need help, I can make some time for it today!

All TikTok requests returns 200 and ‘illegal request…’ in content for now. So app cant decode such content to json and return error