TikTokLive.client.web.routes package

Submodules

TikTokLive.client.web.routes.fetch_gift_list module

exception TikTokLive.client.web.routes.fetch_gift_list.FailedFetchGiftListError

Bases: RuntimeError

Thrown when a request to the gift list endpoint fails

class TikTokLive.client.web.routes.fetch_gift_list.FetchGifListRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Retrieve the gift list from TikTok

TikTokLive.client.web.routes.fetch_image_data module

class TikTokLive.client.web.routes.fetch_image_data.FetchImageDataRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Fetch an image from the TikTok CDN

TikTokLive.client.web.routes.fetch_is_live module

class TikTokLive.client.web.routes.fetch_is_live.FetchIsLiveRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Check if a given user is alive through their unique_id or room_id

async fetch_is_live_room_ids(*room_ids: int) List[bool]

Check whether a list of room_id’s are currently live

Parameters:

room_ids – The room_id’s to check

Returns:

Whether they are alive, in the order they were sent

async fetch_is_live_unique_id(unique_id: str) bool

Check whether a given user is live

Parameters:

unique_id – The unique_id of the user

Returns:

Whether they are live

Raises:

InvalidLiveUser

exception TikTokLive.client.web.routes.fetch_is_live.InvalidFetchIsLiveRequest

Bases: RuntimeError

Thrown when the user fails to specify either a room ID or unique ID

exception TikTokLive.client.web.routes.fetch_is_live.MissingRoomIdInResponse

Bases: RuntimeError

Thrown when no entries are returned from the Room ID live method. This occurs when passing a nonexistent Room ID or when being detected by TikTok.

TikTokLive.client.web.routes.fetch_room_id_api module

class TikTokLive.client.web.routes.fetch_room_id_api.FetchRoomIdAPIRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Route to retrieve the room ID for a user

async classmethod fetch_user_room_data(web: TikTokHTTPClient, unique_id: str) dict

Fetch user room from the API (not the same as room info)

Parameters:
  • web – The TikTokHTTPClient client to use

  • unique_id – The user to check

Returns:

The user’s room info

classmethod parse_room_id(data: dict) str

Parse the room ID from livestream API response

Parameters:

data – The data to parse

Returns:

The user’s room id

Raises:

UserOfflineError if the user is offline

Raises:

FailedParseRoomIdError if the user data does not exist

TikTokLive.client.web.routes.fetch_room_id_live_html module

exception TikTokLive.client.web.routes.fetch_room_id_live_html.FailedParseRoomIdError

Bases: RuntimeError

Thrown when the Room ID cannot be parsed

class TikTokLive.client.web.routes.fetch_room_id_live_html.FetchRoomIdLiveHTMLRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Route to retrieve the room ID for a user

SIGI_PATTERN: Pattern = re.compile('<script id="SIGI_STATE" type="application/json">(.*?)</script>')
classmethod parse_room_id(html: str) str

Parse the room ID from livestream HTML

Parameters:

html – The HTML to parse from https://tiktok.com/@<unique_id>/live

Returns:

The user’s room id

Raises:

UserOfflineError if the user is offline

Raises:

FailedParseRoomIdError if the user does not exist

TikTokLive.client.web.routes.fetch_room_info module

exception TikTokLive.client.web.routes.fetch_room_info.FailedFetchRoomInfoError

Bases: RuntimeError

Thrown if Room info request fails

class TikTokLive.client.web.routes.fetch_room_info.FetchRoomInfoRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Retrieve the room info payload of a livestream room

exception TikTokLive.client.web.routes.fetch_room_info.InvalidFetchRoomInfoPayload

Bases: RuntimeError

TikTokLive.client.web.routes.fetch_signed_websocket module

class TikTokLive.client.web.routes.fetch_signed_websocket.FetchSignedWebSocketRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Call the signature server to receive the TikTok websocket URL

TikTokLive.client.web.routes.fetch_video_data module

exception TikTokLive.client.web.routes.fetch_video_data.DuplicateDownloadError

Bases: RuntimeError

Thrown when attempting to start a duplicate download on a video you are already downloading

class TikTokLive.client.web.routes.fetch_video_data.FetchVideoDataRoute(web: TikTokHTTPClient)

Bases: ClientRoute

TikTok route to record the livestream video in real-time

property ffmpeg: FFmpeg | None

Return a copy of the FFmpeg class, which is only defined while recording

Returns:

Copy of the class or None

property is_recording: bool

Check if the route is currently in use to record the Live

Returns:

Recording status

start(**kwargs) None

Alias for calling the class itself, starts a recording

Parameters:

kwargs – Kwargs to pass to __call__

Returns:

None

stop() None

Stop a livestream recording if it is ongoing

Returns:

None

class TikTokLive.client.web.routes.fetch_video_data.VideoFetchFormat(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

TikTok-supported video recording formats

CMAF = 'cmaf'
FLV = 'flv'
HLS = 'hls'
class TikTokLive.client.web.routes.fetch_video_data.VideoFetchQuality(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Video quality selection for stream downloads

HD = 'hd'

High definition (540p, vbrate-1,000,000)

LD = 'ld'

Low definition (480p, vbrate-500,000)

ORIGIN = 'origin'

Original definition (N/A, vbrate-N/A)

SD = 'sd'

Standard definition (480p, vbrate-800,000)

UHD = 'uhd'

Ultra-high definition (720p, vbrate-1,000,000)

TikTokLive.client.web.routes.send_room_chat module

class TikTokLive.client.web.routes.send_room_chat.SendRoomChatRoute(web: TikTokHTTPClient)

Bases: ClientRoute

TikTokLive.client.web.routes.send_room_gift module

class TikTokLive.client.web.routes.send_room_gift.GiftPayload

Bases: TypedDict

Gift payload for sending a gift to a TikTok LIVE room.

Example Payload:

count: 1 enter_from: live_detail_ gift_id: 5655 is_opted_in_host: true is_subscription: false room_id: 7451132632405510917 send_gift_req_start_ms: 1734862440968 send_scene: 1 send_type: 1 to_user_id: 7230478347297063942

count: int
enter_from: str
gift_id: int
is_opted_in_host: bool
is_subscription: bool
room_id: int | None
send_gift_req_start_ms: int
send_scene: int
send_type: int
to_user_id: int
class TikTokLive.client.web.routes.send_room_gift.SendRoomGiftRoute(web: TikTokHTTPClient)

Bases: ClientRoute

TikTokLive.client.web.routes.send_room_like module

class TikTokLive.client.web.routes.send_room_like.SendRoomLikeRoute(web: TikTokHTTPClient)

Bases: ClientRoute

Module contents