Open Source Libraries
Node.JS
Connect to TikTok LIVE streams in real-time with the TikTok-Live-Connector Node.JS library.
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-connector2
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
| Event | Description |
|---|---|
chat | A viewer sent a chat message |
gift | A viewer sent a gift |
like | A viewer liked the stream |
member | A viewer joined the stream |
share | A viewer shared the stream |
follow | A viewer followed the creator |
subscribe | A viewer subscribed |
roomUser | Viewer count updated |
streamEnd | The livestream ended |
See the API Key Usage guide for more configuration options.