Skip to main content

POST /webcast/fetch

Fetch live stream events via HTTP long-polling. Returns the same real-time data as WebSocket (chat, gifts, likes, battles) but over HTTP. Uses TikTok’s binary protobuf protocol and returns decoded events. How it works: The API signs and fetches TikTok’s internal polling endpoint, decodes the protobuf response, and returns structured event data. Pass a cursor from the previous response for continuous polling. Identification: Provide either unique_id (username) or room_id. If using unique_id, the server resolves the room ID automatically. WebSocket vs Fetch: WebSocket connections are preferred for real-time use — they deliver events instantly with lower latency. Use /webcast/fetch when WebSocket is not possible (serverless environments, HTTP-only infrastructure) or for one-off data snapshots.

Parameters

ParameterTypeRequiredDescription
unique_idstringNoTikTok username
room_idstringNoRoom ID (alternative to unique_id)
cursorstringNoPagination cursor from previous response

Response

{ "status_code": 0, "data": { "room_id": "...", "alive": true, "message_count": 5, "raw_data": "base64...", "cursor": "" } }

Examples

const res = await fetch('https://api.tik.tools/webcast/fetch?apiKey=YOUR_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ unique_id: 'username' })
});
const { data } = await res.json();
console.log(`Messages: ${data.message_count}`);