Documentation Index
Fetch the complete documentation index at: https://tiktools.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Connection URL
wss://api.tik.tools?uniqueId=TIKTOK_USERNAME&apiKey=YOUR_API_KEY
Query Parameters
| Parameter | Type | Required | Description |
|---|
uniqueId | string | Yes | TikTok username (without @) |
apiKey | string | Yes* | Your API key (*or use jwtKey) |
jwtKey | string | Yes* | JWT token for frontend auth (*or use apiKey) |
Connection Example
import WebSocket from 'ws';
const ws = new WebSocket('wss://api.tik.tools?uniqueId=streamer&apiKey=YOUR_KEY');
ws.on('open', () => console.log('Connected!'));
ws.on('message', (raw) => {
const { event, data } = JSON.parse(raw);
switch (event) {
case 'roomInfo': console.log('Room:', data.roomId); break;
case 'chat': console.log(data.user.uniqueId + ':', data.comment); break;
case 'gift': console.log(data.user.uniqueId, 'sent', data.giftName); break;
case 'like': console.log(data.user.uniqueId, 'liked ×' + data.likeCount); break;
case 'member': console.log(data.user.uniqueId, 'joined'); break;
}
});
ws.on('close', (code, reason) => console.log('Closed:', code, reason.toString()));
Every WebSocket message is a JSON object with:
{
"event": "chat",
"data": {
"type": "chat",
"user": {
"uniqueId": "viewer123",
"nickname": "Cool Viewer",
"userId": "6892636847263982593",
"profilePictureUrl": "https://..."
},
"comment": "Hello streamer!"
}
}
First Event: roomInfo
The first event you receive after connecting is always roomInfo with the room metadata:
{
"event": "roomInfo",
"roomId": "71234567890",
"uniqueId": "streamer",
"roomInfo": {
"title": "Stream Title",
"user_count": 1234,
"like_count": 5678,
"owner": { "nickname": "Streamer", "uniqueId": "streamer" }
}
}
Connection Limits
| Tier | Max Connections | Max Duration |
|---|
| Sandbox | 1 | 5 minutes |
| Basic | 5 | 30 minutes |
| Pro | 50 | Unlimited |
| Ultra | 500 | Unlimited |
Reconnection
If the WebSocket disconnects, implement exponential backoff:
let reconnectDelay = 1000;
function connect() {
const ws = new WebSocket('wss://api.tik.tools?uniqueId=streamer&apiKey=KEY');
ws.on('open', () => {
reconnectDelay = 1000; // Reset on successful connection
});
ws.on('close', (code) => {
if (code !== 4003) { // Don't reconnect on auth errors
setTimeout(connect, reconnectDelay);
reconnectDelay = Math.min(reconnectDelay * 2, 30000);
}
});
}
See Close Codes for all possible close reasons.