Event Architecture
TikTokLive uses an event-driven architecture built on top ofpyee.AsyncIOEventEmitter. When you connect to a live stream, the client receives WebSocket messages from TikTok and converts them into Python event objects that you can handle.
Event Types
There are two main categories of events:Proto Events
Proto events are automatically generated from TikTok’s protobuf messages. These represent the raw data structures sent by TikTok’s servers.Custom Events
Custom events are specially processed events that provide additional context or represent important state changes.Common Events
CommentEvent - Chat Messages
CommentEvent - Chat Messages
Triggered when a user sends a chat message.Key Properties:
comment/content: The message textuser_info: User who sent the commentuser_is_super_fan: Whether user is a subscriber
GiftEvent - Virtual Gifts
GiftEvent - Virtual Gifts
Triggered when a user sends a virtual gift.Key Properties:
gift/m_gift: The gift objectfrom_user: User who sent the giftto_user: Gift recipientrepeat_count: Number in streakstreaking: Whether still in progressvalue: USD value (only when streak ends)
JoinEvent - User Joins
JoinEvent - User Joins
Triggered when a user joins the livestream.Key Properties:
user: User who joinedoperator: User who performed the action
LikeEvent - Likes
LikeEvent - Likes
Triggered when a user likes the stream.Key Properties:
user: User who likedcount: Number of likes
FollowEvent - New Followers
FollowEvent - New Followers
Triggered when a user follows the streamer.
ShareEvent - Shares
ShareEvent - Shares
Lifecycle Events
ConnectEvent
Emitted when successfully connected to the stream.
DisconnectEvent
Emitted when disconnected from the stream.
LiveEndEvent
Emitted when the livestream ends.
LivePauseEvent
Emitted when the stream is paused.
Base Event Properties
All events inherit fromBaseEvent and share these properties:
The event class name (e.g., “CommentEvent”, “GiftEvent”).
The raw protobuf payload bytes if available.
Base64-encoded representation of the payload.
Size of the payload in bytes.
Example
Event Flow
Custom Event Processing
If applicable, additional custom events are derived (e.g., FollowEvent from SocialEvent)
Special Events
WebsocketResponseEvent
This event is emitted for every WebSocket message received, regardless of type. It’s useful for debugging or logging all activity.UnknownEvent
Emitted when TikTok sends a message type that TikTokLive doesn’t recognize yet.Complete Event List
TikTokLive supports over 200 different event types. Here are some additional notable ones:DiggEvent- When users “dig” (tap) the screenGoalUpdateEvent- Stream goal progress updatesPollEvent- Poll-related eventsRoomPinEvent- Pinned message eventsSubNotifyEvent- Subscription notificationsEmoteChatEvent- Emote messagesLinkMicBattleEvent- Battle events during co-hostingRankUpdateEvent- Ranking changes
For a complete list of all events, see the Events API Reference.
Next Steps
Event Handling
Learn how to register and handle events
Connection Lifecycle
Understand the connection process