TypeScript
Python
Track the connection
Pass handlers toconnect() to record stream state, rather than treating a resolved connect() as the whole workflow. onMessage receives every server message, including the ones without a typed callback.
Replay and gap callbacks
Replay data arrives through replay callbacks, not the live subscription callbacks. The typedonHistoricalData callback receives coin, timestamp, and data, but not channel; read channel from onMessage when a multi-channel run or a run manifest needs it.
speed with the output. Treat the value reported by replay_started as the effective speed; speed does not apply to core L4. For core L4, store delivery: checkpoint_anchored_bulk and checkpoint metadata instead. Also keep the l4_snapshot anchor and the count of ordered l4_batch events. Keep gap callbacks and the output destination for either delivery model. WebSocket replay covers the events and controls.
For multi-channel replay, send a non-empty channels list with one symbol. The server refuses duplicate channels, mixed venue families, and L4 channels in a multi-channel request; core L4 replay is single-channel. Keep channel and channels mutually exclusive in your code, even though the server gives channels precedence when both are sent.
What to record
The TypeScript client delivers
l4_snapshot and l4_batch through onMessage rather than a dedicated typed callback. Python has on_l4_snapshot and on_l4_batch, and Rust delivers decoded server messages through OxArchiveWs.rx. In every runtime, apply a core L4 snapshot before its ordered batches and rebuild after an unsafe sequence or reconnect, as in Order-book reconstruction.
Test with one channel and one symbol before widening, and exercise close, reconnect, unsubscribe, replay snapshot, gap, and end-of-replay paths. In your application, replace each console.log above with the real action: update UI state, append to replay output, apply a book diff, mark a gap, or start a resync.
Subscription helpers
For a HIP-4 market, take an active outcome side from
GET /v1/hyperliquid/hip4/outcomes. If a helper does not cover a channel, call ws.subscribe(channel, symbol) or use the raw WebSocket protocol.
Some SDK releases still include stream or multiStream methods. The server refuses stream and stream.stop with an error, because bulk WebSocket streaming is discontinued. For large file delivery, use Data Catalog Parquet exports.