Skip to content

Events

Listen to TikTok LIVE gifts, comments, likes, follows, shares, joins and subscriptions in tiktok-live-printer, with helpers for gift streaks and image URLs.

TikTokPrinterClient is an event emitter keyed by the Euler Stream schema v3 message names. Listen with client.on(name, listener).

EventPayloadMeaning
WebcastGiftMessageuser, gift.{name, diamondCount, type}, repeatCount, repeatEndA gift was sent (see streaks below)
WebcastChatMessageuser, contentA comment
WebcastLikeMessageuser, countLikes from a viewer
WebcastSocialMessageuser, followType, shareTypeFollow or share; use socialKind()
WebcastMemberMessageuser, actionRoom membership; isJoin() is true for joins
WebcastSubNotifyMessageuser, subMonthA subscription
WebcastRoomUserSeqMessageviewer countsCurrent viewer count
WebcastControlMessage, WebcastLiveIntroMessage, WebcastEnvelopeMessage, WebcastLinkMicBattle, WebcastPollMessage, WebcastQuestionNewMessage, WebcastRankUpdateMessage and moreSee WebcastEventMap for the full typed list

Unlisted schema v3 events still arrive; subscribe with a cast on the name. Euler Stream’s own events (room.status, roomInfo, workerInfo) are typed too.

EventPayload
connectednone
disconnected{ code, reason }, for example 4404 “Streamer is not live”, 4400 missing API key
errorError

Streakable gifts (gift.type === 1) send one message per tap while the viewer holds the button. Only the last one has repeatEnd === 1, and its repeatCount is the total.

import { giftDiamonds, giftTotal, isGiftComplete } from "tiktok-live-printer";
client.on("WebcastGiftMessage", (msg) => {
if (!isGiftComplete(msg)) return; // wait for the streak to end
console.log(giftTotal(msg), giftDiamonds(msg));
});
import { isJoin, socialKind } from "tiktok-live-printer";
client.on("WebcastSocialMessage", (msg) => console.log(socialKind(msg))); // "follow" | "share" | undefined
client.on("WebcastMemberMessage", (msg) => isJoin(msg) && console.log("joined"));