Overview
TheTikTokLiveClient is the core class for connecting to and interacting with TikTok LIVE streams. It handles WebSocket connections, HTTP requests, event management, and provides a simple interface for reading live stream data.
Creating a Client
Basic Initialization
Constructor Parameters
The username or user ID of the creator to connect to. Can include
@ prefix and /live suffix - these will be automatically stripped.The platform to connect from (WEB or APP).
Optional proxy for HTTP requests.
Optional proxy for WebSocket connections.
Additional arguments for the HTTP client.
Additional arguments for the WebSocket client.
Whether to resolve a user ID to a unique_id (username).
Example with Options
Client Properties
Connection State
Whether the WebSocket client is currently connected to TikTok.
User Information
The cleaned unique ID (username) of the connected user.
The room ID of the current livestream.
None if not connected.Stream Data
Room information if
fetch_room_info=True was passed to start(), connect(), or run().Gift information if
fetch_gift_info=True was passed to start(), connect(), or run().Internal Components
The HTTP client used for requests.
The internal logger used by TikTokLive.
Client Configuration
Error Handling
Utility Methods
Check Live Status
Send Chat Message
The
send_room_chat() method requires appropriate authentication and permissions. It may not work for all users or streams.Event Listener Methods
Check for Listeners
Best Practices
Use Context Managers
Always close the client properly using
await client.close() or use async context managers when available.Handle Exceptions
Catch
AlreadyConnectedError, UserOfflineError, and UserNotFoundError when connecting.Configure Logging
Set appropriate log levels for development vs production environments.
Reuse Clients
Disconnect and reconnect the same client instance instead of creating new instances.
Related Topics
Connection Lifecycle
Learn about starting, connecting, and disconnecting
Event Handling
Understand how to register and handle events
Events Overview
Explore all available events