Using TikTok API by David Teather `pip3 install TikTokApi`
Cell In[1], line 1
Using TikTok API by David Teather `pip3 install TikTokApi`
^
SyntaxError: invalid syntax
from TikTokApi import TikTokApi
api = TikTokApi.get_instance()
results = 10
# Since TikTok changed their API you need to use the custom_verifyFp option.
# In your web browser you will need to go to TikTok, Log in and get the s_v_web_id value.
trending = api.by_trending(count=results, custom_verifyFp="")
for tiktok in trending:
# Prints the id of the tiktok
print(tiktok['id'])
print(len(trending))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_27608/1837457069.py in <module>
5 # Since TikTok changed their API you need to use the custom_verifyFp option.
6 # In your web browser you will need to go to TikTok, Log in and get the s_v_web_id value.
----> 7 trending = api.by_trending(count=results, custom_verifyFp="")
8
9 for tiktok in trending:
C:\ProgramData\Anaconda3\envs\mlpy\lib\site-packages\TikTokApi\tiktok.py in by_trending(self, count, **kwargs)
506 }
507 api_url = "{}api/recommend/item_list/?{}&{}".format(
--> 508 BASE_URL, self.__add_url_params__(), urlencode(query)
509 )
510 res = self.get_data(url=api_url, ttwid=ttwid, **kwargs)
C:\ProgramData\Anaconda3\envs\mlpy\lib\site-packages\TikTokApi\tiktok.py in __add_url_params__(self)
1526 "app_name": "tiktok_web",
1527 "device_platform": "web_mobile",
-> 1528 "region": self.region or "US",
1529 "priority_region": "",
1530 "os": "ios",
AttributeError: 'TikTokApi' object has no attribute 'region'
from TikTokApi import TikTokApi
api = TikTokApi()
n_videos = 100
username = 'washingtonpost'
user_videos = api.byUsername(username, count=n_videos)
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_27608/1733951738.py in <module>
1 from TikTokApi import TikTokApi
----> 2 api = TikTokApi()
3 n_videos = 100
4 username = 'washingtonpost'
5 user_videos = api.byUsername(username, count=n_videos)
C:\ProgramData\Anaconda3\envs\mlpy\lib\site-packages\TikTokApi\tiktok.py in __init__(self, **kwargs)
27 TikTokApi.__instance = self
28 else:
---> 29 raise Exception("Only one TikTokApi object is allowed")
30 logging.basicConfig(level=kwargs.get("logging_level", logging.WARNING))
31 logging.info("Class initalized")
Exception: Only one TikTokApi object is allowed