tiktok-live-api 1.0.1 ā 1.1.0
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 +10 -8
- package/dist/index.d.mts +20 -0
- package/dist/index.d.ts +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/tiktok-live-api)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://github.com/tiktool/tiktok-live-api/blob/main/LICENSE)
|
|
9
|
+
[](https://discord.gg/y8TwuFBAmD)
|
|
9
10
|
|
|
10
11
|
> 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).
|
|
11
12
|
|
|
@@ -56,14 +57,14 @@ That's it. **No complex setup, no protobuf, no reverse engineering, no breakages
|
|
|
56
57
|
|
|
57
58
|
---
|
|
58
59
|
|
|
59
|
-
## š Try It Now ā
|
|
60
|
+
## š Try It Now ā 5-Minute Live Demo
|
|
60
61
|
|
|
61
|
-
Copy-paste this into a file and run it. Connects to a live TikTok stream, prints every event for
|
|
62
|
+
Copy-paste this into a file and run it. Connects to a live TikTok stream, prints every event for 5 minutes, then exits. Works on the free Sandbox tier.
|
|
62
63
|
|
|
63
64
|
**Save as `demo.mjs` and run with `node demo.mjs`:**
|
|
64
65
|
|
|
65
66
|
```javascript
|
|
66
|
-
// demo.mjs ā TikTok LIVE in
|
|
67
|
+
// demo.mjs ā TikTok LIVE in 5 minutes
|
|
67
68
|
// npm install tiktok-live-api
|
|
68
69
|
import { TikTokLive } from 'tiktok-live-api';
|
|
69
70
|
|
|
@@ -80,11 +81,11 @@ client.on('member', e => { events++; console.log(`š ${e.user.uniqueId} j
|
|
|
80
81
|
client.on('follow', e => { events++; console.log(`ā ${e.user.uniqueId} followed`); });
|
|
81
82
|
client.on('roomUserSeq', e => { events++; console.log(`š Viewers: ${e.viewerCount}`); });
|
|
82
83
|
|
|
83
|
-
client.on('connected', () => console.log(`\nā
Connected to @${LIVE_USERNAME} ā listening for
|
|
84
|
+
client.on('connected', () => console.log(`\nā
Connected to @${LIVE_USERNAME} ā listening for 5 min...\n`));
|
|
84
85
|
client.on('disconnected', () => console.log(`\nš Done! Received ${events} events.\n`));
|
|
85
86
|
|
|
86
87
|
client.connect();
|
|
87
|
-
setTimeout(() => { client.disconnect(); },
|
|
88
|
+
setTimeout(() => { client.disconnect(); }, 300_000);
|
|
88
89
|
```
|
|
89
90
|
|
|
90
91
|
<details>
|
|
@@ -101,7 +102,7 @@ const LIVE_USERNAME = 'tv_asahi_news';
|
|
|
101
102
|
const ws = new WebSocket(`wss://api.tik.tools?uniqueId=${LIVE_USERNAME}&apiKey=${API_KEY}`);
|
|
102
103
|
let events = 0;
|
|
103
104
|
|
|
104
|
-
ws.on('open', () => console.log(`\nā
Connected to @${LIVE_USERNAME} ā listening for
|
|
105
|
+
ws.on('open', () => console.log(`\nā
Connected to @${LIVE_USERNAME} ā listening for 5 min...\n`));
|
|
105
106
|
ws.on('message', (raw) => {
|
|
106
107
|
const msg = JSON.parse(raw);
|
|
107
108
|
events++;
|
|
@@ -119,7 +120,7 @@ ws.on('message', (raw) => {
|
|
|
119
120
|
});
|
|
120
121
|
ws.on('close', () => console.log(`\nš Done! Received ${events} events.\n`));
|
|
121
122
|
|
|
122
|
-
setTimeout(() => ws.close(),
|
|
123
|
+
setTimeout(() => ws.close(), 300_000);
|
|
123
124
|
```
|
|
124
125
|
|
|
125
126
|
</details>
|
|
@@ -181,6 +182,7 @@ client.connect();
|
|
|
181
182
|
| `subscribe` | New subscriber | `user` |
|
|
182
183
|
| `roomUserSeq` | Viewer count | `viewerCount`, `topViewers` |
|
|
183
184
|
| `battle` | Battle event | `type`, `teams`, `scores` |
|
|
185
|
+
| `roomPin` | Pinned/starred message | `user`, `comment`, `action`, `durationSeconds` |
|
|
184
186
|
| `envelope` | Treasure chest | `diamonds`, `user` |
|
|
185
187
|
| `streamEnd` | Stream ended | `reason` |
|
|
186
188
|
| `connected` | Connected | `uniqueId` |
|
|
@@ -339,7 +341,7 @@ client.on('gift', (event: GiftEvent) => {
|
|
|
339
341
|
|
|
340
342
|
| Tier | Requests/Day | WebSocket Connections | Price |
|
|
341
343
|
|------|-------------|----------------------|-------|
|
|
342
|
-
| Sandbox | 50 | 1 (
|
|
344
|
+
| Sandbox | 50 | 1 (5 min) | Free |
|
|
343
345
|
| Basic | 10,000 | 3 (8h) | $7/week |
|
|
344
346
|
| Pro | 75,000 | 50 (8h) | $15/week |
|
|
345
347
|
| Ultra | 300,000 | 500 (8h) | $45/week |
|
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,25 @@ interface BattleEvent {
|
|
|
60
60
|
teams: Array<Record<string, unknown>>;
|
|
61
61
|
scores: number[];
|
|
62
62
|
}
|
|
63
|
+
/** Payload for `roomPin` (starred/pinned message) events. */
|
|
64
|
+
interface RoomPinEvent {
|
|
65
|
+
/** User who wrote the pinned message. */
|
|
66
|
+
user: TikTokUser;
|
|
67
|
+
/** The pinned comment text. */
|
|
68
|
+
comment: string;
|
|
69
|
+
/** Pin action: 1 = pin, 2 = unpin. */
|
|
70
|
+
action: number;
|
|
71
|
+
/** How long the message stays pinned (seconds). */
|
|
72
|
+
durationSeconds: number;
|
|
73
|
+
/** Timestamp when the message was pinned (ms). */
|
|
74
|
+
pinnedAt: number;
|
|
75
|
+
/** Original message type (e.g. "WebcastChatMessage"). */
|
|
76
|
+
originalMsgType: string;
|
|
77
|
+
/** Original message ID that was pinned. */
|
|
78
|
+
originalMsgId: string;
|
|
79
|
+
/** User ID of the operator who pinned the message. */
|
|
80
|
+
operatorUserId: string;
|
|
81
|
+
}
|
|
63
82
|
/** Payload for `caption` events from {@link TikTokCaptions}. */
|
|
64
83
|
interface CaptionEvent {
|
|
65
84
|
text: string;
|
|
@@ -104,6 +123,7 @@ interface TikTokLiveEventMap {
|
|
|
104
123
|
subscribe: SocialEvent;
|
|
105
124
|
roomUserSeq: RoomUserSeqEvent;
|
|
106
125
|
battle: BattleEvent;
|
|
126
|
+
roomPin: RoomPinEvent;
|
|
107
127
|
envelope: Record<string, unknown>;
|
|
108
128
|
streamEnd: Record<string, unknown>;
|
|
109
129
|
roomInfo: Record<string, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,25 @@ interface BattleEvent {
|
|
|
60
60
|
teams: Array<Record<string, unknown>>;
|
|
61
61
|
scores: number[];
|
|
62
62
|
}
|
|
63
|
+
/** Payload for `roomPin` (starred/pinned message) events. */
|
|
64
|
+
interface RoomPinEvent {
|
|
65
|
+
/** User who wrote the pinned message. */
|
|
66
|
+
user: TikTokUser;
|
|
67
|
+
/** The pinned comment text. */
|
|
68
|
+
comment: string;
|
|
69
|
+
/** Pin action: 1 = pin, 2 = unpin. */
|
|
70
|
+
action: number;
|
|
71
|
+
/** How long the message stays pinned (seconds). */
|
|
72
|
+
durationSeconds: number;
|
|
73
|
+
/** Timestamp when the message was pinned (ms). */
|
|
74
|
+
pinnedAt: number;
|
|
75
|
+
/** Original message type (e.g. "WebcastChatMessage"). */
|
|
76
|
+
originalMsgType: string;
|
|
77
|
+
/** Original message ID that was pinned. */
|
|
78
|
+
originalMsgId: string;
|
|
79
|
+
/** User ID of the operator who pinned the message. */
|
|
80
|
+
operatorUserId: string;
|
|
81
|
+
}
|
|
63
82
|
/** Payload for `caption` events from {@link TikTokCaptions}. */
|
|
64
83
|
interface CaptionEvent {
|
|
65
84
|
text: string;
|
|
@@ -104,6 +123,7 @@ interface TikTokLiveEventMap {
|
|
|
104
123
|
subscribe: SocialEvent;
|
|
105
124
|
roomUserSeq: RoomUserSeqEvent;
|
|
106
125
|
battle: BattleEvent;
|
|
126
|
+
roomPin: RoomPinEvent;
|
|
107
127
|
envelope: Record<string, unknown>;
|
|
108
128
|
streamEnd: Record<string, unknown>;
|
|
109
129
|
roomInfo: Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiktok-live-api",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
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
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|