Stream depth and the trade tape
/ws/market is the public half of the platform: no bearer, no handshake token, no tenant
header. Open it, send two subscribe frames, and you have the live book and every print for
a symbol on one connection.
-
Open the socket
Section titled “Open the socket”Nothing precedes the first subscribe. The TypeScript SDK ships no market-data client, so drive this channel with any WebSocket implementation. Append
?encoding=msgpackto switch server frames to MessagePack — on a busy book it is the cheapest win available.const ws = new WebSocket('wss://api.troncharts.xyz/ws/market')ws.addEventListener('message', (e) => handle(JSON.parse(e.data)))ws.addEventListener('open', () => { /* subscribe here */ }) -
Subscribe to the book
Section titled “Subscribe to the book”venueandsymbolare separate fields; there is novenue:symbolstring on the wire. You getResult { ok: true }, and aDepth-Updatesnapshot immediately after it when the server’s cache is already warm. Depth serveshyperliquid,aster,lighter,polymarket,kalshi,massiveandb3.{ "type": "Subscribe-Depth", "venue": "hyperliquid", "symbol": "BTC.HL" }Every level is
{ px, sz }as decimal strings, plusct— the resting-order count — on the venues that expose one.{ "type": "Depth-Update", "venue": "hyperliquid", "symbol": "BTC.HL","bids": [{ "px": "64210.0", "sz": "1.842" }],"asks": [{ "px": "64211.5", "sz": "0.311" }],"source": "be_canonical", "ts": "2026-08-04T12:00:00.000Z" } -
Subscribe to the tape
Section titled “Subscribe to the tape”The tape’s venue set is narrower than depth’s —
hyperliquid,aster,massive,b3, the four with a trade-print producer. Asking for any other venue is rejected asinvalid_framerather than accepted and left silently blank.{ "type": "Subscribe-Tape", "venue": "hyperliquid", "symbol": "BTC.HL" }Handle both wire shapes. Prints are batched into a
tradesarray — one frame per flush window, not per print, because B3 alone was measured at 612 prints per second — while the legacy flattened single-print frame is still part of the contract.function onTape(f) {const prints = 'trades' in f ? f.trades : [f]for (const p of prints) console.log(p.side, p.px, p.sz, p.ts)} -
Add the channels you need
Section titled “Add the channels you need”The same socket multiplexes
Subscribe-Depth-L3for the per-order book (lighterandb3only) →Order-Book-Update,Subscribe-BBO→BBO-Update,Subscribe-VAP→VAP-Update, andSubscribe-Candleswith anintervalwritten as a count pluss,m,h,d,worM(1m,4h,1d) →Candle-Update. Each has a matchingUnsubscribe-*,Unsubscribe-Alldrops everything, andPinganswersPong. Past the per-socket subscription cap you getResult { ok: false, error: "subscription_limit" }.
Next: Market channel · Market data · Stream account and position updates