tiktok-live-api-npm
v1.0.0
Published
TikTok LIVE API for Node.js - real-time WebSocket chat, gifts, likes, viewers, battles + AI live captions. Managed signing, no sign server.
Maintainers
Keywords
Readme
TikTok LIVE API for Node.js
The managed TikTok LIVE API for Node.js and TypeScript. Connect to any TikTok LIVE stream over a single WebSocket and receive real-time chat messages, gifts, likes, follows, viewer counts, shares and battle events - plus AI live captions with 60+ language translation. Managed signing works out of the box: no third-party sign server, no keys to configure. Powered by the TikTool managed API.
Docs and dashboard: tik.tools | WebSocket API: tik.tools/websocket
This is the same client as the
tiktok-live-apipackage, published under a search-friendly name. It re-exports the client, REST helper, captions client and every public type unchanged, and depends ontiktok-live-apiso it always tracks the upstream release. If you are starting fresh you can install either name - the API is identical.
Not affiliated with or endorsed by TikTok. It connects to the TikTool Live managed API service - no reverse engineering, no sign server to maintain. Also available for Python and any language via WebSocket.
Install
npm install tiktok-live-api-npm# or with yarn / pnpm / bun
yarn add tiktok-live-api-npm
pnpm add tiktok-live-api-npm
bun add tiktok-live-api-npmQuick Start
import { TikTokLive } from 'tiktok-live-api-npm';
const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
client.on('chat', (event) => {
console.log(`${event.user.uniqueId}: ${event.comment}`);
});
client.on('gift', (event) => {
console.log(`${event.user.uniqueId} sent ${event.giftName} (${event.diamondCount} diamonds)`);
});
client.on('like', (event) => {
console.log(`${event.user.uniqueId} liked (total: ${event.totalLikes})`);
});
client.on('follow', (event) => {
console.log(`${event.user.uniqueId} followed`);
});
client.on('roomUserSeq', (event) => {
console.log(`${event.viewerCount} viewers watching`);
});
client.connect();Get a free API key at tik.tools. The key can also be supplied through the TIKTOOL_API_KEY environment variable.
Events
Register handlers with client.on(event, handler). Every payload is fully typed.
| Event | Fires when |
| --- | --- |
| chat | A viewer sends a chat message |
| gift | A gift is sent (with diamond value and combo state) |
| like | A viewer likes the stream |
| follow | A viewer follows the creator |
| share | A viewer shares the stream |
| member | A viewer joins the room |
| roomUserSeq | The viewer count updates |
| battle | A LIVE Match / battle event (armies, scores, timers) |
| connected | The WebSocket connects |
| disconnected | The stream ends or the socket closes |
| error | A connection or protocol error occurs |
REST client
The package also exports TikTool, a typed REST client for the tik.tools HTTP API - live status, rankings and leaderboards, gift catalogs, profiles, live analytics and more.
import { TikTool } from 'tiktok-live-api-npm';
const api = new TikTool({ apiKey: 'YOUR_API_KEY' });
const live = await api.isLive('streamer_username');
const board = await api.leaderboard({ region: 'US+' });
const recruits = await api.eligibleCreators({ region: 'US+', limit: 50 });AI live captions
TikTokCaptions streams real-time speech-to-text with translation into 60+ languages, including speaker labels.
import { TikTokCaptions } from 'tiktok-live-api-npm';
const captions = new TikTokCaptions('streamer_username', {
apiKey: 'YOUR_API_KEY',
translateTo: 'en',
});
captions.on('caption', (event) => console.log(event.text));
captions.on('translation', (event) => console.log(event.translated));
captions.connect();Why tik.tools
The premium managed alternative for TikTok LIVE data. What you get out of the box:
- Managed signing infrastructure. Signing runs on our servers and works immediately - no third-party sign server to run, no separate key to configure.
- AI live captions and translation. Real-time speech-to-text with 60+ language translation and speaker labels.
- Unreal Engine plugin. Drive avatars, overlays and gameplay directly from live chat, gifts and battles.
- Agency and leaderboard intelligence. Gifter leaderboards, gaming and creator ranks across regions, and eligible-creator discovery. See
tiktok-live-api-ranksfor the public rankings client. - Multi-language SDKs. First-class Node.js and Python clients plus a plain WebSocket API for any language.
- Free Sandbox tier. Start building for free, upgrade only when you need higher limits or unmasked data.
TypeScript
Types ship with the package. TikTokLiveEventMap maps each event name to its payload type, so client.on('gift', ...) gives you a fully typed GiftEvent.
License
MIT - see LICENSE.
