Skip to content

Event catalog

Every event TikTokLiveJava emits, its category, what it means, and the page that documents it, with both ways to subscribe.

A handler is registered in one of two forms. The builder’s on<Event> methods take an EventConsumer, a lambda that receives the LiveClient and the event; onEvent does the same for any event class, including the ones without a dedicated method, as onEvent(TikTokXEvent.class, handler), and onEvent(handler) receives every event. The other form is a listener: any object whose methods carry @TikTokEventObserver and take a parameter that extends TikTokEvent, added with addListener on the builder or on getListenersManager(); the LiveClient is an optional second parameter in either position. See listeners for priorities and asynchronous methods.

import io.github.jwdeveloper.tiktok.api.annotations.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.api.data.events.social.TikTokLikeEvent;
import io.github.jwdeveloper.tiktok.api.data.events.social.TikTokShareEvent;
import io.github.jwdeveloper.tiktok.api.live.LiveClient;
import io.github.jwdeveloper.tiktok.client.TikTokLive;
public class EventForms {
public static void main(String[] args) {
TikTokLive.newClient("isaackogz")
.onComment((client, event) -> System.out.println(event.getUser().getProfileName() + ": " + event.getText()))
.onEvent(TikTokShareEvent.class, (client, event) -> System.out.println(event.getUser().getProfileName() + " shared the stream"))
.addListener(new ReactionListener())
.buildAndConnect();
}
public static class ReactionListener {
@TikTokEventObserver
public void onLike(LiveClient client, TikTokLikeEvent event) {
client.getLogger().info(event.getUser().getProfileName() + " sent " + event.getLikes() + " likes");
}
}
}

Handlers are matched by the event’s exact class, plus the TikTokEvent catch-all. A handler for a base class does not receive its subclasses: onGift is not called for a TikTokGiftComboEvent although that class extends TikTokGiftEvent, and onEvent(TikTokLinkEvent.class, ...) receives only the generic link event, not TikTokLinkInviteEvent. An exception thrown by a handler while a message is processed is published as TikTokErrorEvent, and the client carries on with the next message. Register handlers before connecting: the signing response already carries messages, and they are dispatched before the socket opens.

This checkout defines 78 event classes under io.github.jwdeveloper.tiktok.api.data.events. The @EventMeta annotation on each gives its category: 6 Control events, which the client publishes about its own connection; 64 Message events, mapped from TikTok’s Webcast protobuf messages; and 4 Debug events, which expose the raw traffic. Four classes carry no category: TikTokLiveClientEvent and TikTokHeaderEvent are the base classes of the control and message events, TikTokUnhandledEvent is the base of the unhandled wrappers, and TikTokEmptyEvent is a placeholder. TikTokEvent itself is abstract and is never published; it is the type onEvent(handler) receives, and every event inherits its toJson().

A message event extends TikTokHeaderEvent, so it carries getMessageId(), getRoomId(), and getTimeStamp() from the message’s common header, and each grouped page links the message’s schema page for the full field list. Nested objects such as getUser() and getGift() are mapped from the message and are not null; a user TikTok did not send has id 0 and an empty name. Some messages produce more than one event: a like message publishes TikTokLikeEvent and then TikTokRoomInfoEvent, and a finished gift streak publishes TikTokGiftComboEvent and then TikTokGiftEvent. Every mapped event is preceded by a TikTokWebsocketMessageEvent that wraps it, and every batch by a TikTokWebsocketResponseEvent; see debugging.

The client maps a message only when MessagesMapperFactory registers a handler for its name; any other message is published as TikTokWebsocketUnhandledMessageEvent with its raw payload. Sixteen event classes exist for messages the default mapper does not register, or for a case its switch does not cover, so the default client never produces them: TikTokChestEvent, TikTokDetectEvent, TikTokEnvelopeEvent, TikTokGoalUpdateEvent, TikTokIMDeleteEvent, TikTokInRoomBannerEvent, TikTokLinkApplyEvent, TikTokLinkLayerEvent, TikTokLinkMicFanTicketEvent, TikTokLinkMicMethodEvent, TikTokLinkReplyEvent, TikTokRankTextEvent, TikTokRankUpdateEvent, TikTokShopEvent, TikTokSubNotifyEvent, and TikTokUnauthorizedMemberEvent. Each section below says so where it applies. Two more are never published by the client for another reason: TikTokHttpResponseEvent has a handler but no publisher in this checkout, and TikTokEmptyEvent is referenced nowhere.

To produce one of them, register a mapping with mappings on the builder. The mapping receives the message bytes, deserialises them with the helper, and returns a MappingResult holding the message and the events to publish. The protobuf classes live in io.github.jwdeveloper.tiktok.api.messages.webcast.

import io.github.jwdeveloper.tiktok.api.data.events.TikTokRankTextEvent;
import io.github.jwdeveloper.tiktok.api.mappers.data.MappingResult;
import io.github.jwdeveloper.tiktok.api.messages.webcast.WebcastRankTextMessage;
TikTokLive.newClient("isaackogz")
.mappings(mapper -> mapper.forMessage(WebcastRankTextMessage.class, (bytes, messageName, helper) -> {
var message = helper.bytesToWebcastObject(bytes, WebcastRankTextMessage.class);
return MappingResult.of(message, new TikTokRankTextEvent(message));
}))
.onEvent(TikTokRankTextEvent.class, (client, event) -> System.out.println(event.getLabel()))
.buildAndConnect();

A mapping registered this way replaces the default one for that message, so a custom WebcastLinkMessage mapping must reproduce the cases it still wants.

The client’s own connection lifecycle. Details: Control events.

EventTypeDescription
TikTokConnectingEventControlThe first thing connect() does, before any request
TikTokPreConnectionEventControlThe room data is fetched and the connection can still be cancelled
TikTokConnectedEventControlTriggered when the connection is successfully established
TikTokReconnectingEventControlA scheduled retry is about to call connect() again
TikTokDisconnectedEventControlTriggered when the connection gets disconnected
TikTokErrorEventControlGeneral error event; you should handle this
TikTokLiveClientEventnoneBase class of the control events, never published on its own

Comments, emotes, joins, likes, follows, shares, questions, barrages, and captions. Details: Chat and audience.

EventTypeDescription
TikTokCommentEventMessageTriggered every time a new chat comment arrives
TikTokEmoteEventMessageTriggered every time a subscriber sends an emote (sticker)
TikTokJoinEventMessageA viewer joined the livestream
TikTokLikeEventMessageTriggered when a viewer sends likes to the streamer
TikTokFollowEventMessageTriggers when a user follows the streamer
TikTokShareEventMessageTriggers when a user shares the stream
TikTokQuestionEventMessageTriggered every time someone asks a new question via the question feature
TikTokBarrageEventMessageAn animated banner notice, such as a high-grade viewer entering, a fan-level upgrade, or a subscription gift
TikTokCaptionEventMessageCaptions of the host’s speech

Gifts, streaks, goals, envelopes, and treasure chests. Details: Gifts and goals.

EventTypeDescription
TikTokGiftEventMessageTriggered when a user sends a gift that has no combo, or when a combo has finished
TikTokGiftComboEventMessageTriggered every time a gift is sent, with the streak’s state
TikTokGoalUpdateEventMessageA goal’s progress was updated (unmapped)
TikTokEnvelopeEventMessageAn envelope, the sender of a treasure chest (unmapped)
TikTokChestEventMessageA treasure chest with its diamond total and participant count (unmapped)

Battles, battle points, and link-mic (cohost and multi-guest) signalling. Details: Battles and cohosting.

EventTypeDescription
TikTokLinkMicBattleEventMessageA battle started or finished, with its teams, hosts, and final scores
TikTokLinkMicArmiesEventMessageA battle’s points were updated, per host or team with the top contributors
TikTokLinkMicBattleItemCardMessageA battle Power-Up card notice; carries only the message header
TikTokLinkMicFanTicketEventMessageA fan-ticket notice of a link-mic session; carries only the header (unmapped)
TikTokLinkMicMethodEventMessageLink-mic signalling between hosts; carries only the header (unmapped)
TikTokLinkLayerEventMessageA link layer change; carries only the header (unmapped)
TikTokLinkEventMessageA link message of a type with no dedicated event, and the base class of the ones below
TikTokLinkAcceptNoticeEventMessageAn invitation was accepted
TikTokLinkApplyEventMessageA guest applied to join (unmapped)
TikTokLinkCancelEventMessageAn invitation or application was cancelled
TikTokLinkCloseEventMessageThe link session was closed
TikTokLinkCohostListChangeEventMessageThe cohost list changed
TikTokLinkCreateEventMessageA link session was created
TikTokLinkEnterEventMessageUsers entered the link session, with the linked users list
TikTokLinkInviteEventMessageA host invited another host
TikTokLinkKickOutEventMessageA guest was removed, with the reason
TikTokLinkLeaveEventMessageA guest left
TikTokLinkLinkedListChangeEventMessageThe linked users list changed (first version of the message)
TikTokLinkListChangeEventMessageThe linked, applied, and connecting user lists changed
TikTokLinkMediaChangeEventMessageA guest’s microphone or camera was opened or closed
TikTokLinkMicIdxUpdateEventMessageA guest’s microphone position changed
TikTokLinkMuteEventMessageA guest was muted or unmuted
TikTokLinkRandomMatchEventMessageA random match paired the host with another host
TikTokLinkReplyEventMessageA host replied to an invitation (unmapped)
TikTokLinkSysKickOutEventMessageThe system removed a guest
TikTokLinkUpdateUserEventMessageA linked user’s state was updated
TikTokLinkUpdateUserSettingEventMessageA linked user’s settings were updated
TikTokLinkUserToastEventMessageA toast message about a linked user
TikTokLinkWaitListChangeEventMessageThe waiting list changed

Subscriptions and subscription notices. Details: Subscriptions and fans.

EventTypeDescription
TikTokSubscribeEventMessageTriggers when a user creates a subscription
TikTokSubNotifyEventMessageA subscription notice with its user (unmapped)

Room information, pinned messages, banners, polls, and the message header. Details: Room and display.

EventTypeDescription
TikTokRoomInfoEventMessageTriggered when LiveRoomInfo got updated, such as likes, viewers, or ranking
TikTokRoomPinEventMessageA comment was pinned
TikTokInRoomBannerEventMessageAn in-room banner, as the message’s extra data (unmapped)
TikTokHeaderEventnoneBase class of the message events: message id, room id, and timestamp
TikTokPollEventMessageA poll message of a type with no dedicated event, and the base class of the three below
TikTokPollStartEventMessageA poll started, with its title and options
TikTokPollUpdateEventMessageA poll’s vote counts were updated
TikTokPollEndEventMessageA poll ended, with the final options

Rank text and rank updates. Details: Rankings.

EventTypeDescription
TikTokRankTextEventMessageA rank notice’s text, such as a viewer entering the top contributors (unmapped)
TikTokRankUpdateEventMessageThe room’s rank or hourly rank was updated; carries only the header (unmapped)

Deleted messages, unauthorized members, detection probes, and the fallbacks for member, social, and control messages. Details: Moderation and access.

EventTypeDescription
TikTokIMDeleteEventMessageMessages or users’ messages were deleted (unmapped)
TikTokUnauthorizedMemberEventMessageA viewer without access entered, with a nickname only (unmapped)
TikTokDetectEventMessageA message-detection probe with its region (unmapped)
TikTokUnhandledMemberEventMessageA member message with an action other than joined or subscribed
TikTokUnhandledSocialEventMessageA social message that is not a like, follow, share, or join
TikTokUnhandledControlEventMessageA control message with an action other than pause, unpause, end, or suspend

Live shopping. Details: Games and commerce.

EventTypeDescription
TikTokShopEventMessageA product shown in live shopping (unmapped)

Stream pause, resume, end, and suspension. Details: Stream control.

EventTypeDescription
TikTokLiveEndedEventMessageTriggered when the live stream gets terminated by the host, or suspended by TikTok
TikTokLivePausedEventMessageThe host paused the stream
TikTokLiveUnpausedEventMessageThe host resumed a paused stream

The raw traffic, the mapping of each message, and the generic base classes. Details: Debugging.

EventTypeDescription
TikTokWebsocketResponseEventDebugA batch of messages arrived, before any of them is mapped
TikTokWebsocketMessageEventDebugTriggered every time TikTok sends data, with the message, its event, and the mapping time
TikTokWebsocketUnhandledMessageEventDebugA protobuf-encoded Webcast message arrived that no mapping is registered for
TikTokHttpResponseEventDebugAn HTTP request and its response; not published in this checkout
TikTokUnhandledEventnoneGeneric base class of the unhandled wrappers, holding the raw message
TikTokEmptyEventnoneAn event with no fields, for your own publishEvent calls