REST, live, or replay
Run a live subscription
This Node.js script subscribes to live BTC trades, prints five messages, then unsubscribes and closes. It runs on any plan, including Free.1
Choose the venue family
Pick Hyperliquid core, Hyperliquid Spot, HIP-3, HIP-4, or Lighter before choosing a channel. WebSocket channels lists the channels and symbol formats for each.
2
Start with one channel and one symbol
Confirm the consumer keeps up with one channel-symbol pair. Do not subscribe to every channel by default: a broad set can build a local backlog, stale UI, duplicate subscriptions after a reconnect, or incorrect local books, even when the server accepts every subscription.
3
Handle state changes
Track snapshots, updates, gaps, unsubscribes, and reconnects, and rebuild local state after a reconnect. Keep-alive has the reconnect sequence.
4
Watch lag before widening
Watch consumer lag, queue depth, reconnect count, and gap events before you add channels or symbols.
First events by channel
The socket’sopen event confirms only transport and authentication. A subscription is active only after subscribed arrives; a refused command returns error. The first data event depends on the channel:
- Ordinary channels deliver
datamessages. - L4 channels begin with an
l4_snapshot, then orderedl4_batchmessages. See WebSocket L4 order book. - Live Lighter channels deliver
datawith Lighter payloads: a full top-20 book onlighter_orderbook, two fill legs per trade onlighter_trades, and a market-context object onlighter_open_interestandlighter_funding. See Lighter channels.
unsubscribe, wait for unsubscribed before removing the subscription from local state. After a close, rebuild state on the new connection rather than applying new updates to a book from before the close.
Live Lighter channels
Lighter live subscriptions are available onlighter_orderbook, lighter_trades, lighter_open_interest, and lighter_funding through wss://api.0xarchive.io/ws. lighter_candles and lighter_l3_orderbook are replay-only, and all six Lighter channels support historical replay.
Lighter on Robinhood Chain live subscriptions are available on rh_lighter_orderbook, rh_lighter_trades, rh_lighter_open_interest, and rh_lighter_funding through wss://api.0xarchive.io/ws. rh_lighter_candles is replay-only, and all five Robinhood Chain channels support historical replay.
Use REST for current Lighter candles and L3 depth.