@tiktool/live 2.6.4 โ 2.6.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.
- package/README.md +92 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,6 +41,81 @@ await live.connect();
|
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
44
|
+
## ๐ Try It Now โ 60-Second Live Demo
|
|
45
|
+
|
|
46
|
+
Copy-paste this into a file and run it. Connects to a live TikTok stream, prints every event for 60 seconds, then exits. Works on the free Sandbox tier.
|
|
47
|
+
|
|
48
|
+
**Save as `demo.mjs` and run with `node demo.mjs`:**
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
// demo.mjs โ TikTok LIVE in 60 seconds
|
|
52
|
+
// npm install @tiktool/live
|
|
53
|
+
import { TikTokLive } from '@tiktool/live';
|
|
54
|
+
|
|
55
|
+
const API_KEY = 'YOUR_API_KEY'; // Get free key โ https://tik.tools
|
|
56
|
+
const LIVE_USERNAME = 'tv_asahi_news'; // Any live TikTok username
|
|
57
|
+
|
|
58
|
+
const live = new TikTokLive({ uniqueId: LIVE_USERNAME, apiKey: API_KEY });
|
|
59
|
+
let events = 0;
|
|
60
|
+
|
|
61
|
+
live.on('chat', e => { events++; console.log(`๐ฌ ${e.user.uniqueId}: ${e.comment}`); });
|
|
62
|
+
live.on('gift', e => { events++; console.log(`๐ ${e.user.uniqueId} sent ${e.giftName} (${e.diamondCount}๐)`); });
|
|
63
|
+
live.on('like', e => { events++; console.log(`โค๏ธ ${e.user.uniqueId} liked ร ${e.likeCount}`); });
|
|
64
|
+
live.on('member', e => { events++; console.log(`๐ ${e.user.uniqueId} joined`); });
|
|
65
|
+
live.on('follow', e => { events++; console.log(`โ ${e.user.uniqueId} followed`); });
|
|
66
|
+
live.on('share', e => { events++; console.log(`๐ ${e.user.uniqueId} shared`); });
|
|
67
|
+
live.on('roomUserSeq', e => { events++; console.log(`๐ Viewers: ${e.viewerCount}`); });
|
|
68
|
+
live.on('subscribe', e => { events++; console.log(`โญ ${e.user.uniqueId} subscribed`); });
|
|
69
|
+
live.on('battle', e => { events++; console.log(`โ๏ธ Battle update`); });
|
|
70
|
+
|
|
71
|
+
live.on('connected', () => console.log(`\nโ
Connected to @${LIVE_USERNAME} โ listening for 60s...\n`));
|
|
72
|
+
live.on('disconnected', () => console.log(`\n๐ Done! Received ${events} events.\n`));
|
|
73
|
+
|
|
74
|
+
await live.connect();
|
|
75
|
+
setTimeout(() => { live.disconnect(); }, 60_000);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
<details>
|
|
79
|
+
<summary><strong>๐ Pure WebSocket version (no SDK, any language)</strong></summary>
|
|
80
|
+
|
|
81
|
+
Works with any WebSocket client. No dependencies except `ws` (Node.js) or your language's WebSocket library.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
// ws-demo.mjs โ Pure WebSocket, zero SDK
|
|
85
|
+
// npm install ws
|
|
86
|
+
import WebSocket from 'ws';
|
|
87
|
+
|
|
88
|
+
const API_KEY = 'YOUR_API_KEY';
|
|
89
|
+
const LIVE_USERNAME = 'tv_asahi_news';
|
|
90
|
+
|
|
91
|
+
const ws = new WebSocket(`wss://api.tik.tools?uniqueId=${LIVE_USERNAME}&apiKey=${API_KEY}`);
|
|
92
|
+
let events = 0;
|
|
93
|
+
|
|
94
|
+
ws.on('open', () => console.log(`\nโ
Connected to @${LIVE_USERNAME} โ listening for 60s...\n`));
|
|
95
|
+
ws.on('message', (raw) => {
|
|
96
|
+
const msg = JSON.parse(raw);
|
|
97
|
+
events++;
|
|
98
|
+
const d = msg.data || {};
|
|
99
|
+
const user = d.user?.uniqueId || d.uniqueId || '';
|
|
100
|
+
switch (msg.event) {
|
|
101
|
+
case 'chat': console.log(`๐ฌ ${user}: ${d.comment}`); break;
|
|
102
|
+
case 'gift': console.log(`๐ ${user} sent ${d.giftName} (${d.diamondCount}๐)`); break;
|
|
103
|
+
case 'like': console.log(`โค๏ธ ${user} liked ร ${d.likeCount}`); break;
|
|
104
|
+
case 'member': console.log(`๐ ${user} joined`); break;
|
|
105
|
+
case 'roomUserSeq': console.log(`๐ Viewers: ${d.viewerCount}`); break;
|
|
106
|
+
case 'roomInfo': console.log(`๐ก Room: ${msg.roomId}`); break;
|
|
107
|
+
default: console.log(`๐ฆ ${msg.event}`); break;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
ws.on('close', () => console.log(`\n๐ Done! Received ${events} events.\n`));
|
|
111
|
+
|
|
112
|
+
setTimeout(() => ws.close(), 60_000);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</details>
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
44
119
|
## How It Works
|
|
45
120
|
|
|
46
121
|
```
|
|
@@ -202,24 +277,15 @@ wss://api.tik.tools/captions?uniqueId=USERNAME&apiKey=YOUR_KEY&translate=en&diar
|
|
|
202
277
|
|
|
203
278
|
### Caption Credits
|
|
204
279
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
| Tier | Included Credits | Additional Top-Ups |
|
|
208
|
-
|------|-----------------|-------------------|
|
|
209
|
-
| **Free** | 60 min free trial | โ |
|
|
210
|
-
| **Pro** | 2,000 min/month | Available |
|
|
211
|
-
| **Ultra** | 10,000 min/month | Available |
|
|
212
|
-
|
|
213
|
-
**Top-Up Packages:**
|
|
280
|
+
Caption credits are **pay-as-you-go add-ons** โ no credits are included in the base subscription. Requires Basic tier or higher.
|
|
214
281
|
|
|
215
282
|
| Package | Credits | Price | Per Credit |
|
|
216
283
|
|---------|---------|-------|------------|
|
|
217
|
-
| Starter |
|
|
218
|
-
|
|
|
219
|
-
|
|
|
220
|
-
| Whale | 10,000 min | $149.99 | $0.015/min |
|
|
284
|
+
| **Starter** | 1,000 min | $10 | $0.010/min |
|
|
285
|
+
| **Creator** | 5,000 min | $35 | $0.007/min |
|
|
286
|
+
| **Agency** | 20,000 min | $100 | $0.005/min |
|
|
221
287
|
|
|
222
|
-
> **1 credit = 1 minute** of audio transcribed/translated into one language.
|
|
288
|
+
> **1 credit = 1 minute** of audio transcribed/translated into one language. If translating to 2 languages simultaneously, it burns 2 credits per minute.
|
|
223
289
|
|
|
224
290
|
Try the live demo at [tik.tools/captions](https://tik.tools/captions) โ see real-time transcription and translation on actual TikTok LIVE streams.
|
|
225
291
|
|
|
@@ -263,13 +329,19 @@ Try the live demo at [tik.tools/captions](https://tik.tools/captions) โ see re
|
|
|
263
329
|
|
|
264
330
|
All API requests require an API key. Get yours at [tik.tools](https://tik.tools).
|
|
265
331
|
|
|
266
|
-
| Tier | Rate Limit | WS Connections | Bulk Check |
|
|
267
|
-
|
|
268
|
-
| **
|
|
269
|
-
| **
|
|
270
|
-
| **
|
|
332
|
+
| Tier | Requests/Day | Rate Limit | WS Connections | WS Duration | WS Connects | Bulk Check | CAPTCHA | Feed Discovery | Price |
|
|
333
|
+
|------|-------------|-----------|----------------|-------------|-------------|------------|---------|----------------|-------|
|
|
334
|
+
| **Sandbox** | 50 | 5/min | 1 | 60 sec | 10/hr ยท 30/day | 1 | โ | โ | Free |
|
|
335
|
+
| **Basic** | 10,000 | 60/min | 3 | 8 hours | 60/hr ยท 200/day | 10 | โ | โ | From $7/wk |
|
|
336
|
+
| **Pro** | 75,000 | Unlimited | 50 | 8 hours | Unlimited | 50 | 50/day | 100/day | From $15/wk |
|
|
337
|
+
| **Ultra** | 300,000 | Unlimited | 500 | 8 hours | Unlimited | 500 | 500/day | 2,000/day | From $45/wk |
|
|
338
|
+
|
|
339
|
+
**Caption Credits** are available as pay-as-you-go add-ons (1 credit = 1 min of audio in 1 language):
|
|
340
|
+
- **Starter**: 1,000 credits โ $10
|
|
341
|
+
- **Creator**: 5,000 credits โ $35
|
|
342
|
+
- **Agency**: 20,000 credits โ $100
|
|
271
343
|
|
|
272
|
-
The SDK calls the sign server **once per connection**, then stays connected via WebSocket.
|
|
344
|
+
The SDK calls the sign server **once per connection**, then stays connected via WebSocket. Sandbox is for API verification only โ use Basic or higher for production.
|
|
273
345
|
|
|
274
346
|
---
|
|
275
347
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiktool/live",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.6",
|
|
4
4
|
"description": "TikTok LIVE API Client โ Real-time chat, gifts, viewers, live captions (speech-to-text), AI transcription & translation from any TikTok livestream.",
|
|
5
5
|
"author": "tiktool",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,4 +74,4 @@
|
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=18"
|
|
76
76
|
}
|
|
77
|
-
}
|
|
77
|
+
}
|