@tiktool/live 2.10.0 → 2.10.1

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 +59 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -97,22 +97,42 @@ Install `https-proxy-agent` if using `proxy`:
97
97
  npm install https-proxy-agent
98
98
  ```
99
99
 
100
- ### Mode 2 — Relayed (via our proxy pool, no SDK install)
100
+ ### Mode 2 — Relayed (via our proxy pool)
101
101
 
102
102
  ```
103
- Your App ◀──── wss://api.tik.tools/?uniqueId=X&apiKey=Y ──── tik.tools
104
- │
105
- │ WS via
106
- │ rotated proxies
107
- ▼
108
- TikTok
103
+ Your App ◀──── wss://api.tik.tools/?... ──── tik.tools
104
+ │
105
+ │ WS via
106
+ │ rotated proxies
107
+ ▼
108
+ TikTok
109
109
  ```
110
110
 
111
111
  - **TikTok sees our IPs** (rotated across hundreds of Webshare + residential proxies).
112
112
  - We absorb every per-IP rate-limit hit. Survives any block automatically.
113
113
  - Best for **30+ concurrent streams**, low-budget setups, or anyone who doesn't want their own IP fingerprinted by TikTok.
114
- - Costs slightly more per stream-hour (events stream through us, not signed-once direct).
115
- - No SDK install — plain `WebSocket`. Events arrive pre-parsed as JSON.
114
+
115
+ **Easiest — same SDK, one option:**
116
+
117
+ ```typescript
118
+ import { TikTokLive } from '@tiktool/live';
119
+
120
+ const live = new TikTokLive({
121
+ uniqueId: 'creator_username',
122
+ apiKey: 'YOUR_KEY',
123
+ mode: 'relayed', // ← that's it
124
+ });
125
+
126
+ live.on('chat', e => console.log(`${e.user.uniqueId}: ${e.comment}`));
127
+ live.on('gift', e => console.log(`${e.user.uniqueId} sent ${e.giftName}`));
128
+ live.on('battleArmies', e => console.log(e));
129
+
130
+ await live.connect();
131
+ ```
132
+
133
+ Event names + payload shapes are **identical to Direct mode**. Switch back and forth by toggling `mode`.
134
+
135
+ **Advanced — raw WebSocket (no SDK, your own client):**
116
136
 
117
137
  ```typescript
118
138
  import WebSocket from 'ws';
@@ -124,12 +144,12 @@ const ws = new WebSocket(
124
144
  ws.on('message', raw => {
125
145
  const msg = JSON.parse(raw.toString());
126
146
  if (msg.event === 'chat') console.log(msg.data.user.uniqueId, msg.data.comment);
127
- if (msg.event === 'gift') console.log(msg.data.user.uniqueId, msg.data.giftName, msg.data.diamondCount);
147
+ if (msg.event === 'gift') console.log(msg.data.user.uniqueId, msg.data.giftName);
128
148
  if (msg.event === 'battleArmies') console.log(msg.data);
129
149
  });
130
150
  ```
131
151
 
132
- Event payloads are identical to Direct-mode `client.on('chat', …)` etc. — only the wrapping changes (`{event, data}` envelope vs the SDK's separate emit).
152
+ Use this when integrating from a non-Node runtime (Python, Go, Bun, browser) or when you want absolute control over the connection.
133
153
 
134
154
  ### Side-by-side
135
155
 
@@ -318,6 +338,8 @@ live.on('battle', (e) => {
318
338
  | `heartbeatInterval` | `number` | `10000` | Heartbeat interval (ms) |
319
339
  | `roomId` | `string` | — | Pre-resolved room ID (skips page fetch when paired with `sessionId`) |
320
340
  | `sessionId` | `string` | — | Pre-resolved `ttwid` cookie (skips page fetch when paired with `roomId`) |
341
+ | `proxy` | `string` | — | HTTP(S) proxy URL for Direct mode (e.g. `http://USER:PASS@host:port`). Requires `https-proxy-agent`. |
342
+ | `mode` | `'direct' \| 'relayed'` | `'direct'` | Connection mode. See [Connection Modes](#connection-modes). |
321
343
  | `debug` | `boolean` | `false` | Debug logging |
322
344
 
323
345
  ### Methods
@@ -331,6 +353,32 @@ live.on('battle', (e) => {
331
353
  | `eventCount` | `number` | Total events received |
332
354
  | `roomId` | `string` | Current room ID |
333
355
 
356
+ ### REST endpoints (companion to the WS SDK)
357
+
358
+ For lookups outside the live event stream, hit the sign server directly with your API key:
359
+
360
+ | Endpoint | Method | Tier | Use case |
361
+ |----------|--------|------|----------|
362
+ | `/webcast/room_id` | POST | sandbox+ | `unique_id` → `room_id` |
363
+ | `/webcast/room_info` | POST | sandbox+ | `unique_id` → `room_id` + `alive` + `title` |
364
+ | `/webcast/check_alive` | GET/POST | sandbox+ | Is `room_id` currently live? |
365
+ | `/webcast/bulk_live_check` | POST | basic+ | Batch check up to 500 users in one call |
366
+ | `/webcast/live_status` | GET | sandbox+ | `unique_id` → live snapshot incl. viewer count |
367
+ | `/webcast/user_profile` | GET | **pro+** | **`unique_id` → numeric `id`, `secUid`, nickname, bio, avatars, follower stats** |
368
+ | `/webcast/resolve_user_ids` | POST | sandbox+ | Batch numeric `userId` → `unique_id` (reverse of `user_profile`) |
369
+ | `/webcast/rankings` | GET | sandbox+ | Top gifters / hourly rank for a room |
370
+ | `/webcast/room_video` | POST | basic+ | Get HLS / FLV stream URLs |
371
+ | `/webcast/ws_credentials` | POST | sandbox+ | Get signed WS URL + ttwid (used by Direct mode under the hood) |
372
+
373
+ **Need the streamer's numeric TikTok ID for a username?**
374
+
375
+ ```bash
376
+ curl -H "X-Api-Key: YOUR_KEY" \
377
+ "https://api.tik.tools/webcast/user_profile?unique_id=anyuser"
378
+ ```
379
+
380
+ Returns full profile JSON. Pro tier and above. Cached server-side for 24h — repeated lookups are free and instant.
381
+
334
382
  ---
335
383
 
336
384
  ## Rate Limits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiktool/live",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "TikTok LIVE API Client — Real-time chat, gifts, viewers, PK battles with MVP breakdown, x2/x3 boosters, gloves, mist, match-guide & 20+ event types from any TikTok livestream. Direct WebSocket connection.",
5
5
  "author": "tiktool",
6
6
  "license": "MIT",