Overview
HTTP routes are registered on theTikTokWebClient and provide access to TikTok’s web API endpoints. Each route is a callable class that handles a specific API interaction.
Room Information Routes
FetchRoomIdLiveHTMLRoute
Fetch a user’s room ID by parsing their TikTok LIVE HTML page. Source:TikTokLive/client/web/routes/fetch_room_id_live_html.py:20
Usage
Parameters
unique_id(str) - The user’s unique_id/username
Returns
str- The room ID
Raises
UserOfflineError- User is not currently liveUserNotFoundError- User does not exist or cannot go liveFailedParseRoomIdError- Failed to parse room ID from HTML
FetchRoomIdAPIRoute
Fetch a user’s room ID from TikTok’s API endpoint. Source:TikTokLive/client/web/routes/fetch_room_id_api.py:9
Usage
Parameters
unique_id(str) - The user’s unique_id/username
Returns
int- The room ID
Raises
UserNotFoundError- User does not exist or cannot go liveFailedParseRoomIdError- Failed to parse room ID from response
FetchRoomInfoRoute
Retrieve detailed room information for a livestream. Source:TikTokLive/client/web/routes/fetch_room_info.py:21
Usage
Parameters
room_id(Optional[int]) - The room ID to fetch info forunique_id(Optional[str]) - The user’s unique_id (alternative to room_id)
Returns
Dict[str, Any]- Room information dictionary
Raises
InvalidFetchRoomInfoPayload- Both room_id and unique_id specified, or neither specifiedAgeRestrictedError- Stream is 18+ restricted (requires sessionid cookie)FailedFetchRoomInfoError- Request failed
Status Routes
FetchIsLiveRoute
Check if a user is currently live on TikTok. Source:TikTokLive/client/web/routes/fetch_is_live.py:29
Usage
Parameters
room_id(Optional[int]) - The room ID to checkunique_id(Optional[str]) - The user’s unique_id to check
Returns
bool- Whether the user is currently live
Raises
InvalidFetchIsLiveRequest- Neither room_id nor unique_id providedMissingRoomIdInResponse- Room ID not found (nonexistent or detected by TikTok)
Additional Methods
fetch_is_live_room_ids(*room_ids: int) -> List[bool]
Check multiple room IDs at once:
fetch_is_live_unique_id(unique_id: str) -> bool
Check a single unique_id:
Gift Routes
FetchGifListRoute
Fetch the list of available gifts from TikTok. Source:TikTokLive/client/web/routes/fetch_gift_list.py:17
Usage
Parameters
room_id(Optional[str]) - The room ID to fetch gifts for (currently unused)
Returns
Dict[str, Any]- Gift list data containing gift information
Raises
FailedFetchGiftListError- Request to gift list endpoint failed
Media Routes
FetchImageDataRoute
Fetch image data from TikTok’s CDN. Source:TikTokLive/client/web/routes/fetch_image_data.py:9
Usage
Parameters
image(Union[str, ImageModel]) - Image URL string or ImageModel protobuf object
Returns
bytes- Raw image data
FetchVideoDataRoute
Record a TikTok livestream video in real-time using FFmpeg. Source:TikTokLive/client/web/routes/fetch_video_data.py:57
Usage
Parameters
output_fp(Union[Path, str]) - Output file path for the recordingroom_info(dict) - Room information dictionary (fromfetch_room_info)record_for(Optional[int]) - Duration in seconds (-1 or ≤0 for infinite)quality(VideoFetchQuality) - Video quality presetrecord_format(VideoFetchFormat) - Source format from TikTokoutput_format(Optional[str]) - Output format for FFmpeg (defaults to record_format)**kwargs- Additional FFmpeg options
Video Quality Options
Video Format Options
Properties
ffmpeg(Optional[FFmpeg]) - The FFmpeg instance (None when not recording)is_recording(bool) - Whether currently recordingoutput_filename(Optional[str]) - Current output file path
Methods
start(**kwargs) - Start recording (alias for __call__)
stop() - Stop the current recording
Raises
DuplicateDownloadError- Already recording this stream
Requires FFmpeg to be installed and available in system PATH.
WebSocket Routes
FetchSignedWebSocketRoute
Fetch signed WebSocket connection data from the signature server. Source:TikTokLive/client/web/routes/fetch_signed_websocket.py:30
Usage
Parameters
platform(WebcastPlatform) - Platform type (WEB or MOBILE)room_id(Optional[int]) - Room ID to connect tosession_id(Optional[str]) - Session ID for authenticated connectiontt_target_idc(Optional[str]) - TikTok target IDC cookie value
Returns
ProtoMessageFetchResult- Initial WebSocket message data
Platform Options
Raises
SignAPIError- Sign server request failedSignatureRateLimitError- Too many connection attemptsValueError- Mobile platform requires sessionid cookie
User Routes
FetchUserUniqueIdRoute
Resolve a TikTok user ID to their unique_id (username). Source:TikTokLive/client/web/routes/fetch_user_unique_id.py:27
Usage
Parameters
user_id(int) - The numeric user ID
Returns
str- The user’s unique_id (username)
Raises
FailedParseAppInfo- Failed to extract user data from HTMLFailedResolveUserId- Failed to resolve user ID to unique_id
Interaction Routes
All interaction routes require authentication via session cookies. See Session Management for setup instructions.
SendRoomChatRoute
Send a chat message to a livestream room. Source:TikTokLive/client/web/routes/send_room_chat.py:10
Usage
Parameters
content(str) - The chat message contentroom_id(Optional[int]) - Room ID to send message tosession_id(Optional[str]) - Session ID cookie (overrides client cookies)tt_target_idc(Optional[str]) - TikTok target IDC value
Returns
dict- Response from TikTok’s chat endpoint
Raises
ValueError- No room_id provided and client has no stored room_id- Authentication errors if session is invalid
SendRoomLikeRoute
Send likes to a livestream room. Source:TikTokLive/client/web/routes/send_room_like.py:9
Usage
Parameters
count(int) - Number of likes to sendroom_id(Optional[int]) - Room ID to send likes to
Returns
dict- Response from TikTok’s like endpoint
Raises
UserOfflineError- Cannot send likes to offline roomWebcastBlocked200Error- Blocked by TikTok (JA3 fingerprint mismatch)
SendRoomGiftRoute
Send a gift to a livestream broadcaster. Source:TikTokLive/client/web/routes/send_room_gift.py:40
Usage
Parameters
payload(GiftPayload) - Gift payload dictionary
GiftPayload Structure
Returns
dict- Response from TikTok’s gift endpoint
Raises
WebcastBlocked200Error- Blocked by TikTok (JA3 fingerprint mismatch)
Error Handling
All routes may raise the following general errors:httpx.HTTPError- Network/HTTP errorsSignAPIError- Sign server errorsTikTokLiveError- Base exception for all TikTokLive errors