Guide

TikTok Live WebSocket API

Connect to any TikTok LIVE stream via WebSocket. Receive real-time chat messages, gifts, viewer counts, battles, and engagement data with sub-50ms latency. Works with any programming language.

tiktok.com/@
Stream offlineEnter a live TikTok username above
Connecting to @ live
Offline
Live Stream Monitor
@
<50msLatency
99.9%Uptime
FreeTo Test

How the TikTok Live WebSocket Works

TikTool provides a managed WebSocket endpoint at wss://api.tik.tools that streams real-time events from any TikTok LIVE stream. You connect with your API key and a TikTok username — the server handles all protocol negotiation, authentication, and reconnection logic.

Unlike reverse-engineered solutions that connect directly to TikTok's internal WebCast protocol (and break frequently), TikTool's WebSocket API is a stable, production-grade proxy with 99.9% uptime SLA.

Quick Start — Connect in 3 Lines

JavaScript / Node.js

import { TikTokLive } from '@tiktool/live'

const client = new TikTokLive('streamer_username', { apiKey: 'YOUR_KEY' })
client.on('chat', e => console.log(`${e.user.uniqueId}: ${e.comment}`))
client.connect()

Or connect directly with native WebSocket (no SDK needed):

const ws = new WebSocket('wss://api.tik.tools?uniqueId=USERNAME&apiKey=YOUR_KEY')

ws.onmessage = (msg) => {
  const event = JSON.parse(msg.data)
  console.log(event.event, event.data)
}

Python

import asyncio, websockets, json

async def connect():
    uri = "wss://api.tik.tools?uniqueId=USERNAME&apiKey=YOUR_KEY"
    async with websockets.connect(uri) as ws:
        async for message in ws:
            event = json.loads(message)
            print(event["event"], event.get("data", {}))

Any Language

Any language with WebSocket support works — Go, Rust, Java, C#, Ruby, PHP. Just connect to:

wss://api.tik.tools?uniqueId=TIKTOK_USERNAME&apiKey=YOUR_API_KEY

WebSocket Connection Parameters

ParameterRequiredDescription
uniqueIdTikTok username (without @) of the streamer
apiKeyYour TikTool API key
sessionIdResume a previous session after disconnect

Event Types

Every WebSocket message is a JSON object with event and data fields. Here are the events you'll receive:

chat

New chat message from a viewer. Includes user info, message text, and badges.

gift

Virtual gift sent by a viewer. Includes gift name, diamond value, and repeat count.

like

A viewer liked the stream. Includes total like count.

member

A viewer joined the stream. Fires when users enter the live room.

follow

A viewer followed the streamer during the live stream.

share

A viewer shared the live stream with their friends.

roomUserSeq

Viewer count update. Includes current viewerCount and topViewers.

subscribe

A viewer subscribed to the streamer.

linkMicBattle

Battle/LinkMic event. Includes battle status, scores, and participants.

linkMicArmies

Battle armies update. Team scores and participant rankings.

roomPin

A chat message was pinned by the streamer.

liveIntro

Stream introduction update. Includes stream title and description.

emote

Custom emote sent in chat.

envelope

Treasure chest/envelope event in the stream.

Connection Limits by Tier

TierConnectionsPrice
Sandbox (free)1Free forever
Basic10from $7/week
Pro50from $15/week
Ultra200from $45/week

Error Handling & Reconnection

The WebSocket will close with standard close codes. Your client should handle reconnection:

// Auto-reconnect pattern (Node.js)
function connect() {
  const ws = new WebSocket('wss://api.tik.tools?uniqueId=USERNAME&apiKey=KEY')

  ws.onmessage = (msg) => {
    const event = JSON.parse(msg.data)
    // Process event
  }

  ws.onclose = (e) => {
    console.log(`Disconnected (${e.code}). Reconnecting in 3s...`)
    setTimeout(connect, 3000)
  }

  ws.onerror = (err) => {
    console.error('WebSocket error:', err.message)
    ws.close()
  }
}

connect()

Frequently Asked Questions

How do I connect to a TikTok live stream via WebSocket?

What programming languages work with TikTok Live WebSocket?

Is the TikTok Live WebSocket API free?

How is this different from TikTok-Live-Connector?

What is the latency of the WebSocket connection?