SDKs
Typisierte Clients für TypeScript und Python.
Beide Clients werden aus dem OpenAPI-Dokument der API generiert. Sie enthalten also jeden Endpunkt, jeden Parameter und jeden
Antworttyp und werden mit der API aktualisiert. Sie sind schlank: ein HTTP-Aufruf pro Methode, keine Wiederholungen und kein Zustand,
dieselben Felder credits_charged und balance_remaining wie die rohe API.
TypeScript
npm install tikdataapiimport { tikdataapi } from 'tikdataapi';
const api = tikdataapi({ apiKey: process.env.TIKDATAAPI_KEY! });
const { data: profile } = await api.getUser({ path: { user: 'tiktok' } });
console.log(profile?.data.followers, profile?.credits_charged);
const { data: page } = await api.getUserVideos({ path: { user: 'tiktok' }, query: { count: 16 } });
for (const v of page?.data ?? []) console.log(v.id, v.plays, v.description);
const { data: many } = await api.getUsers({ body: { usernames: ['tiktok', 'nba', 'espn'] } });
console.log(many?.items, many?.errors);
const { data: found } = await api.searchVideos({ query: { query: 'street food', count: 12 } });
for (const v of found?.data ?? []) console.log(v.id, v.author.username, v.plays);
const { data: accounts } = await api.searchUsers({ query: { query: 'cooking', count: 10 } });
for (const u of accounts?.data ?? []) console.log(u.username, u.followers, u.verified);
const { data: followers } = await api.getUserFollowers({ path: { user: 'tiktok' }, query: { count: 30 } });
for (const u of followers?.data ?? []) console.log(u.username, u.followers);
const { data: sound } = await api.getMusic({ path: { id: '6696419263248336898' } });
console.log(sound?.data.title, sound?.data.videos);
const { data: trending } = await api.getTrendingVideos({ query: { count: 16 } });
for (const v of trending?.data ?? []) console.log(v.id, v.author.username, v.plays);
const { data: sounds } = await api.searchMusic({ query: { query: 'lofi', count: 12 } });
for (const m of sounds?.data ?? []) console.log(m.id, m.title, m.author);
const { data: live } = await api.getUserLive({ path: { user: 'tiktok' } });
console.log(live?.data.live, live?.data.title, live?.data.viewers);
const { data: transcript } = await api.getVideoTranscript({ path: { id: '7708543740230536461' } });
console.log(transcript?.data.language, transcript?.data.text);
const { data: tags } = await api.searchHashtags({ query: { query: 'street food', count: 10 } });
for (const t of tags?.data ?? []) console.log(t.name, t.result_videos, t.result_plays);Jeder Aufruf gibt { data, error, response } zurück. Bei einem Status außer 2xx ist data undefined, und error
enthält den API-Fehler mit seinem code. Node 18+, Bun, Deno, Browser, Edge-Runtimes.
Python
pip install tikdataapiimport os
from tikdataapi import AuthenticatedClient
from tikdataapi.api.music import get_music
from tikdataapi.api.search import search_hashtags, search_music, search_users, search_videos
from tikdataapi.api.users import get_user, get_user_followers, get_user_live, get_user_videos, get_users
from tikdataapi.api.videos import get_trending_videos, get_video_transcript
from tikdataapi.models import (
GetUsersBody,
HashtagSummaryPage,
LiveRoomResponse,
MusicResponse,
MusicSummaryPage,
TranscriptResponse,
UserBatch,
UserPage,
UserResponse,
UserSummaryPage,
VideoPage,
)
client = AuthenticatedClient(
base_url="https://api.tikdataapi.com",
token=os.environ["TIKDATAAPI_KEY"],
prefix="",
auth_header_name="x-api-key",
)
profile = get_user.sync("tiktok", client=client)
if isinstance(profile, UserResponse):
print(profile.data.followers, profile.credits_charged)
page = get_user_videos.sync("tiktok", client=client, count=16)
if isinstance(page, VideoPage):
for v in page.data:
print(v.id, v.plays, v.description)
many = get_users.sync(client=client, body=GetUsersBody(usernames=["tiktok", "nba", "espn"]))
if isinstance(many, UserBatch):
print(many.items, many.errors)
found = search_videos.sync(client=client, query="street food", count=12)
if isinstance(found, VideoPage):
for v in found.data:
print(v.id, v.author.username, v.plays)
accounts = search_users.sync(client=client, query="cooking", count=10)
if isinstance(accounts, UserSummaryPage):
for u in accounts.data:
print(u.username, u.followers, u.verified)
followers = get_user_followers.sync("tiktok", client=client, count=30)
if isinstance(followers, UserPage):
for u in followers.data:
print(u.username, u.followers)
sound = get_music.sync("6696419263248336898", client=client)
if isinstance(sound, MusicResponse):
print(sound.data.title, sound.data.videos)
trending = get_trending_videos.sync(client=client, count=16)
if isinstance(trending, VideoPage):
for v in trending.data:
print(v.id, v.author.username, v.plays)
sounds = search_music.sync(client=client, query="lofi", count=12)
if isinstance(sounds, MusicSummaryPage):
for m in sounds.data:
print(m.id, m.title, m.author)
live = get_user_live.sync("tiktok", client=client)
if isinstance(live, LiveRoomResponse):
print(live.data.live, live.data.title, live.data.viewers)
transcript = get_video_transcript.sync("7708543740230536461", client=client)
if isinstance(transcript, TranscriptResponse):
print(transcript.data.language, transcript.data.text)
tags = search_hashtags.sync(client=client, query="street food", count=10)
if isinstance(tags, HashtagSummaryPage):
for t in tags.data:
print(t.name, t.result_videos, t.result_plays)Jede Operation gibt es in den Formen sync, sync_detailed, asyncio und asyncio_detailed. Die Module sind
api.users, api.videos, api.hashtags, api.music, api.playlists, api.search, api.account und api.billing;
get_related_videos, get_trending_videos und get_video_transcript liegen in api.videos, get_user_live liegt in
api.users. sync gibt bei 200 das
Modell der Antwort zurück (UserResponse, VideoPage, ...), bei einem Fehlerstatus ein Error-Modell und
None bei einem Status, den die API-Referenz nicht nennt. Prüfen Sie den Typ mit isinstance, wie oben.
Methoden
| Methode | Endpunkt |
|---|---|
getMe / get_me | GET /v1/me |
getUser / get_user | GET /v1/users/{user} |
getUsers / get_users | POST /v1/users/batch |
getUserVideos / get_user_videos | GET /v1/users/{user}/videos |
getUsersVideos / get_users_videos | POST /v1/users/videos/batch |
getUserFollowers / get_user_followers | GET /v1/users/{user}/followers |
getUserFollowing / get_user_following | GET /v1/users/{user}/following |
getUserReposts / get_user_reposts | GET /v1/users/{user}/reposts |
getUserPlaylists / get_user_playlists | GET /v1/users/{user}/playlists |
getUserLive / get_user_live | GET /v1/users/{user}/live |
getVideo / get_video | GET /v1/videos/{id} |
getVideos / get_videos | POST /v1/videos/batch |
getRelatedVideos / get_related_videos | GET /v1/videos/{id}/related |
getTrendingVideos / get_trending_videos | GET /v1/trending/videos |
getVideoTranscript / get_video_transcript | GET /v1/videos/{id}/transcript |
getComments / get_comments | GET /v1/videos/{id}/comments |
getCommentReplies / get_comment_replies | GET /v1/videos/{id}/comments/{comment_id}/replies |
getHashtag / get_hashtag | GET /v1/hashtags/{name} |
getHashtagVideos / get_hashtag_videos | GET /v1/hashtags/{name}/videos |
getMusic / get_music | GET /v1/music/{id} |
getMusicVideos / get_music_videos | GET /v1/music/{id}/videos |
getPlaylistVideos / get_playlist_videos | GET /v1/playlists/{id}/videos |
searchVideos / search_videos | GET /v1/search/videos |
searchUsers / search_users | GET /v1/search/users |
searchMusic / search_music | GET /v1/search/music |
searchLive / search_live | GET /v1/search/live |
searchHashtags / search_hashtags | GET /v1/search/hashtags |
listPacks, createCheckout / list_packs, create_checkout | Abrechnung |
Die Videosuche, die Kontosuche und die Follower- und Gefolgt-Listen sind neu seit dem 2026-12-02. Ein Eintrag der
Kontosuche ist ein kurzes Profil (UserSummary) mit gerundetem followers. In einem Eintrag einer Follower- oder
Gefolgt-Liste können die Zahlen gerundet sein. getUser / get_user liefert die genauen.
Sounds, Reposts, Playlists, ähnliche Videos und Trend-Videos sind neu seit dem 2026-12-03. getMusic / get_music
liefert ein MusicDetail; sein videos, die Zahl der Videos, die den Sound nutzen, ist von TikTok gerundet.
getUserPlaylists / get_user_playlists liefert Playlist-Einträge; geben Sie die id eines Eintrags an
getPlaylistVideos / get_playlist_videos. getRelatedVideos / get_related_videos (eine Seite mit bis zu 16) und
getTrendingVideos / get_trending_videos (bis zu 50) nehmen keinen Cursor und haben keine nächste Seite.
Sound-Suche, Live und Transkripte sind ebenfalls neu seit dem 2026-12-03. searchMusic / search_music liefert
MusicSummary-Einträge; geben Sie die id eines Eintrags an getMusic / get_music. searchLive / search_live liefert
LiveRoom-Einträge, und getUserLive / get_user_live liefert einen LiveRoom, mit live: false und ohne Raumfelder, wenn
das Konto nicht live ist. Ein LiveRoom hat keine Stream-URL. getVideoTranscript / get_video_transcript liefert ein
Transcript: segments mit start und end in Sekunden, und text. Sein lang wählt eine Sprache; ein Video ohne
Untertitel ist ein 404.
Die Hashtag-Suche ist ebenfalls neu seit dem 2026-12-03. searchHashtags / search_hashtags liefert
HashtagSummary-Einträge, die meistgenutzten zuerst, aus etwa 24 Videos der allgemeinen Suche. Ihre result_videos und
result_plays zählen nur diese Videos, nicht die Gesamtzahlen von TikTok: Geben Sie dafür den name eines Eintrags an
getHashtag / get_hashtag. Sie nimmt keinen Cursor und hat keine nächste Seite.
Ein user ist ein Benutzername, mit oder ohne @, oder eine sec_uid. Geben Sie next_cursor einer Seite als cursor zurück.
Andere Sprachen: Das OpenAPI-Dokument funktioniert mit jedem Generator, und der MCP-Server deckt Agenten ohne Code ab.