tiktok-live-api 1.2.13 → 1.2.15
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/bin/demo.mjs +26 -18
- package/package.json +1 -1
package/bin/demo.mjs
CHANGED
|
@@ -368,7 +368,7 @@ function runScaffold(choice, targetDir, pm) {
|
|
|
368
368
|
'import json',
|
|
369
369
|
'import websockets',
|
|
370
370
|
'',
|
|
371
|
-
'#
|
|
371
|
+
'# \u2500\u2500 Configuration \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500',
|
|
372
372
|
"USERNAME = 'gbnews' # TikTok @username",
|
|
373
373
|
"API_KEY = 'demo_tiktokliveapi_public_2026' # Get yours at https://tik.tools",
|
|
374
374
|
'',
|
|
@@ -376,32 +376,40 @@ function runScaffold(choice, targetDir, pm) {
|
|
|
376
376
|
'async def main():',
|
|
377
377
|
' """Connect to TikTok LIVE and print events."""',
|
|
378
378
|
' uri = f"wss://api.tik.tools?uniqueId={USERNAME}&apiKey={API_KEY}"',
|
|
379
|
-
' print(f"
|
|
379
|
+
' print(f"Connecting to @{USERNAME}...")',
|
|
380
380
|
'',
|
|
381
381
|
' try:',
|
|
382
382
|
' async with websockets.connect(uri) as ws:',
|
|
383
|
-
' print(f"
|
|
383
|
+
' print(f"Connected to @{USERNAME}")',
|
|
384
|
+
' print()',
|
|
384
385
|
' async for raw in ws:',
|
|
385
386
|
' try:',
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
" msg = json.loads(raw)",
|
|
388
|
+
" event = msg.get('event', '')",
|
|
389
|
+
" data = msg.get('data', {})",
|
|
390
|
+
" user = data.get('user', {}).get('uniqueId', '?')",
|
|
390
391
|
'',
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
'
|
|
394
|
-
|
|
395
|
-
'
|
|
396
|
-
|
|
397
|
-
'
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
' print(f"
|
|
392
|
+
" if event == 'chat':",
|
|
393
|
+
" comment = data.get('comment', '')",
|
|
394
|
+
' print(f"[chat] {user}: {comment}")',
|
|
395
|
+
" elif event == 'gift':",
|
|
396
|
+
" gift = data.get('giftName', 'a gift')",
|
|
397
|
+
" count = data.get('repeatCount', 1)",
|
|
398
|
+
' print(f"[gift] {user} sent {gift} x{count}")',
|
|
399
|
+
" elif event == 'like':",
|
|
400
|
+
" total = data.get('totalLikeCount', 0)",
|
|
401
|
+
' print(f"[like] {user} liked (total: {total})")',
|
|
402
|
+
" elif event == 'member':",
|
|
403
|
+
' print(f"[join] {user} joined")',
|
|
404
|
+
" elif event == 'roomUserSeq':",
|
|
405
|
+
" viewers = data.get('viewerCount', 0)",
|
|
406
|
+
' print(f"[viewers] {viewers}")',
|
|
401
407
|
' except json.JSONDecodeError:',
|
|
402
408
|
' pass',
|
|
409
|
+
' except KeyboardInterrupt:',
|
|
410
|
+
' print("Disconnected.")',
|
|
403
411
|
' except Exception as e:',
|
|
404
|
-
' print(f"
|
|
412
|
+
' print(f"Error: {e}")',
|
|
405
413
|
'',
|
|
406
414
|
'',
|
|
407
415
|
'if __name__ == "__main__":',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiktok-live-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
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",
|