tiktok-live-api 1.4.5 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +531 -427
  2. package/package.json +84 -84
package/README.md CHANGED
@@ -1,427 +1,531 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/tiktool/tiktok-live-api/main/banner.png" alt="tiktok-live-api" width="100%" />
3
- </p>
4
-
5
- # tiktok-live-api
6
-
7
- > šŸ“– **Full documentation, guides, and dashboard → [tik.tools](https://tik.tools)** &nbsp;|&nbsp; šŸ **Python SDK → [tik.tools/guides/python-tiktok-live](https://tik.tools/guides/python-tiktok-live)** &nbsp;|&nbsp; šŸ”Œ **WebSocket API → [tik.tools/websocket](https://tik.tools/websocket)**
8
-
9
- **Unofficial TikTok LIVE API Client for Node.js & TypeScript** - Connect to any TikTok LIVE stream and receive real-time chat messages, gifts, likes, follows, viewer counts, battles, and more. Includes AI-powered live captions (speech-to-text). Powered by the [TikTool](https://tik.tools) managed API.
10
-
11
- [![npm](https://img.shields.io/npm/v/tiktok-live-api)](https://www.npmjs.com/package/tiktok-live-api)
12
- [![npm downloads](https://img.shields.io/npm/dm/tiktok-live-api)](https://www.npmjs.com/package/tiktok-live-api)
13
- [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
14
- [![License](https://img.shields.io/npm/l/tiktok-live-api)](https://github.com/tiktool/tiktok-live-api/blob/main/LICENSE)
15
-
16
- <p align="center">
17
- <img src="https://raw.githubusercontent.com/tiktool/tiktok-live-api/main/tiktok-live-api.gif" alt="TikTok Live API Demo - real-time chat, gifts, and viewer events" width="700">
18
- </p>
19
-
20
- > This package is **not affiliated with or endorsed by TikTok**. It connects to the [TikTool Live](https://tik.tools) managed API service - 99.9% uptime, no reverse engineering, no maintenance required. Also available for [Python](https://pypi.org/project/tiktok-live-api/) and [any language via WebSocket](https://tik.tools/docs).
21
-
22
- ## Install
23
-
24
- ```bash
25
- npm install tiktok-live-api
26
- ```
27
-
28
- ```bash
29
- # or with yarn / pnpm / bun
30
- yarn add tiktok-live-api
31
- pnpm add tiktok-live-api
32
- bun add tiktok-live-api
33
- ```
34
-
35
- ## Quick Start
36
-
37
- ```typescript
38
- import { TikTokLive } from 'tiktok-live-api';
39
-
40
- const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
41
-
42
- client.on('chat', (event) => {
43
- console.log(`${event.user.uniqueId}: ${event.comment}`);
44
- });
45
-
46
- client.on('gift', (event) => {
47
- console.log(`${event.user.uniqueId} sent ${event.giftName} (${event.diamondCount} šŸ’Ž)`);
48
- });
49
-
50
- client.on('like', (event) => {
51
- console.log(`${event.user.uniqueId} liked (total: ${event.totalLikes})`);
52
- });
53
-
54
- client.on('follow', (event) => {
55
- console.log(`${event.user.uniqueId} followed!`);
56
- });
57
-
58
- client.on('roomUserSeq', (event) => {
59
- console.log(`${event.viewerCount} viewers watching`);
60
- });
61
-
62
- client.connect();
63
- ```
64
-
65
- That's it. **No complex setup, no protobuf, no reverse engineering, no breakages when TikTok updates.**
66
-
67
- ---
68
-
69
- ## šŸš€ Try It Now - Live Demo
70
-
71
- Copy-paste this into a file and run it. Connects to a live TikTok stream and prints every event in real time. Works on the free Community tier - 2 hours per WebSocket connection.
72
-
73
- **Save as `demo.mjs` and run with `node demo.mjs`:**
74
-
75
- ```javascript
76
- // demo.mjs - TikTok LIVE in real time
77
- // npm install tiktok-live-api
78
- import { TikTokLive } from 'tiktok-live-api';
79
-
80
- const API_KEY = 'YOUR_API_KEY'; // Get free key → https://tik.tools
81
- const LIVE_USERNAME = 'tv_asahi_news'; // Any live TikTok username
82
-
83
- const client = new TikTokLive(LIVE_USERNAME, { apiKey: API_KEY });
84
- let events = 0;
85
-
86
- client.on('chat', e => { events++; console.log(`šŸ’¬ ${e.user.uniqueId}: ${e.comment}`); });
87
- client.on('gift', e => { events++; console.log(`šŸŽ ${e.user.uniqueId} sent ${e.giftName} (${e.diamondCount}šŸ’Ž)`); });
88
- client.on('like', e => { events++; console.log(`ā¤ļø ${e.user.uniqueId} liked Ɨ ${e.likeCount}`); });
89
- client.on('member', e => { events++; console.log(`šŸ‘‹ ${e.user.uniqueId} joined`); });
90
- client.on('follow', e => { events++; console.log(`āž• ${e.user.uniqueId} followed`); });
91
- client.on('roomUserSeq', e => { events++; console.log(`šŸ‘€ Viewers: ${e.viewerCount}`); });
92
-
93
- client.on('connected', () => console.log(`\nāœ… Connected to @${LIVE_USERNAME} - streaming events...\n`));
94
- client.on('disconnected', () => console.log(`\nšŸ“Š Disconnected. Received ${events} events.\n`));
95
-
96
- client.connect();
97
- // Press Ctrl+C to stop. Community tier caps each WebSocket at 2 hours.
98
- ```
99
-
100
- <details>
101
- <summary><strong>šŸ”Œ Pure WebSocket version (no SDK, any language)</strong></summary>
102
-
103
- ```javascript
104
- // ws-demo.mjs - Pure WebSocket, zero SDK
105
- // npm install ws
106
- import WebSocket from 'ws';
107
-
108
- const API_KEY = 'YOUR_API_KEY';
109
- const LIVE_USERNAME = 'tv_asahi_news';
110
-
111
- const ws = new WebSocket(`wss://api.tik.tools?uniqueId=${LIVE_USERNAME}&apiKey=${API_KEY}`);
112
- let events = 0;
113
-
114
- ws.on('open', () => console.log(`\nāœ… Connected to @${LIVE_USERNAME} - streaming events...\n`));
115
- ws.on('message', (raw) => {
116
- const msg = JSON.parse(raw);
117
- events++;
118
- const d = msg.data || {};
119
- const user = d.user?.uniqueId || '';
120
- switch (msg.event) {
121
- case 'chat': console.log(`šŸ’¬ ${user}: ${d.comment}`); break;
122
- case 'gift': console.log(`šŸŽ ${user} sent ${d.giftName} (${d.diamondCount}šŸ’Ž)`); break;
123
- case 'like': console.log(`ā¤ļø ${user} liked Ɨ ${d.likeCount}`); break;
124
- case 'member': console.log(`šŸ‘‹ ${user} joined`); break;
125
- case 'roomUserSeq': console.log(`šŸ‘€ Viewers: ${d.viewerCount}`); break;
126
- case 'roomInfo': console.log(`šŸ“” Room: ${msg.roomId}`); break;
127
- default: console.log(`šŸ“¦ ${msg.event}`); break;
128
- }
129
- });
130
- ws.on('close', () => console.log(`\nšŸ“Š Disconnected. Received ${events} events.\n`));
131
- // Press Ctrl+C to stop. Community tier caps each WebSocket at 2 hours.
132
- ```
133
-
134
- </details>
135
-
136
- ---
137
-
138
- ## JavaScript (CommonJS)
139
-
140
- ```javascript
141
- const { TikTokLive } = require('tiktok-live-api');
142
-
143
- const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
144
- client.on('chat', (e) => console.log(`${e.user.uniqueId}: ${e.comment}`));
145
- client.connect();
146
- ```
147
-
148
- ## Get a Free API Key
149
-
150
- 1. Go to [tik.tools](https://tik.tools)
151
- 2. Sign up (no credit card required)
152
- 3. Copy your API key
153
-
154
- The free **Community** tier gives you 2,500 requests/day and 15 WebSocket connections (2 hours per connection). Forever free.
155
-
156
- ## Environment Variable
157
-
158
- Instead of passing `apiKey` directly, you can set it as an environment variable:
159
-
160
- ```bash
161
- # Linux / macOS
162
- export TIKTOOL_API_KEY=your_api_key_here
163
-
164
- # Windows (CMD)
165
- set TIKTOOL_API_KEY=your_api_key_here
166
-
167
- # Windows (PowerShell)
168
- $env:TIKTOOL_API_KEY="your_api_key_here"
169
- ```
170
-
171
- ```typescript
172
- import { TikTokLive } from 'tiktok-live-api';
173
-
174
- // Automatically reads TIKTOOL_API_KEY from environment
175
- const client = new TikTokLive('streamer_username');
176
- client.on('chat', (e) => console.log(e.comment));
177
- client.connect();
178
- ```
179
-
180
- ## Events
181
-
182
- | Event | Description | Key Fields |
183
- |-------|-------------|------------|
184
- | `chat` | Chat message | `user`, `comment`, `emotes`, `starred?` |
185
- | `gift` | Virtual gift | `user`, `giftName`, `diamondCount`, `repeatCount` |
186
- | `like` | Like event | `user`, `likeCount`, `totalLikes` |
187
- | `follow` | New follower | `user` |
188
- | `share` | Stream share | `user` |
189
- | `member` | Viewer joined | `user` |
190
- | `subscribe` | New subscriber | `user` |
191
- | `roomUserSeq` | Viewer count | `viewerCount`, `topViewers` |
192
- | `battle` | PK start / end / status change | `battleId`, `status` (1=ACTIVE / 2=STARTING / 3=ENDED / 4=PREPARING), `battleDuration`, `teams` |
193
- | `battleArmies` | Live PK score update | `battleId`, `status`, `matchId`, `sessionId`, `durationSec`, `secsRemaining`, `hosts[]` - each host has `teamTotalScore` + `contributors[]` (MVP first) |
194
- | `battleItemCard` | Booster multipliers, gloves, mist, match-guide, thunder, extra-time | `effect` (`'gloves'` / `'mist'` / `'booster_x2'` / `'booster_x3'` / `'match_guide'` / ...), `multiplier` (2 or 3), `senderUserId`, `senderNickname`, `activatedAtSec`, `durationSec`, `endsAtSec`, `commentTemplate` |
195
- | `roomPin` | Pinned/starred message | `user`, `comment`, `action`, `durationSeconds` |
196
- | `envelope` | Treasure chest | `diamonds`, `user` |
197
- | `streamEnd` | Stream ended | `reason` |
198
- | `connected` | Connected | `uniqueId` |
199
- | `disconnected` | Disconnected | `uniqueId` |
200
- | `error` | Error occurred | `error` |
201
- | `event` | Catch-all | Full raw event |
202
-
203
- All events are fully typed with TypeScript interfaces. Your IDE will show autocompletion for every field.
204
-
205
- ### Battle / PK example
206
-
207
- ```typescript
208
- import { TikTokLive } from 'tiktok-live-api';
209
-
210
- const client = new TikTokLive({ uniqueId: 'creator_username', apiKey: 'tk_...' });
211
-
212
- client.on('battle', e => console.log('PK', e.status, e.battleId, 'duration=', e.battleDuration));
213
-
214
- client.on('battleArmies', e => {
215
- console.log('Countdown:', e.secsRemaining, 's');
216
- for (const host of e.hosts ?? []) {
217
- console.log(`@${host.hostUserId} team total=${host.teamTotalScore}`);
218
- const mvp = host.contributors[0];
219
- if (mvp) console.log(` MVP @${mvp.nickname} score=${mvp.score}`);
220
- }
221
- });
222
-
223
- client.on('battleItemCard', e => {
224
- if (e.multiplier > 0) console.log(`x${e.multiplier} booster from @${e.senderUniqueId}`);
225
- else console.log(`Effect ${e.effect} from @${e.senderUniqueId} (${e.durationSec}s)`);
226
- });
227
-
228
- await client.connect();
229
- ```
230
-
231
-
232
- ## Live Captions (Speech-to-Text)
233
-
234
- Transcribe and translate any TikTok LIVE stream in real-time. **This feature is unique to TikTool Live - no other TikTok library offers it.**
235
-
236
- ```typescript
237
- import { TikTokCaptions } from 'tiktok-live-api';
238
-
239
- const captions = new TikTokCaptions('streamer_username', {
240
- apiKey: 'YOUR_API_KEY',
241
- translate: 'en', // translate to English
242
- diarization: true, // identify who is speaking
243
- });
244
-
245
- captions.on('caption', (event) => {
246
- const speaker = event.speaker ? `[${event.speaker}] ` : '';
247
- console.log(`${speaker}${event.text}${event.isFinal ? ' āœ“' : '...'}`);
248
- });
249
-
250
- captions.on('translation', (event) => {
251
- console.log(` → ${event.text}`);
252
- });
253
-
254
- captions.on('credits', (event) => {
255
- console.log(`${event.remaining}/${event.total} minutes remaining`);
256
- });
257
-
258
- captions.connect();
259
- ```
260
-
261
- ### Caption Events
262
-
263
- | Event | Description | Key Fields |
264
- |-------|-------------|------------|
265
- | `caption` | Real-time caption text | `text`, `speaker`, `isFinal`, `language` |
266
- | `translation` | Translated caption | `text`, `sourceLanguage`, `targetLanguage` |
267
- | `credits` | Credit balance update | `total`, `used`, `remaining` |
268
- | `credits_low` | Low credit warning | `remaining`, `percentage` |
269
- | `status` | Session status | `status`, `message` |
270
-
271
- ## Chat Bot Example
272
-
273
- ```typescript
274
- import { TikTokLive } from 'tiktok-live-api';
275
-
276
- const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
277
- const giftLeaderboard = new Map<string, number>();
278
- let messageCount = 0;
279
-
280
- client.on('chat', (event) => {
281
- messageCount++;
282
- const msg = event.comment.toLowerCase().trim();
283
- const user = event.user.uniqueId;
284
-
285
- if (msg === '!hello') {
286
- console.log(`>> BOT: Welcome ${user}! šŸ‘‹`);
287
- } else if (msg === '!stats') {
288
- console.log(`>> BOT: ${messageCount} messages, ${giftLeaderboard.size} gifters`);
289
- } else if (msg === '!top') {
290
- const top = [...giftLeaderboard.entries()]
291
- .sort((a, b) => b[1] - a[1])
292
- .slice(0, 5);
293
- top.forEach(([name, diamonds], i) => {
294
- console.log(` ${i + 1}. ${name} - ${diamonds} šŸ’Ž`);
295
- });
296
- }
297
- });
298
-
299
- client.on('gift', (event) => {
300
- const user = event.user.uniqueId;
301
- const diamonds = event.diamondCount || 0;
302
- giftLeaderboard.set(user, (giftLeaderboard.get(user) || 0) + diamonds);
303
- });
304
-
305
- client.connect();
306
- ```
307
-
308
- ## TypeScript
309
-
310
- This package ships with full TypeScript support. All events are typed:
311
-
312
- ```typescript
313
- import { TikTokLive, ChatEvent, GiftEvent } from 'tiktok-live-api';
314
-
315
- const client = new TikTokLive('streamer', { apiKey: 'KEY' });
316
-
317
- // Full autocompletion - your IDE knows the type of `event`
318
- client.on('chat', (event: ChatEvent) => {
319
- console.log(event.user.uniqueId); // āœ“ typed
320
- console.log(event.comment); // āœ“ typed
321
- });
322
-
323
- client.on('gift', (event: GiftEvent) => {
324
- console.log(event.giftName); // āœ“ typed
325
- console.log(event.diamondCount); // āœ“ typed
326
- });
327
- ```
328
-
329
- ## API Reference
330
-
331
- ### `new TikTokLive(uniqueId, options?)`
332
-
333
- | Option | Type | Default | Description |
334
- |--------|------|---------|-------------|
335
- | `apiKey` | `string` | `process.env.TIKTOOL_API_KEY` | Your TikTool API key |
336
- | `autoReconnect` | `boolean` | `true` | Auto-reconnect on disconnect |
337
- | `maxReconnectAttempts` | `number` | `5` | Max reconnection attempts |
338
-
339
- **Methods:**
340
- - `client.on(event, handler)` - Register event handler
341
- - `client.off(event, handler)` - Remove event handler
342
- - `client.connect()` - Connect to stream (returns Promise)
343
- - `client.disconnect()` - Disconnect from stream
344
- - `client.connected` - Whether currently connected
345
- - `client.eventCount` - Total events received
346
-
347
- ### `new TikTokCaptions(uniqueId, options?)`
348
-
349
- | Option | Type | Default | Description |
350
- |--------|------|---------|-------------|
351
- | `apiKey` | `string` | `process.env.TIKTOOL_API_KEY` | Your TikTool API key |
352
- | `translate` | `string` | `undefined` | Target translation language |
353
- | `diarization` | `boolean` | `true` | Enable speaker identification |
354
- | `maxDurationMinutes` | `number` | `60` | Auto-disconnect timer |
355
-
356
- **Methods:**
357
- - `captions.on(event, handler)` - Register event handler
358
- - `captions.off(event, handler)` - Remove event handler
359
- - `captions.connect()` - Start receiving captions (returns Promise)
360
- - `captions.disconnect()` - Stop receiving captions
361
- - `captions.connected` - Whether currently connected
362
-
363
- ## Why tiktok-live-api?
364
-
365
- | | tiktok-live-api | tiktok-live-connector | TikTokLive (Python) |
366
- |---|---|---|---|
367
- | **Stability** | āœ“ Managed API, 99.9% uptime | āœ— Breaks on TikTok updates | āœ— Breaks on TikTok updates |
368
- | **TypeScript** | āœ“ First-class, fully typed | Partial | N/A |
369
- | **Live Captions** | āœ“ AI speech-to-text | āœ— | āœ— |
370
- | **Translation** | āœ“ Real-time, 50+ languages | āœ— | āœ— |
371
- | **Maintenance** | āœ“ Zero - we handle it | āœ— You fix breakages | āœ— You fix breakages |
372
- | **CAPTCHA Solving** | āœ“ Built-in (Pro+) | āœ— | āœ— |
373
- | **Feed Discovery** | āœ“ See who's live | āœ— | āœ— |
374
- | **Free Tier** | āœ“ 2,500 req/day, 15 WS, 2h per WS | āœ“ Free (unreliable) | āœ“ Free (unreliable) |
375
- | **ESM + CJS** | āœ“ Both supported | āœ“ | N/A |
376
-
377
- ## Pricing
378
-
379
- | Tier | Requests/Day | WebSocket Connections | Price |
380
- |------|-------------|----------------------|-------|
381
- | Community | 2,500 | 15 (2h per WS) | Free forever |
382
- | Pro | 75,000 | 50 (8h per WS) | from $19/wk +tax |
383
- | Ultra | 300,000 | 250 (8h per WS) | from $69/wk +tax |
384
- | **Global Agency** | 300,000 | 500 (8h per WS) + Firehose | $149/wk or $549/mo +tax |
385
-
386
- Full plan details at [tik.tools/pricing](https://tik.tools/pricing). Highlights:
387
-
388
- - **Community** ($0 forever): 2,500 req/day Ā· 15 WS Ā· 2 hours per connection Ā· masked leaderboards. Designed for devs building apps - upgrade when you need real usernames. No datacenter proxies; calls must come from your own IP.
389
- - **Pro** ($19/wk): 75K req/day Ā· 50 WS Ā· unmasked leaderboards Ā· Feed Discovery Ā· 5 AI caption streams Ā· priority routing Ā· chat support
390
- - **Ultra** ($69/wk): 300K req/day Ā· 250 WS Ā· 20 AI caption streams Ā· **League Rankings API** unmasked Ā· 99.5% uptime SLA Ā· priority chat support
391
- - **Global Agency** ($149/wk or $549/mo): Everything in Ultra + **Live Gifter Firehose WS** (region/league/global filters, min-diamond threshold) + VIP Telegram alerts + VIP Web Vault (unmasked historical visual access)
392
-
393
- ### Live Gifter Firehose - Global Agency
394
-
395
- Real-time gift event stream from our Dragonfly fan-out. Filter by region, league, or globally; cap by minimum diamond threshold. Mid-stream filter updates supported via `update_filter` frame, no reconnect needed.
396
-
397
- ```js
398
- const ws = new WebSocket(
399
- `wss://api.tik.tools/firehose/gifters?apiKey=${KEY}&mode=region&region=US%2B&min_diamonds=1000`
400
- )
401
- ws.on('message', (raw) => {
402
- const evt = JSON.parse(raw)
403
- // evt: { type:'gifter_alert', ts, gifter:{username,displayName,isAnonymous},
404
- // creator:{uniqueId}, gift:{name,totalDiamonds}, region }
405
- })
406
- // Update filter without reconnect
407
- ws.send(JSON.stringify({ type: 'update_filter', mode: 'global', min_diamonds: 5000 }))
408
- ```
409
-
410
- Modes: `global` (all regions), `region` (single region code), `league` (region + league class, e.g. `B2`).
411
-
412
- ## Also Available
413
-
414
- - **Python**: [`pip install tiktok-live-api`](https://pypi.org/project/tiktok-live-api/)
415
- - **Any language**: Connect via WebSocket: `wss://api.tik.tools?uniqueId=USERNAME&apiKey=KEY`
416
- - **Unreal Engine**: Native C++/Blueprint plugin
417
-
418
- ## Links
419
-
420
- - 🌐 **Website**: [tik.tools](https://tik.tools)
421
- - šŸ“– **Documentation**: [tik.tools/docs](https://tik.tools/docs)
422
- - šŸ **Python SDK**: [pypi.org/project/tiktok-live-api](https://pypi.org/project/tiktok-live-api/)
423
- - šŸ’» **GitHub**: [github.com/tiktool/tiktok-live-api](https://github.com/tiktool/tiktok-live-api)
424
-
425
- ## License
426
-
427
- MIT
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/tiktool/tiktok-live-api/main/banner.png" alt="tiktok-live-api" width="100%" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://discord.com/oauth2/authorize?client_id=1482386543233597470">
7
+ <img src="https://img.shields.io/badge/Add%20TikTool%20Bot%20to%20Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Add TikTool Bot to Discord" height="46">
8
+ </a>
9
+ </p>
10
+
11
+ <p align="center"><b>Agency rank feeds in Discord</b>: gaming ranks, creator ranks and 99+ movers across all 30 regions, copy-paste usernames for backstage. Run <code>/ranks</code> to start (Global Agency).</p>
12
+
13
+ # tiktok-live-api
14
+
15
+ > šŸ“– **Full documentation, guides, and dashboard → [tik.tools](https://tik.tools)** &nbsp;|&nbsp; šŸ **Python SDK → [tik.tools/guides/python-tiktok-live](https://tik.tools/guides/python-tiktok-live)** &nbsp;|&nbsp; šŸ”Œ **WebSocket API → [tik.tools/websocket](https://tik.tools/websocket)**
16
+
17
+ **Unofficial TikTok LIVE API Client for Node.js & TypeScript** - Connect to any TikTok LIVE stream and receive real-time chat messages, gifts, likes, follows, viewer counts, battles, and more. Includes AI-powered live captions (speech-to-text). Powered by the [TikTool](https://tik.tools) managed API.
18
+
19
+ [![npm](https://img.shields.io/npm/v/tiktok-live-api)](https://www.npmjs.com/package/tiktok-live-api)
20
+ [![npm downloads](https://img.shields.io/npm/dm/tiktok-live-api)](https://www.npmjs.com/package/tiktok-live-api)
21
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
22
+ [![License](https://img.shields.io/npm/l/tiktok-live-api)](https://github.com/tiktool/tiktok-live-api/blob/main/LICENSE)
23
+
24
+ <p align="center">
25
+ <img src="https://raw.githubusercontent.com/tiktool/tiktok-live-api/main/tiktok-live-api.gif" alt="TikTok Live API Demo - real-time chat, gifts, and viewer events" width="700">
26
+ </p>
27
+
28
+ > This package is **not affiliated with or endorsed by TikTok**. It connects to the [TikTool Live](https://tik.tools) managed API service - 99.9% uptime, no reverse engineering, no maintenance required. Also available for [Python](https://pypi.org/project/tiktok-live-api/) and [any language via WebSocket](https://tik.tools/docs).
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npm install tiktok-live-api
34
+ ```
35
+
36
+ ```bash
37
+ # or with yarn / pnpm / bun
38
+ yarn add tiktok-live-api
39
+ pnpm add tiktok-live-api
40
+ bun add tiktok-live-api
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```typescript
46
+ import { TikTokLive } from 'tiktok-live-api';
47
+
48
+ const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
49
+
50
+ client.on('chat', (event) => {
51
+ console.log(`${event.user.uniqueId}: ${event.comment}`);
52
+ });
53
+
54
+ client.on('gift', (event) => {
55
+ console.log(`${event.user.uniqueId} sent ${event.giftName} (${event.diamondCount} šŸ’Ž)`);
56
+ });
57
+
58
+ client.on('like', (event) => {
59
+ console.log(`${event.user.uniqueId} liked (total: ${event.totalLikes})`);
60
+ });
61
+
62
+ client.on('follow', (event) => {
63
+ console.log(`${event.user.uniqueId} followed!`);
64
+ });
65
+
66
+ client.on('roomUserSeq', (event) => {
67
+ console.log(`${event.viewerCount} viewers watching`);
68
+ });
69
+
70
+ client.connect();
71
+ ```
72
+
73
+ That's it. **No complex setup, no protobuf, no reverse engineering, no breakages when TikTok updates.**
74
+
75
+ ---
76
+
77
+ ## šŸš€ Try It Now - Live Demo
78
+
79
+ Copy-paste this into a file and run it. Connects to a live TikTok stream and prints every event in real time. Works on the free Community tier - 2 hours per WebSocket connection.
80
+
81
+ **Save as `demo.mjs` and run with `node demo.mjs`:**
82
+
83
+ ```javascript
84
+ // demo.mjs - TikTok LIVE in real time
85
+ // npm install tiktok-live-api
86
+ import { TikTokLive } from 'tiktok-live-api';
87
+
88
+ const API_KEY = 'YOUR_API_KEY'; // Get free key → https://tik.tools
89
+ const LIVE_USERNAME = 'tv_asahi_news'; // Any live TikTok username
90
+
91
+ const client = new TikTokLive(LIVE_USERNAME, { apiKey: API_KEY });
92
+ let events = 0;
93
+
94
+ client.on('chat', e => { events++; console.log(`šŸ’¬ ${e.user.uniqueId}: ${e.comment}`); });
95
+ client.on('gift', e => { events++; console.log(`šŸŽ ${e.user.uniqueId} sent ${e.giftName} (${e.diamondCount}šŸ’Ž)`); });
96
+ client.on('like', e => { events++; console.log(`ā¤ļø ${e.user.uniqueId} liked Ɨ ${e.likeCount}`); });
97
+ client.on('member', e => { events++; console.log(`šŸ‘‹ ${e.user.uniqueId} joined`); });
98
+ client.on('follow', e => { events++; console.log(`āž• ${e.user.uniqueId} followed`); });
99
+ client.on('roomUserSeq', e => { events++; console.log(`šŸ‘€ Viewers: ${e.viewerCount}`); });
100
+
101
+ client.on('connected', () => console.log(`\nāœ… Connected to @${LIVE_USERNAME} - streaming events...\n`));
102
+ client.on('disconnected', () => console.log(`\nšŸ“Š Disconnected. Received ${events} events.\n`));
103
+
104
+ client.connect();
105
+ // Press Ctrl+C to stop. Community tier caps each WebSocket at 2 hours.
106
+ ```
107
+
108
+ <details>
109
+ <summary><strong>šŸ”Œ Pure WebSocket version (no SDK, any language)</strong></summary>
110
+
111
+ ```javascript
112
+ // ws-demo.mjs - Pure WebSocket, zero SDK
113
+ // npm install ws
114
+ import WebSocket from 'ws';
115
+
116
+ const API_KEY = 'YOUR_API_KEY';
117
+ const LIVE_USERNAME = 'tv_asahi_news';
118
+
119
+ const ws = new WebSocket(`wss://api.tik.tools?uniqueId=${LIVE_USERNAME}&apiKey=${API_KEY}`);
120
+ let events = 0;
121
+
122
+ ws.on('open', () => console.log(`\nāœ… Connected to @${LIVE_USERNAME} - streaming events...\n`));
123
+ ws.on('message', (raw) => {
124
+ const msg = JSON.parse(raw);
125
+ events++;
126
+ const d = msg.data || {};
127
+ const user = d.user?.uniqueId || '';
128
+ switch (msg.event) {
129
+ case 'chat': console.log(`šŸ’¬ ${user}: ${d.comment}`); break;
130
+ case 'gift': console.log(`šŸŽ ${user} sent ${d.giftName} (${d.diamondCount}šŸ’Ž)`); break;
131
+ case 'like': console.log(`ā¤ļø ${user} liked Ɨ ${d.likeCount}`); break;
132
+ case 'member': console.log(`šŸ‘‹ ${user} joined`); break;
133
+ case 'roomUserSeq': console.log(`šŸ‘€ Viewers: ${d.viewerCount}`); break;
134
+ case 'roomInfo': console.log(`šŸ“” Room: ${msg.roomId}`); break;
135
+ default: console.log(`šŸ“¦ ${msg.event}`); break;
136
+ }
137
+ });
138
+ ws.on('close', () => console.log(`\nšŸ“Š Disconnected. Received ${events} events.\n`));
139
+ // Press Ctrl+C to stop. Community tier caps each WebSocket at 2 hours.
140
+ ```
141
+
142
+ </details>
143
+
144
+ ---
145
+
146
+ ## JavaScript (CommonJS)
147
+
148
+ ```javascript
149
+ const { TikTokLive } = require('tiktok-live-api');
150
+
151
+ const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
152
+ client.on('chat', (e) => console.log(`${e.user.uniqueId}: ${e.comment}`));
153
+ client.connect();
154
+ ```
155
+
156
+ ## Get a Free API Key
157
+
158
+ 1. Go to [tik.tools](https://tik.tools)
159
+ 2. Sign up (no credit card required)
160
+ 3. Copy your API key
161
+
162
+ The free **Community** tier gives you 2,500 requests/day and 15 WebSocket connections (2 hours per connection). Forever free.
163
+
164
+ ## Environment Variable
165
+
166
+ Instead of passing `apiKey` directly, you can set it as an environment variable:
167
+
168
+ ```bash
169
+ # Linux / macOS
170
+ export TIKTOOL_API_KEY=your_api_key_here
171
+
172
+ # Windows (CMD)
173
+ set TIKTOOL_API_KEY=your_api_key_here
174
+
175
+ # Windows (PowerShell)
176
+ $env:TIKTOOL_API_KEY="your_api_key_here"
177
+ ```
178
+
179
+ ```typescript
180
+ import { TikTokLive } from 'tiktok-live-api';
181
+
182
+ // Automatically reads TIKTOOL_API_KEY from environment
183
+ const client = new TikTokLive('streamer_username');
184
+ client.on('chat', (e) => console.log(e.comment));
185
+ client.connect();
186
+ ```
187
+
188
+ ## Events (54 v3 event types)
189
+
190
+ Every event is dispatched by name. `client.on('chat', e => ...)` is fully typed end-to-end. Each event payload extends `BaseEvent` (`type`, `timestamp`, `msgId`, optional `protoVersion: 1 | 2 | 3`).
191
+
192
+ ### Core live events
193
+
194
+ | Event | Description |
195
+ |---|---|
196
+ | `connected` | WebSocket open. |
197
+ | `disconnected` | WebSocket close. |
198
+ | `roomInfo` | One-shot post-connect: `{ roomId, wsHost, clusterRegion, connectedAt }`. |
199
+ | `chat` | Chat message. `user`, `comment`, `emotes`, optional `starred`. **v3** adds `language` (auto-detected ISO 639-1) + `messageUuid` (moderation correlation). |
200
+ | `gift` | Virtual gift. `giftId`, `giftName`, `diamondCount`, `repeatCount`, `repeatEnd`, `giftType`. **v3** adds `transactionId` (dedup key), `senderUserId`, `relationship` (`joinDayNumber`, `fromUser`, `toUser`). |
201
+ | `like` | Like batch. `likeCount`, `totalLikes`. |
202
+ | `member` | Viewer joined. **v3** adds `actionCode`, `entrySource` (`"homepage_hot-live_cell"`, `"follow-tab"`, ...), `entryAction` (`"draw"`/`"click"`), `entryType` (`"rec"` = algorithmic). |
203
+ | `social` | Follow / share. |
204
+ | `roomUserSeq` | Periodic viewer count tick. |
205
+ | `subscribe` | A viewer subscribed. |
206
+
207
+ ### PK / battle events
208
+
209
+ | Event | Description |
210
+ |---|---|
211
+ | `battle` | PK lifecycle. `status` (1=ACTIVE, 2=STARTING, 3=ENDED, 4=PREPARING), `battleDuration`, `teams`. **v3** adds `extraHostUserIds`, `layoutSubtype`. |
212
+ | `battleArmies` | Per-host MVP breakdown ticking through the PK. `hosts[].contributors[]` sorted MVP first. **v3** adds `transactionId`. |
213
+ | `battleItemCard` | Booster card: x2 / x3 multipliers, gloves (crit), mist, thunder, extra-time, match-guide. Includes overlay assets from TikTok's CDN. |
214
+ | `battlePunishFinish` | Loser-side punishment screen ended. |
215
+ | `battleNotice` | PK notice (version-mismatch toast, invite-failure). |
216
+ | `battleGameplay` | PK mini-game state (Whack-A-Mole, Tic-Tac-Toe variants). |
217
+ | `linkLayer` | PK / link-mic negotiation (invite, cancel, accept, source change). |
218
+ | `linkMicOpponentGift` | Per-gift breakdown from the OPPONENT side of a PK. |
219
+ | `linkScreenChange` | PK split-screen layout flip (1v1 / 1vN / cohost mode swap). |
220
+ | `cohostLayoutUpdate` | Cohost layout subtype change. |
221
+ | `linkMic`, `linkMicLayoutState`, `link` | Generic link-mic envelopes. |
222
+ | `competition`, `competitionContributor` | Cross-stream competition + per-contributor breakdown. |
223
+ | `guestShowdown` | Guest showdown lifecycle. |
224
+
225
+ ### Native captions (v3)
226
+
227
+ | Event | Description |
228
+ |---|---|
229
+ | `caption` | **NEW in v3.** TikTok native auto-captions on the LIVE WebSocket. `text`, `isFinal`, `startedAtMs`, `endsAtMs`. Independent of the operator-managed [TikTok Live Captions](https://tik.tools/captions) product. |
230
+
231
+ ### Creator-side events
232
+
233
+ | Event | Description |
234
+ |---|---|
235
+ | `goalUpdate` | Stream goal progress (subscriber / gift / watch-time goals). |
236
+ | `commentTray` | Comment tray UI state change. |
237
+ | `roomPin` | A chat got pinned by the host or a moderator. |
238
+ | `hostBoard` | Host leaderboard board update. |
239
+ | `privilegeAdvance` | Viewer privilege tier-up notification with overlay assets. |
240
+ | `anchorToolModification` | Creator modified a panel/widget. |
241
+ | `inRoomBanner` | In-room activity banner. |
242
+ | `roomSticker` | Room-wide sticker drop. |
243
+ | `bottomMessage` | Bottom-bar safety / risk notice. |
244
+ | `accessRecall`, `roomVerify` | Content-classification recheck events. |
245
+ | `smbBoard` | SMB (small-business) board overlay. |
246
+ | `streamStatus` | Stream status flip. |
247
+ | `shareRevenueNotice` | Share-revenue subscriber count change. |
248
+ | `capsule` | TikTok service-plus pin reminder. |
249
+ | `hotRoom` | TikTok promoted the room to a high-traffic slot. |
250
+ | `linkMicAnchorGuide` | Anchor (creator) guide nudges. |
251
+
252
+ ### Moderation / safety
253
+
254
+ | Event | Description |
255
+ |---|---|
256
+ | `imDelete` | Chat moderation delete. Correlate via `chat.messageUuid` (v3). |
257
+ | `unauthorizedMember` | Unauthorized viewer hit a gated feature. |
258
+ | `barrage` | Raw barrage feed (announcements, special effects). |
259
+ | `superFan`, `superFanJoin`, `superFanBox` | Super-fan lifecycle. |
260
+ | `emoteChat` | Inline emote message. |
261
+
262
+ ### Gift catalog + ecommerce
263
+
264
+ | Event | Description |
265
+ |---|---|
266
+ | `giftPanelUpdate` | Real-time gift catalog change. Cache-bust your local catalog. |
267
+ | `giftDynamicRestriction` | Per-room gift availability flip / age-gating. |
268
+ | `giftGallery` | Host-side gift wall snapshot. |
269
+ | `giftUnlock` | Host unlocked a gated gift. |
270
+ | `viewerPicksUpdate` | TikTok-promoted viewer-pick gift highlights. |
271
+ | `oecLiveShopping`, `oecLiveManager`, `oecLiveBillboard` | OEC live-shopping events. |
272
+ | `ecShortItemRefresh` | Lucky-bag drop refreshed. |
273
+
274
+ ### Engagement + AI
275
+
276
+ | Event | Description |
277
+ |---|---|
278
+ | `aiSummary` | TikTok AI summary of the room (entry-time recap, multi-language). |
279
+ | `poll`, `shortTouch` | In-stream poll lifecycle. |
280
+ | `rankText`, `rankUpdate`, `hourlyRank` | Rank events. |
281
+ | `question`, `questionSelected`, `questionSlideDown` | Q&A round events. |
282
+ | `pictionaryUpdate`, `pictionaryEnd`, `pictionaryExit` | Drawing-game round events. |
283
+ | `fansEvent`, `fanTicket` | Fan-club events. |
284
+ | `envelope`, `envelopePortal` | Red-envelope drops + multi-room portal chain. |
285
+ | `gameMoment`, `gameServerFeature` | TikTok Gaming live integration. |
286
+ | `groupLiveMemberNotify` | Group-live member join / leave. |
287
+ | `perception` | Perception event (mute cancel, TikTok hint signal). |
288
+ | `control`, `room`, `liveIntro` | Stream control + room metadata. |
289
+
290
+ ### Catch-all
291
+
292
+ - `event` - Fires for every decoded event (dump-to-queue pattern).
293
+ - `unknown` - Fires when TikTok ships a method we don't yet model (forward-compat hook).
294
+
295
+ All events are fully typed with TypeScript interfaces. Your IDE will show autocompletion for every field. See [full per-event JSON examples + field tables](https://tik.tools/docs).
296
+
297
+ ### Battle / PK example
298
+
299
+ ```typescript
300
+ import { TikTokLive } from 'tiktok-live-api';
301
+
302
+ const client = new TikTokLive({ uniqueId: 'creator_username', apiKey: 'tk_...' });
303
+
304
+ client.on('battle', e => console.log('PK', e.status, e.battleId, 'duration=', e.battleDuration));
305
+
306
+ client.on('battleArmies', e => {
307
+ console.log('Countdown:', e.secsRemaining, 's');
308
+ for (const host of e.hosts ?? []) {
309
+ console.log(`@${host.hostUserId} team total=${host.teamTotalScore}`);
310
+ const mvp = host.contributors[0];
311
+ if (mvp) console.log(` MVP @${mvp.nickname} score=${mvp.score}`);
312
+ }
313
+ });
314
+
315
+ client.on('battleItemCard', e => {
316
+ if (e.multiplier > 0) console.log(`x${e.multiplier} booster from @${e.senderUniqueId}`);
317
+ else console.log(`Effect ${e.effect} from @${e.senderUniqueId} (${e.durationSec}s)`);
318
+ });
319
+
320
+ await client.connect();
321
+ ```
322
+
323
+
324
+ ## Live Captions (Speech-to-Text)
325
+
326
+ Transcribe and translate any TikTok LIVE stream in real-time. **This feature is unique to TikTool Live - no other TikTok library offers it.**
327
+
328
+ ```typescript
329
+ import { TikTokCaptions } from 'tiktok-live-api';
330
+
331
+ const captions = new TikTokCaptions('streamer_username', {
332
+ apiKey: 'YOUR_API_KEY',
333
+ translate: 'en', // translate to English
334
+ diarization: true, // identify who is speaking
335
+ });
336
+
337
+ captions.on('caption', (event) => {
338
+ const speaker = event.speaker ? `[${event.speaker}] ` : '';
339
+ console.log(`${speaker}${event.text}${event.isFinal ? ' āœ“' : '...'}`);
340
+ });
341
+
342
+ captions.on('translation', (event) => {
343
+ console.log(` → ${event.text}`);
344
+ });
345
+
346
+ captions.on('credits', (event) => {
347
+ console.log(`${event.remaining}/${event.total} minutes remaining`);
348
+ });
349
+
350
+ captions.connect();
351
+ ```
352
+
353
+ ### Caption Events
354
+
355
+ | Event | Description | Key Fields |
356
+ |-------|-------------|------------|
357
+ | `caption` | Real-time caption text | `text`, `speaker`, `isFinal`, `language` |
358
+ | `translation` | Translated caption | `text`, `sourceLanguage`, `targetLanguage` |
359
+ | `credits` | Credit balance update | `total`, `used`, `remaining` |
360
+ | `credits_low` | Low credit warning | `remaining`, `percentage` |
361
+ | `status` | Session status | `status`, `message` |
362
+
363
+ ## Chat Bot Example
364
+
365
+ ```typescript
366
+ import { TikTokLive } from 'tiktok-live-api';
367
+
368
+ const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_API_KEY' });
369
+ const giftLeaderboard = new Map<string, number>();
370
+ let messageCount = 0;
371
+
372
+ client.on('chat', (event) => {
373
+ messageCount++;
374
+ const msg = event.comment.toLowerCase().trim();
375
+ const user = event.user.uniqueId;
376
+
377
+ if (msg === '!hello') {
378
+ console.log(`>> BOT: Welcome ${user}! šŸ‘‹`);
379
+ } else if (msg === '!stats') {
380
+ console.log(`>> BOT: ${messageCount} messages, ${giftLeaderboard.size} gifters`);
381
+ } else if (msg === '!top') {
382
+ const top = [...giftLeaderboard.entries()]
383
+ .sort((a, b) => b[1] - a[1])
384
+ .slice(0, 5);
385
+ top.forEach(([name, diamonds], i) => {
386
+ console.log(` ${i + 1}. ${name} - ${diamonds} šŸ’Ž`);
387
+ });
388
+ }
389
+ });
390
+
391
+ client.on('gift', (event) => {
392
+ const user = event.user.uniqueId;
393
+ const diamonds = event.diamondCount || 0;
394
+ giftLeaderboard.set(user, (giftLeaderboard.get(user) || 0) + diamonds);
395
+ });
396
+
397
+ client.connect();
398
+ ```
399
+
400
+ ## TypeScript
401
+
402
+ This package ships with full TypeScript support. All events are typed:
403
+
404
+ ```typescript
405
+ import { TikTokLive, ChatEvent, GiftEvent } from 'tiktok-live-api';
406
+
407
+ const client = new TikTokLive('streamer', { apiKey: 'KEY' });
408
+
409
+ // Full autocompletion - your IDE knows the type of `event`
410
+ client.on('chat', (event: ChatEvent) => {
411
+ console.log(event.user.uniqueId); // āœ“ typed
412
+ console.log(event.comment); // āœ“ typed
413
+ });
414
+
415
+ client.on('gift', (event: GiftEvent) => {
416
+ console.log(event.giftName); // āœ“ typed
417
+ console.log(event.diamondCount); // āœ“ typed
418
+ });
419
+ ```
420
+
421
+ ## API Reference
422
+
423
+ ### `new TikTokLive(uniqueId, options?)`
424
+
425
+ | Option | Type | Default | Description |
426
+ |--------|------|---------|-------------|
427
+ | `apiKey` | `string` | `process.env.TIKTOOL_API_KEY` | Your TikTool API key |
428
+ | `autoReconnect` | `boolean` | `true` | Auto-reconnect on disconnect |
429
+ | `maxReconnectAttempts` | `number` | `5` | Max reconnection attempts |
430
+
431
+ **Methods:**
432
+ - `client.on(event, handler)` - Register event handler
433
+ - `client.off(event, handler)` - Remove event handler
434
+ - `client.connect()` - Connect to stream (returns Promise)
435
+ - `client.disconnect()` - Disconnect from stream
436
+ - `client.connected` - Whether currently connected
437
+ - `client.eventCount` - Total events received
438
+
439
+ ### `new TikTokCaptions(uniqueId, options?)`
440
+
441
+ | Option | Type | Default | Description |
442
+ |--------|------|---------|-------------|
443
+ | `apiKey` | `string` | `process.env.TIKTOOL_API_KEY` | Your TikTool API key |
444
+ | `translate` | `string` | `undefined` | Target translation language |
445
+ | `diarization` | `boolean` | `true` | Enable speaker identification |
446
+ | `maxDurationMinutes` | `number` | `60` | Auto-disconnect timer |
447
+
448
+ **Methods:**
449
+ - `captions.on(event, handler)` - Register event handler
450
+ - `captions.off(event, handler)` - Remove event handler
451
+ - `captions.connect()` - Start receiving captions (returns Promise)
452
+ - `captions.disconnect()` - Stop receiving captions
453
+ - `captions.connected` - Whether currently connected
454
+
455
+ ## Why tiktok-live-api?
456
+
457
+ | | tiktok-live-api | tiktok-live-connector | TikTokLive (Python) |
458
+ |---|---|---|---|
459
+ | **Type** | Managed agency-grade platform | Self-hosted client | Self-hosted client |
460
+ | **Hosting** | āœ“ Fully managed, 99.9% uptime | You run the client; signing via paid backend | You run the client; signing via paid backend |
461
+ | **TypeScript** | āœ“ First-class, fully typed | āœ“ Typed | N/A (Python) |
462
+ | **AI Live Captions (STT + translation)** | āœ“ 60+ languages | āœ— | āœ— |
463
+ | **Unreal Engine plugin** | āœ“ | āœ— | āœ— |
464
+ | **Gifter Intel (LTV, archetypes)** | āœ“ | āœ— | āœ— |
465
+ | **Live Leaderboards (real-time)** | āœ“ Regional + global | āœ— | āœ— |
466
+ | **Battle History + Per-Match Timeline** | āœ“ | āœ— | āœ— |
467
+ | **League Rankings (Diamond Rush)** | āœ“ | āœ— | āœ— |
468
+ | **Real-time Discord + Telegram Alerts** | āœ“ | āœ— | āœ— |
469
+ | **Sniper Gap (live battle tracker)** | āœ“ | āœ— | āœ— |
470
+ | **Agency CRM + Watchlists** | āœ“ | āœ— | āœ— |
471
+ | **Public Profile Pages (creator + gifter)** | āœ“ Indexed | āœ— | āœ— |
472
+ | **CAPTCHA Solving** | āœ“ Built-in (Pro+) | Via signing backend | Via signing backend |
473
+ | **Feed Discovery** | āœ“ See who's live | āœ— | āœ— |
474
+ | **Free Tier** | āœ“ 2,500 req/day, 15 WS, 2h per WS | āœ“ MIT-licensed | āœ“ MIT-licensed |
475
+ | **ESM + CJS** | āœ“ Both supported | āœ“ | N/A (Python) |
476
+
477
+ ## Pricing
478
+
479
+ Tier is enforced server-side by your API key. Snapshot below; the full feature matrix lives at [tik.tools/pricing](https://tik.tools/pricing).
480
+
481
+ | Tier | Weekly | Monthly | Req/min | Req/day | Concurrent WS | WS max duration | Bulk check |
482
+ |---|---|---|---|---|---|---|---|
483
+ | Community | free | free | 5 (300/h) | 2,500 | 1 | 2h | - |
484
+ | Basic | $7 | $19 | 60 | 10,000 | 20 | 8h | 10/req |
485
+ | Pro | $15 | $49 | 300 | 75,000 | 50 | 12h | 50/req |
486
+ | Ultra | $45 | $149 | 1,000 | 300,000 | 250 | 24h | 100/req |
487
+ | **Global Agency** | $119 | $399 | 5,000 | 1,000,000 | 500 | 24h | 200/req |
488
+
489
+ - **Community** ($0 forever): 1 concurrent WS, 2h per session, masked leaderboards. Designed for devs building apps - upgrade when you need real usernames. No datacenter proxies; calls come from your own IP.
490
+ - **Basic** ($7/wk - $19/mo): 60 req/min, 20 concurrent WS, 8h per WS, datacenter proxies, masked leaderboards, **12h/wk - 60h/mo of bundled AI Live Captions**.
491
+ - **Pro** ($15/wk - $49/mo): 300 req/min, 50 concurrent WS, 12h per WS, **unmasked leaderboards**, Feed Discovery, regional leaderboard signed URLs, **30h/wk - 140h/mo of bundled AI Live Captions**.
492
+ - **Ultra** ($45/wk - $149/mo): 1,000 req/min, 250 concurrent WS, 24h per WS, **Gift Catalog API** (full TikTok gift catalog continuously re-synced), **League Rankings unmasked**, CSV exports, 99.5% uptime SLA, **60h/wk - 260h/mo of bundled AI Live Captions**.
493
+ - **Global Agency** ($119/wk - $399/mo): Everything in Ultra plus **Live Gifter Firehose WS** (region / league / global filters + min-diamond threshold), VIP Telegram alerts, VIP Web Vault (unmasked historical visual access), **gifter intel unmasked**, 500 concurrent WS, **120h/wk - 500h/mo of bundled AI Live Captions**.
494
+
495
+ Standalone AI Live Captions plans (no API key needed) on [tik.tools/captions](https://tik.tools/captions): Casual ($7/wk - $29/mo for 12h/wk - 60h/mo), Pro ($15/wk - $59/mo for 30h/wk - 140h/mo), Extreme ($29/wk - $99/mo for 60h/wk - 260h/mo). Auto-renew + early-renewal on exhaust so captions never drop mid-stream.
496
+
497
+ ### Live Gifter Firehose - Global Agency
498
+
499
+ Real-time gift event stream from our Dragonfly fan-out. Filter by region, league, or globally; cap by minimum diamond threshold. Mid-stream filter updates supported via `update_filter` frame, no reconnect needed.
500
+
501
+ ```js
502
+ const ws = new WebSocket(
503
+ `wss://api.tik.tools/firehose/gifters?apiKey=${KEY}&mode=region&region=US%2B&min_diamonds=1000`
504
+ )
505
+ ws.on('message', (raw) => {
506
+ const evt = JSON.parse(raw)
507
+ // evt: { type:'gifter_alert', ts, gifter:{username,displayName,isAnonymous},
508
+ // creator:{uniqueId}, gift:{name,totalDiamonds}, region }
509
+ })
510
+ // Update filter without reconnect
511
+ ws.send(JSON.stringify({ type: 'update_filter', mode: 'global', min_diamonds: 5000 }))
512
+ ```
513
+
514
+ Modes: `global` (all regions), `region` (single region code), `league` (region + league class, e.g. `B2`).
515
+
516
+ ## Also Available
517
+
518
+ - **Python**: [`pip install tiktok-live-api`](https://pypi.org/project/tiktok-live-api/)
519
+ - **Any language**: Connect via WebSocket: `wss://api.tik.tools?uniqueId=USERNAME&apiKey=KEY`
520
+ - **Unreal Engine**: Native C++/Blueprint plugin
521
+
522
+ ## Links
523
+
524
+ - 🌐 **Website**: [tik.tools](https://tik.tools)
525
+ - šŸ“– **Documentation**: [tik.tools/docs](https://tik.tools/docs)
526
+ - šŸ **Python SDK**: [pypi.org/project/tiktok-live-api](https://pypi.org/project/tiktok-live-api/)
527
+ - šŸ’» **GitHub**: [github.com/tiktool/tiktok-live-api](https://github.com/tiktool/tiktok-live-api)
528
+
529
+ ## License
530
+
531
+ MIT
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
- {
2
- "name": "tiktok-live-api",
3
- "version": "1.4.5",
4
- "description": "Unofficial TikTok LIVE API Client - Real-time chat, gifts, viewers, battles, and AI live captions from any TikTok livestream. Managed WebSocket API with 99.9% uptime.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- },
15
- "files": [
16
- "dist",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
- "prepublishOnly": "npm run build"
23
- },
24
- "keywords": [
25
- "tiktok",
26
- "tiktok-live",
27
- "tiktok-api",
28
- "tiktok-live-api",
29
- "tiktok-live-connector",
30
- "tiktok-live-sdk",
31
- "tiktok-websocket",
32
- "tiktok-chat",
33
- "tiktok-gifts",
34
- "tiktok-bot",
35
- "tiktok-data",
36
- "tiktok-stream",
37
- "tiktok-events",
38
- "tiktok-viewer",
39
- "live-streaming",
40
- "live-chat",
41
- "webcast",
42
- "websocket",
43
- "real-time",
44
- "speech-to-text",
45
- "captions",
46
- "transcription",
47
- "translation",
48
- "tiktok-live-python",
49
- "tiktok-tools",
50
- "euler-stream",
51
- "tiktoklive",
52
- "tiktok-connector",
53
- "tiktok-live-node",
54
- "tiktok-live-js",
55
- "tiktok-scraper",
56
- "tiktok-monitoring",
57
- "livestream-api"
58
- ],
59
- "author": {
60
- "name": "TikTool",
61
- "email": "support@tik.tools",
62
- "url": "https://tik.tools"
63
- },
64
- "license": "MIT",
65
- "repository": {
66
- "type": "git",
67
- "url": "https://github.com/tiktool/tiktok-live-api"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/tiktool/tiktok-live-api/issues"
71
- },
72
- "homepage": "https://tik.tools",
73
- "dependencies": {
74
- "ws": "^8.16.0"
75
- },
76
- "devDependencies": {
77
- "@types/ws": "^8.5.10",
78
- "tsup": "^8.0.0",
79
- "typescript": "^5.3.0"
80
- },
81
- "engines": {
82
- "node": ">=16.0.0"
83
- }
84
- }
1
+ {
2
+ "name": "tiktok-live-api",
3
+ "version": "1.4.6",
4
+ "description": "Unofficial TikTok LIVE API Client - Real-time chat, gifts, viewers, battles, and AI live captions from any TikTok livestream. Managed WebSocket API with 99.9% uptime.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "tiktok",
26
+ "tiktok-live",
27
+ "tiktok-api",
28
+ "tiktok-live-api",
29
+ "tiktok-live-connector",
30
+ "tiktok-live-sdk",
31
+ "tiktok-websocket",
32
+ "tiktok-chat",
33
+ "tiktok-gifts",
34
+ "tiktok-bot",
35
+ "tiktok-data",
36
+ "tiktok-stream",
37
+ "tiktok-events",
38
+ "tiktok-viewer",
39
+ "live-streaming",
40
+ "live-chat",
41
+ "webcast",
42
+ "websocket",
43
+ "real-time",
44
+ "speech-to-text",
45
+ "captions",
46
+ "transcription",
47
+ "translation",
48
+ "tiktok-live-python",
49
+ "tiktok-tools",
50
+ "euler-stream",
51
+ "tiktoklive",
52
+ "tiktok-connector",
53
+ "tiktok-live-node",
54
+ "tiktok-live-js",
55
+ "tiktok-scraper",
56
+ "tiktok-monitoring",
57
+ "livestream-api"
58
+ ],
59
+ "author": {
60
+ "name": "TikTool",
61
+ "email": "support@tik.tools",
62
+ "url": "https://tik.tools"
63
+ },
64
+ "license": "MIT",
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "https://github.com/tiktool/tiktok-live-api"
68
+ },
69
+ "bugs": {
70
+ "url": "https://github.com/tiktool/tiktok-live-api/issues"
71
+ },
72
+ "homepage": "https://tik.tools",
73
+ "dependencies": {
74
+ "ws": "^8.16.0"
75
+ },
76
+ "devDependencies": {
77
+ "@types/ws": "^8.5.10",
78
+ "tsup": "^8.0.0",
79
+ "typescript": "^5.3.0"
80
+ },
81
+ "engines": {
82
+ "node": ">=16.0.0"
83
+ }
84
+ }