Skip to main content

POST /webcast/ws_credentials

Get pre-signed WebSocket connection credentials for establishing a direct connection to TikTok’s live stream WebSocket servers. Returns everything needed to connect without using the managed proxy. What’s returned: A signed websocket_url (with X-Bogus), cookies (ttwid, session), user_agent, room_id, and cluster_region. Use these to create your own WebSocket connection directly to TikTok. When to use: Advanced users building custom WebSocket clients who need direct TikTok connections (bypassing our proxy). Most users should use the managed WebSocket connection (wss://api.tik.tools) or the Node.js SDK instead. Important: Direct connections count toward TikTok’s per-IP WebSocket limit (~4 concurrent). If you need more, use our managed proxy which distributes connections across multiple IPs.

Parameters

ParameterTypeRequiredDescription
unique_idstringYesTikTok username

Response

{ "status_code": 0, "data": { "ws_url": "wss://...", "cookies": "ttwid=...", "room_id": "...", "ws_host": "...", "cluster_region": "US_TTP" } }

Examples

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