From 1 December 2026, Bitget’s UTA books50 WebSocket channel changes from a full snapshot on every push to incremental updates. The first message after you subscribe is still a full action: "snapshot". Every message after that is an action: "update" with only the levels that changed. The same change applies to the SBE Depth50 channel. It is already live on demo trading.
If your Node.js code treats every books50 message as the complete book, the local book will shrink to the levels in the latest update. This post shows how to merge those updates with bitget-api (3.2.9 at the time of writing). Public depth does not need API keys.
What changes on 1 December
books50: first push after subscribe is a snapshot, later pushes are incremental updates.pseq, which used to be set only on the full-depthbookschannel, is now also set onbooks50so you can detect packet loss.booksis already snapshot then incremental.books1andbooks5still send a full snapshot on every push.- Until 1 December, live
books50still sends a snapshot every time. Code that resets the book onsnapshotand merges onupdateis correct on both sides of the cutover. You can test the new behaviour now withdemoTrading: true.
The official depth docs already describe books50 the new way. Use the UTA update preview for the live date.
Subscribe, reset on snapshot, merge updates
With WebsocketClientV3, subscribe to books50 on the public connection, the same way as in examples/V3 - UTA/Websocket/ws-public.ts. Each depth row has a (asks, price then size, ascending) and b (bids, descending). On a snapshot, replace the local book. On an update, merge by price. Bitget’s SBE docs for this same channel say a level with size 0 has been removed; apply that when you merge JSON updates too.
The SDK types seq and pseq as string | number. Turn them into strings with String() and compare those strings. Equality is a straight ===. The snapshot range check compares length first, then lexicographic order, so it stays correct for long numeric strings.
import { WebsocketClientV3, WS_KEY_MAP } from 'bitget-api';
import type { WsOrderBookDataV3 } from 'bitget-api';
const topic = {
topic: 'books50' as const,
payload: { instType: 'usdt-futures' as const, symbol: 'BTCUSDT' },
};
const ws = new WebsocketClientV3({
// Already live on demo. Pass demoTrading: true to try it before 1 December.
// demoTrading: true,
});
type Side = Map<string, string>;
const asks: Side = new Map();
const bids: Side = new Map();
let lastSeq: string | undefined;
let lastWasSnapshot = false;
let resubscribing = false;
function applyLevels(side: Side, levels: [string, string][]) {
for (const [price, size] of levels) {
if (size === '0') side.delete(price);
else side.set(price, size);
}
}
function toSeq(value: string | number): string {
return String(value);
}
// Non-negative integer strings, no leading zeros: shorter is smaller.
function cmpSeq(a: string, b: string): number {
if (a.length !== b.length) return a.length < b.length ? -1 : 1;
if (a === b) return 0;
return a < b ? -1 : 1;
}
function sequenceOk(row: WsOrderBookDataV3): boolean {
const seq = toSeq(row.seq);
if (lastSeq === undefined) return false;
if (row.pseq === undefined || row.pseq === '') return false;
const pseq = toSeq(row.pseq);
if (lastWasSnapshot) {
// Official: snapshot seq should fall within [pseq, seq] of the first update.
return cmpSeq(lastSeq, pseq) >= 0 && cmpSeq(lastSeq, seq) <= 0;
}
// Official: seq of the previous update must equal pseq of this update.
return pseq === lastSeq;
}
function resetBook() {
asks.clear();
bids.clear();
lastSeq = undefined;
lastWasSnapshot = false;
}
async function resubscribeForSnapshot() {
if (resubscribing) return;
resubscribing = true;
resetBook();
await ws.unsubscribe(topic, WS_KEY_MAP.v3Public);
await ws.subscribe(topic, WS_KEY_MAP.v3Public);
}
interface Books50Event {
action: 'snapshot' | 'update' | string;
arg?: { topic?: string; symbol?: string; instType?: string };
data: WsOrderBookDataV3[];
}
ws.on('update', (event: Books50Event) => {
if (event.arg?.topic !== 'books50') return;
const row = event.data[0];
if (!row) return;
if (event.action === 'snapshot') {
asks.clear();
bids.clear();
applyLevels(asks, row.a);
applyLevels(bids, row.b);
lastSeq = toSeq(row.seq);
lastWasSnapshot = true;
resubscribing = false;
return;
}
if (event.action !== 'update') return;
if (!sequenceOk(row)) {
console.warn('books50 sequence gap, resubscribing', {
lastSeq,
pseq: row.pseq,
seq: row.seq,
});
void resubscribeForSnapshot();
return;
}
applyLevels(asks, row.a);
applyLevels(bids, row.b);
lastSeq = toSeq(row.seq);
lastWasSnapshot = false;
});
ws.on('exception', console.error);
ws.on('reconnected', () => {
// The SDK resubscribes on its own. Clear the book so a stale merge is not applied first.
resetBook();
});
ws.subscribe(topic, WS_KEY_MAP.v3Public);
Check pseq, and resubscribe if there is a gap
Official rules for pseq on books and books50:
- The
seqof one incremental update must equal thepseqof the next incremental update. - After a snapshot, that snapshot’s
seqshould fall within the[pseq, seq]range of the first update that follows it. That first update’spseqis not always equal to the snapshot’sseq. seqon updates should increase, except during symbol maintenance.- After a system release or restart you may see
pseq=0. Snapshot examples also usepseq: 0.
The docs do not spell out a recovery procedure. A new subscribe starts with a full snapshot, so the reliable fix for a gap is to unsubscribe() and subscribe() again, then rebuild from that snapshot. The SDK resubscribes on its own after reconnected; clear the local book there and wait for the new snapshot.
Bitget removed the checksum field from UTA depth channels, including books50, on 19 May 2026. Use seq and pseq to check consistency. Do not expect a checksum on these frames.
rToken symbols
If you use books50 on rToken (tokenized stock) pairs, Bitget’s 13 October 2026 changelog is worth a look. After the matching-engine upgrade, books1 pushes at all times, during and outside market hours. books5, books50 and books push only outside market hours. During market hours, use books1 or the dedicated rToken depth channels if you need more than the top of book.
Checklist
| Symptom | Likely cause | Fix |
|---|---|---|
| Book has only a few levels after the first updates | Each update replaced the book instead of merging |
Reset only on action === 'snapshot'. Merge a and b by price on update, and delete a level when size is 0 |
| Book drifts, or levels look stale | A gap in the incremental stream | Compare pseq with the official rules above, then unsubscribe and subscribe for a fresh snapshot |
No books50 messages during the US session, on an rToken symbol |
Expected: books50 does not push during market hours for those pairs |
Use books1, or the rToken depth channels, while the market is open |
- Do not treat every
books50message as a full book after 1 December (and not on demo now). - Compare
seqandpseqas strings. - Rebuild from a snapshot after a gap and after
reconnected.
Further reading
- Bitget JavaScript SDK: install, clients and examples
- Bitget API JavaScript tutorial: REST and WebSocket clients in more detail
- Siebly docs: the other exchange SDKs from the same maintainers
- Bitget API docs: UTA update preview and the UTA public depth channel
- Related: Bitget WebSocket kline and publicTrade snapshots removed
- REST API vs WebSockets vs WebSocket API: when a public data stream is the right tool
- orderbooks is a generic snapshot and delta store. It has no Bitget-specific adapter in its samples. If you use it, map
action === 'snapshot'tohandleSnapshot(), and map eachupdateintohandleDelta(), with size0levels in the delete list.
