Open Source Libraries

Node.JS

Connect to TikTok LIVE streams in real-time with the TikTok-Live-Connector Node.JS library.

|View as Markdown|

The TikTok-Live-Connector is a Node.JS library for connecting to TikTok LIVE streams. It provides an event-driven API for receiving chat messages, gifts, likes, and more.

View the full source on GitHub.

Quickstart

1

Install the package

npm i tiktok-live-connector
2

Set your API key

const { SignConfig } = require('tiktok-live-connector');

SignConfig.apiKey = 'YOUR_API_KEY';
3

Connect and listen to events

const { WebcastPushConnection } = require('tiktok-live-connector');

let tiktokLiveConnection = new WebcastPushConnection("username");

tiktokLiveConnection.connect().then(state => {
  console.info(`Connected to roomId ${state.roomId}`);
}).catch(err => {
  console.error('Failed to connect', err);
});

tiktokLiveConnection.on('chat', data => {
  console.log(`${data.uniqueId}: ${data.comment}`);
});

tiktokLiveConnection.on('gift', data => {
  console.log(`${data.uniqueId} sent gift ${data.giftId}`);
});

Common Events

EventDescription
chatA viewer sent a chat message
giftA viewer sent a gift
likeA viewer liked the stream
memberA viewer joined the stream
shareA viewer shared the stream
followA viewer followed the creator
subscribeA viewer subscribed
roomUserViewer count updated
streamEndThe livestream ended

See the API Key Usage guide for more configuration options.