TikTok LIVE chest and bag data API
LIVE rooms that currently have a valid chest or bag, with room_id. Delivered over WebSocket or HTTP polling: first every valid item of the tab, then changes only.
Contents
Pricing and how to rentQuick startData tabsEndpoint and keyHow data is deliveredWebSocketHTTP pollingItem fieldsHandling notesError and close codesLimits and rulesChangelogPricing and how to rent
The API pushes rooms with a valid chest or bag straight into your system, so you do not have to scan TikTok yourself. A good fit for:
- Bot builders (Telegram, Discord…) that post items or join rooms.
- Your own website or app that lists rooms.
- Tools that filter or track rooms by coins, ratio or bag level.
| Tab id | Name | Price for 30 days |
|---|---|---|
c2016 | Chest 20/16 | 2,700,000 coins |
cgold | Gold chests | 2,700,000 coins |
cr1 | Ratio 1 | 2,700,000 coins |
cr2 | Ratio ≥ 2 | 2,700,000 coins |
cr4 | Ratio ≥ 4 | 2,700,000 coins |
chung | Hung chests | 2,700,000 coins |
cluck | Lucky picks | 2,700,000 coins |
b2 | Bags level 2–10 | 2,700,000 coins |
b1 | Bags level 1 | 2,700,000 coins |
b0 | Bags level 0 | 2,700,000 coins |
- Each tab is a separate API, rented 30 days at a time. Renewing adds 30 days to the current expiry.
- You pay from your account wallet balance. If the balance is too low, nothing is charged.
- The system accepts up to 200 running APIs at a time. When full, the rent page tells you and nothing is charged.
How to rent
- Sign in or sign up on the account page.
- Top up your wallet.
- In the Chest and bag data API section, click + Rent an API, pick a tab and pay from the wallet.
- Click Connection details to get your endpoint, key and ready-filled samples.
Rent an API on the account page
Quick start
- Rent an API on the account page to get a key (
lmk_…) and a private endpoint (https://apibot.dichvu321.com/g/…). - Open Connection details for samples with your values filled in, or use the WebSocket and HTTP samples below.
Prefer WebSocket. Use HTTP polling when you cannot hold a long-lived connection. Both return the same data.
Data tabs
Each API is one tab. A key only receives the tab it was rented for. For several tabs, rent several APIs (each has its own key and endpoint).
| Tab id | Name | What the tab contains |
|---|---|---|
c2016 | Chest 20/16 | Counting-down chests with a ratio of 1.2 to 1.25 (for example 20 coins for 16 winners) and at least 20 coins |
cgold | Gold chests | Counting-down gold chests |
cr1 | Ratio 1 | Chests where coins equal the number of winners |
cr2 | Ratio ≥ 2 | Chests with a ratio of 2 or more |
cr4 | Ratio ≥ 4 | Chests with a ratio of 4 or more |
cluck | Lucky picks | Chests with a ratio of 7 or more (many coins, few winners) |
chung | Hung chests | Chests whose open time has passed but are still hanging in the room, kept for up to 15 minutes |
b2 | Bags level 2–10 | Bags that require level 2 to 10 |
b1 | Bags level 1 | Bags that require level 1 |
b0 | Bags level 0 | Bags with no level requirement |
Ratio = coins divided by winners. Except for chung, chest tabs only contain counting-down chests, not hung ones.
Endpoint and key
- Endpoint:
https://apibot.dichvu321.com/g/YOUR_GATE. The part after/g/is your gate code, written asYOUR_GATEhere. - Key: the
Authorization: Bearer lmk_…header on every request. - The API is for scripts and servers, not for direct calls from a browser. Keep the key secret; rotate it on the account page when needed.
How data is delivered
- Snapshot: the first response holds every valid item of the tab, sorted by expiry ascending. Replace your whole list with it.
- Delta:
eventsare new or changed items, upsert byid;removedlists theids to delete. - Reconnecting (or calling
/v1/connectagain) yields a fresh snapshot.
A busy tab can exceed 1,000 items, so a snapshot is roughly 100–500 KB. With HTTP, send Accept-Encoding: gzip.
WebSocket
Connect to wss://apibot.dichvu321.com/g/YOUR_GATE/v1/stream with the Authorization header. The server then sends:
type | When | Content |
|---|---|---|
hello | Right after connecting | tab, server_ms, expires_at (plan expiry, Unix seconds), heartbeat_s |
snapshot | Right after hello, once | seq, server_ms, events (every valid item), removed (empty) |
delta | Whenever something changes, at most every 0.4 s | seq, server_ms, events, removed |
heartbeat | Every 15 seconds | server_ms |
{"type":"hello","tab":"c2016","server_ms":1794265258000,"expires_at":1796857258,"heartbeat_s":15}
{"type":"snapshot","seq":1,"server_ms":1794265258010,"events":[{"id":"chest:7706291234567890123","kind":"chest","room_id":"7706290000000000001","creator":"example_user","total_coins":100,"winner_count":80,"participant_count":null,"viewer_count":112,"ratio":1.25,"opens_at_ms":1794265318000,"expires_at_ms":1794265318000,"chest_type":"normal","chest_status":"active","bag_level":null,"bag_method":null,"bag_comment":null,"country_code":null,"rank_label":null,"event_label":null}],"removed":[]}
{"type":"delta","seq":2,"server_ms":1794265261400,"events":[],"removed":["chest:7706291234567890123"]}
{"type":"heartbeat","server_ms":1794265273000}- The server pings every 15 seconds. If no frame arrives for 45 seconds, reconnect.
- Network drop: reconnect after 1 second, backing off up to 15 seconds. On close codes
4001,4002or4003, stop and do not reconnect automatically (see the code table).
Python
# pip install "websockets>=14"
import asyncio, json, websockets
URL = "wss://apibot.dichvu321.com/g/YOUR_GATE/v1/stream"
HEADERS = {"Authorization": "Bearer lmk_..."}
items = {} # id -> item
def apply(msg):
for e in msg["events"]:
items[e["id"]] = e
for i in msg["removed"]:
items.pop(i, None)
async def main():
delay = 1
while True:
try:
async with websockets.connect(URL, additional_headers=HEADERS, open_timeout=10, max_size=None) as ws:
delay = 1
while True:
msg = json.loads(await asyncio.wait_for(ws.recv(), 45))
if msg["type"] == "snapshot":
items.clear()
apply(msg)
print("snapshot:", len(items))
elif msg["type"] == "delta":
apply(msg)
for e in msg["events"]:
print(e["room_id"], e["creator"], e["total_coins"], e["expires_at_ms"])
except websockets.InvalidStatus as e:
raise SystemExit(f"HTTP {e.response.status_code}") # 401, 402, 403, 404, 423, 429
except websockets.ConnectionClosed as e:
if e.rcvd and e.rcvd.code in (4001, 4002, 4003):
raise SystemExit(f"closed {e.rcvd.code} {e.rcvd.reason}")
except (OSError, TimeoutError):
pass
await asyncio.sleep(delay)
delay = min(delay * 2, 15)
asyncio.run(main())Node.js
// npm i ws
const WebSocket = require("ws");
const URL = "wss://apibot.dichvu321.com/g/YOUR_GATE/v1/stream";
const HEADERS = { Authorization: "Bearer lmk_..." };
const items = new Map();
let delay = 1000;
function connect() {
const ws = new WebSocket(URL, { headers: HEADERS, handshakeTimeout: 10000 });
let timer;
const alive = () => { clearTimeout(timer); timer = setTimeout(() => ws.terminate(), 45000); };
ws.on("open", () => { delay = 1000; alive(); });
ws.on("ping", alive);
ws.on("message", (data) => {
alive();
const msg = JSON.parse(data);
if (msg.type === "snapshot") items.clear();
if (msg.type === "snapshot" || msg.type === "delta") {
for (const e of msg.events) items.set(e.id, e);
for (const id of msg.removed) items.delete(id);
console.log(msg.type, "items:", items.size);
}
});
ws.on("unexpected-response", (req, res) => { console.error("HTTP", res.statusCode); process.exit(1); });
ws.on("error", () => {});
ws.on("close", (code, reason) => {
clearTimeout(timer);
if ([4001, 4002, 4003].includes(code)) { console.error("closed", code, String(reason)); process.exit(1); }
setTimeout(connect, delay);
delay = Math.min(delay * 2, 15000);
});
}
connect();HTTP polling
Base URL: https://apibot.dichvu321.com/g/YOUR_GATE/v1. Every request carries Authorization: Bearer lmk_….
| Step | Request | Result |
|---|---|---|
| 1 | POST /v1/connect | session, tab, poll_ms (3000), lease_s (30), expires_at. Call once at start-up. |
| 2 | GET /v1/eventsX-Session: <session> | First call, without cursor: returns "type":"snapshot" with every valid item and a cursor. |
| 3 | GET /v1/events?cursor=NX-Session: <session> | Every 3 seconds, send the cursor you last received. 200 is a "type":"delta" with a new cursor; 204 means nothing new (keep the same cursor). |
# 1. Open a session
curl -s -X POST "https://apibot.dichvu321.com/g/YOUR_GATE/v1/connect" -H "Authorization: Bearer lmk_..."
# {"session":"Zm9v...","tab":"c2016","poll_ms":3000,"lease_s":30,"expires_at":1796857258}
# 2. First read: every valid item
curl -s --compressed "https://apibot.dichvu321.com/g/YOUR_GATE/v1/events" -H "Authorization: Bearer lmk_..." -H "X-Session: Zm9v..."
# {"type":"snapshot","cursor":8412731,"server_ms":1794265258010,"events":[...],"removed":[]}
# 3. Later reads: changes only
curl -s --compressed -i "https://apibot.dichvu321.com/g/YOUR_GATE/v1/events?cursor=8412731" -H "Authorization: Bearer lmk_..." -H "X-Session: Zm9v..."
# HTTP 204 (nothing new)
# HTTP 200 {"type":"delta","cursor":8412732,"server_ms":1794265261400,"events":[...],"removed":["chest:..."]}- Poll every 3 seconds. Polling too fast returns
429withRetry-After. - After 30 seconds without polling you get
409 session_expired: call/v1/connectagain and read the new snapshot. - Lost response (timeout, network drop): retry with the same cursor; the server returns the same body.
- Always send exactly the
cursoryou last received.
Python
# pip install requests
import time, requests
BASE = "https://apibot.dichvu321.com/g/YOUR_GATE/v1"
H = {"Authorization": "Bearer lmk_...", "User-Agent": "my-system/1.0"}
items = {} # id -> item
http = requests.Session()
def connect():
r = http.post(BASE + "/connect", headers=H, timeout=10)
r.raise_for_status()
return r.json()["session"]
session, cursor = connect(), None
while True:
try:
r = http.get(BASE + "/events", headers={**H, "X-Session": session},
params={"cursor": cursor} if cursor else None, timeout=10)
except requests.RequestException:
time.sleep(1) # retry with the same cursor
continue
if r.status_code == 200:
d = r.json()
if d["type"] == "snapshot":
items.clear()
cursor = d["cursor"]
for e in d["events"]:
items[e["id"]] = e
for i in d["removed"]:
items.pop(i, None)
print(d["type"], "items:", len(items))
elif r.status_code == 204:
pass # nothing new
elif r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", 2)))
continue
elif r.status_code == 409 and r.json().get("code") == "session_expired":
session, cursor = connect(), None
continue
else:
raise SystemExit(f"{r.status_code} {r.text}") # kicked, locked, expired: stop, do not reconnect
time.sleep(3)Node.js
// npm i axios
const axios = require("axios");
const http = axios.create({
baseURL: "https://apibot.dichvu321.com/g/YOUR_GATE/v1",
headers: { Authorization: "Bearer lmk_...", "User-Agent": "my-system/1.0" },
timeout: 10000,
validateStatus: () => true,
});
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const items = new Map();
async function connect() {
const r = await http.post("/connect");
if (r.status !== 200) throw new Error(`connect ${r.status} ${JSON.stringify(r.data)}`);
return r.data.session;
}
(async () => {
let session = await connect(), cursor = null;
for (;;) {
let r;
try {
r = await http.get("/events", { headers: { "X-Session": session }, params: cursor ? { cursor } : {} });
} catch { await sleep(1000); continue; } // retry with the same cursor
if (r.status === 200) {
if (r.data.type === "snapshot") items.clear();
cursor = r.data.cursor;
for (const e of r.data.events) items.set(e.id, e);
for (const id of r.data.removed) items.delete(id);
console.log(r.data.type, "items:", items.size);
} else if (r.status === 429) {
await sleep(Number(r.headers["retry-after"] || 2) * 1000); continue;
} else if (r.status === 409 && r.data.code === "session_expired") {
session = await connect(); cursor = null; continue;
} else if (r.status !== 204) {
throw new Error(`${r.status} ${JSON.stringify(r.data)}`); // kicked, locked, expired
}
await sleep(3000);
}
})();PHP
<?php
// php poll.php
const BASE = "https://apibot.dichvu321.com/g/YOUR_GATE/v1";
const KEY = "lmk_...";
function call(string $method, string $path, string $session = ""): array {
$headers = ["Authorization: Bearer " . KEY, "User-Agent: my-system/1.0"];
if ($session !== "") $headers[] = "X-Session: " . $session;
$ch = curl_init(BASE . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true, CURLOPT_ENCODING => "", CURLOPT_TIMEOUT => 10,
]);
$raw = curl_exec($ch);
if ($raw === false) return [0, null, 1];
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$head = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$retry = preg_match('/^retry-after:\s*(\d+)/mi', substr($raw, 0, $head), $m) ? (int) $m[1] : 2;
return [$status, json_decode(substr($raw, $head), true), $retry];
}
function connect(): string {
[$status, $d] = call("POST", "/connect");
if ($status !== 200) exit("connect $status " . json_encode($d) . "\n");
return $d["session"];
}
$items = []; // id => item
$session = connect();
$cursor = null;
while (true) {
[$status, $d, $retry] = call("GET", "/events" . ($cursor === null ? "" : "?cursor=" . $cursor), $session);
if ($status === 200) {
if ($d["type"] === "snapshot") $items = [];
$cursor = $d["cursor"];
foreach ($d["events"] as $e) $items[$e["id"]] = $e;
foreach ($d["removed"] as $id) unset($items[$id]);
echo $d["type"], " items: ", count($items), "\n";
} elseif ($status === 0) {
sleep(1); continue; // network error: retry with the same cursor
} elseif ($status === 429) {
sleep($retry); continue;
} elseif ($status === 409 && ($d["code"] ?? "") === "session_expired") {
$session = connect(); $cursor = null; continue;
} elseif ($status !== 204) { // 204: nothing new
exit("$status " . json_encode($d) . "\n"); // kicked, locked, expired: stop, do not reconnect
}
sleep(3);
}Go
// go run main.go
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
const base = "https://apibot.dichvu321.com/g/YOUR_GATE/v1"
const key = "lmk_..."
type reply struct {
Type string `json:"type"`
Cursor int64 `json:"cursor"`
Events []map[string]any `json:"events"`
Removed []string `json:"removed"`
Session string `json:"session"`
Code string `json:"code"`
}
var client = &http.Client{Timeout: 10 * time.Second}
func call(method, path, session string) (int, reply, time.Duration) {
var d reply
req, _ := http.NewRequest(method, base+path, nil)
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("User-Agent", "my-system/1.0")
if session != "" {
req.Header.Set("X-Session", session)
}
res, err := client.Do(req)
if err != nil {
return 0, d, time.Second
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
json.Unmarshal(body, &d)
retry, _ := strconv.Atoi(res.Header.Get("Retry-After"))
if retry < 1 {
retry = 2
}
return res.StatusCode, d, time.Duration(retry) * time.Second
}
func connect() string {
status, d, _ := call("POST", "/connect", "")
if status != 200 {
fmt.Println("connect", status, d.Code)
os.Exit(1)
}
return d.Session
}
func main() {
items := map[string]map[string]any{} // id -> item
session, path := connect(), "/events"
for {
status, d, retry := call("GET", path, session)
switch {
case status == 200:
if d.Type == "snapshot" {
clear(items)
}
path = "/events?cursor=" + strconv.FormatInt(d.Cursor, 10)
for _, e := range d.Events {
items[e["id"].(string)] = e
}
for _, id := range d.Removed {
delete(items, id)
}
fmt.Println(d.Type, "items:", len(items))
case status == 204: // nothing new
case status == 0: // network error: retry with the same cursor
time.Sleep(retry)
continue
case status == 429:
time.Sleep(retry)
continue
case status == 409 && d.Code == "session_expired":
session, path = connect(), "/events"
continue
default: // kicked, locked, expired: stop, do not reconnect
fmt.Println(status, d.Code)
os.Exit(1)
}
time.Sleep(3 * time.Second)
}
}cURL
BASE="https://apibot.dichvu321.com/g/YOUR_GATE/v1"
KEY="lmk_..."
# 1) Open a session, once at startup
curl -s -X POST "$BASE/connect" -H "Authorization: Bearer $KEY"
# -> {"session":"...","tab":"...","poll_ms":3000,"lease_s":30,...}
# 2) First call: every item still valid (type "snapshot")
curl -s --compressed "$BASE/events" -H "Authorization: Bearer $KEY" -H "X-Session: SESSION"
# -> {"type":"snapshot","cursor":123456,"events":[...],"removed":[]}
# 3) Then every 3 s: only the changes since the cursor you just got. 204 = nothing new
curl -s --compressed "$BASE/events?cursor=CURSOR" -H "Authorization: Bearer $KEY" -H "X-Session: SESSION"Item fields
| Field | Type | Meaning |
|---|---|---|
id | string | Unique item id, chest:… or bag:…. Use it as the key for updates and removals. |
kind | string | chest (chest) or bag (bag) |
room_id | string | The real TikTok LIVE room id. Always a string, because the number is too large for JavaScript numbers. |
creator | string | Username (uniqueId) of the room owner |
total_coins | int | Total coins in the chest or bag |
winner_count | int | Number of winner slots |
participant_count | int | null | Bags only: number of people who joined. null when not known yet. |
viewer_count | int | null | Current viewers in the room, approximate |
ratio | number | null | total_coins / winner_count, rounded to 4 decimals |
opens_at_ms | int | When the chest or bag opens, Unix milliseconds |
expires_at_ms | int | When the item stops being valid. For counting-down chests and bags it equals opens_at_ms. For hung chests it is opens_at_ms plus 15 minutes. |
chest_type | string | null | normal, gold; null for bags |
chest_status | string | null | active (counting down), hung (hung); null for bags |
bag_level | int | null | Required level of the bag, 0 to 10; null for chests |
bag_method | int | null | How to join the bag: 1 comment, 2 share, 3 tap join |
bag_comment | string | null | The text to comment when bag_method is 1, up to 80 characters |
country_code | string | null | Country code of the room owner, when known |
rank_label | string | null | Rank label of the room owner, when known |
event_label | string | null | Gift name for event chests, when present |
Fields marked null may be empty on first delivery and filled in later by a delta with the same id. New fields may be added in the future; ignore fields you do not know.
Handling notes
- An item can appear in
eventsagain when its numbers change. If you only announce new items, check theidfirst. - Remaining time:
expires_at_ms - now; useserver_msto correct clock drift. - Opening a room:
https://www.tiktok.com/@{creator}/live, or an app deeplink built fromroom_id.
Error and close codes
HTTP errors return JSON {"code":"…","message":"…","message_en":"…"}, sometimes with retry_after (seconds). Branch on code.
| HTTP | code | What it means | What to do |
|---|---|---|---|
| 401 | invalid_key | Wrong key | Check the key |
| 402 | expired | Plan expired | Renew within 7 days to keep the key and endpoint |
| 403 | browser_blocked | Request sent from a web page in a browser | Call from a script or server |
| 403 | revoked | Key revoked | Stop, contact support |
| 404 | — | Wrong endpoint, or the API expired more than 7 days ago and its gate is gone (empty body) | Check the endpoint on the account page. If the hold period has passed, rent again to get a new key and endpoint |
| 409 | kicked | Another stream took over | Stop, do not reconnect automatically |
| 409 | session_expired | Session expired after 30 seconds without polling | Call /v1/connect again |
| 409 | cursor_conflict | Cursor mismatch | Check the client; one reader per key |
| 423 | locked | Key temporarily locked | Wait for retry_after |
| 426 | upgrade_required | Plain GET on /v1/stream | Use wss:// |
| 429 | rate_limited | Too many requests | Wait for Retry-After |
WebSocket close codes
| Code | What it means | What to do |
|---|---|---|
| 4001 | Another stream took over | Stop, do not reconnect automatically |
| 4002 | Plan expired | Renew, then start again |
| 4003 | Key no longer valid or temporarily locked | Stop and check the status on the account page |
| 1012 | Server restarting | Reconnect after a few seconds |
| 1013 | Your side reads too slowly | Reconnect and process items faster |
Limits and rules
- One key, one stream, shared by WebSocket and HTTP. A new stream replaces the running one (
4001or409 kicked); the replaced stream must not reconnect automatically. - Repeated misuse can get the key temporarily locked.
- The data is for one system of yours. No sharing, redistribution or resale; violations lead to revocation without refund.
- Each account can hold 1 key per tab. If you already rent that tab, renew it instead of renting again.
- You can rotate the key at most once every 24 hours, while the API is running. The old key stops working within seconds.
- After expiry, the key and endpoint are kept for 7 more days; renew within that time and everything keeps working. After that the gate is gone (404): rent again to get a new key and endpoint.
Changelog
- 2026-11-11: Added Pricing and how to rent. Clarified limits: 1 key per tab, key rotation, the hold period after expiry and the 404 code.
- 2026-11-10:
country_codeandrank_labelare populated. Added PHP, Go and cURL samples. - 2026-11-10: The snapshot returns every valid item of the tab. HTTP responses carry
type; errors carrymessage_en. - 2026-11-09: API launched.