TikTok API for Python.
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
Checking
Clean example request for the media downloader endpoint. Replace YOUR API and the media URL, then run the code.
import requests
import urllib.parse
API_KEY = "YOUR API"
VIDEO_URL = "URL TIKTOK"
ENDPOINT = "https://senpai-bot.store/tiktokdl"
def main():
encoded_url = urllib.parse.quote(VIDEO_URL, safe='')
get_data = f"{ENDPOINT}?apikey={API_KEY}&url={encoded_url}"
try:
response = requests.get(get_data)
response.raise_for_status()
data = response.json()
except Exception as e:
print(f"Error: {e}")
return
r = data.get("result", {})
username = r.get("username", {})
print("Username:", username.get("unique_id"))
print("Nickname:", username.get("nickname"))
print("Avatar:", username.get("avatar"))
print("Title:", r.get("title"))
print("Title Count:", r.get("title_count"))
print("Duration:", r.get("duration"))
print("Like Count:", r.get("like_count"))
print("Comment Count:", r.get("comment_count"))
print("Share Count:", r.get("share_count"))
print("Play Count:", r.get("play_count"))
print("Download Count:", r.get("download_count"))
print("Created:", r.get("created"))
print("Cover Track:", r.get("cover_track"))
print("Audio URL:", r.get("audio_url"))
print("Video Picture:", r.get("video_picture"))
print("Thumbnail URL:", r.get("thumbnail_url"))
print("Watermark URL:", r.get("watermark_url"))
print("No Watermark URL:", r.get("no_watermark_url"))
if __name__ == "__main__":
main()