Python
Connection
Raw WebSocket connection pattern.
Replay
Historical playback commands and gap handling.
SDK Responsibilities
An SDK WebSocket helper should reduce boilerplate without hiding stream risk. The caller still needs to know when the socket opened, which channels are active, whether a replay is running, and whether a gap or reconnect made local state unsafe. Use helpers for connection setup, subscription state, typed messages, and reconnection. Keep application-level policy in your code: whether to pause, resync, rebuild a book, retry a replay window, or mark output incomplete. That separation keeps market-data correctness visible in code review.Connection Contract
Use connection callbacks to record stream state instead of treatingconnect() as the whole workflow.
Replay And Gap Callbacks
Historical replay data arrives through replay-specific callbacks, not through the same live subscription callbacks. The typedonHistoricalData callback receives coin, timestamp, and data, but not channel. Use the generic onMessage callback when a multi-channel run or a run manifest must retain the channel field.
speed with the output. Treat the value as the effective speed reported by replay_started; it does not apply to core L4. For core L4, store delivery: checkpoint_anchored_bulk and checkpoint metadata instead. Also retain the l4_snapshot anchor and ordered l4_batch count. Preserve gap callbacks and the output destination for either delivery model. Use WebSocket replay when the event sequence is the product requirement.
For multi-channel replay, send a bounded non-empty channels list with one symbol. The server rejects duplicate channels, mixed exchange families, and core L4 channels in a multi-channel request; core L4 replay is single-channel only. Keep channel and channels mutually exclusive in application code even though the server gives channels precedence when both are sent.
SDK Event Checklist
SDK helpers may wrap raw WebSocket messages, but the underlying event model still matters.
The TypeScript client exposes
l4_snapshot and l4_batch through its generic onMessage handler rather than a dedicated typed L4 callback. Python provides dedicated L4 snapshot and batch callbacks, while Rust delivers decoded server messages through OxArchiveWs.rx. In all runtimes, apply a core L4 snapshot before its ordered batches and rebuild after an unsafe sequence or reconnect.
Testing A Stream
Test with one channel and one symbol before widening. Confirm open, message, close, reconnect, unsubscribe, and gap paths. For standard replay, store the input window andspeed with the output. For core L4, store the input window, delivery model, and checkpoint metadata. For live streams, store the first snapshot timestamp and the latest applied update timestamp.
Bulk WebSocket operation
Some SDK releases still exposestream or multiStream methods for compatibility. The backend currently rejects stream and stream.stop with an error because bulk WebSocket streaming was discontinued. Use the Data Catalog for large file delivery; do not treat a successful socket connection as evidence that this operation is available.
Subscription Methods
Keep helper names tied to venue family.
If a helper does not cover a route family, fall back to the raw WebSocket docs or REST/OpenAPI until the package exposes that route family.
Review Rule
WebSocket helper examples should never end atconsole.log. They should explain what happens after the message arrives: update UI state, append to a replay output, apply a book diff, mark a gap, or trigger a resync.
Pair helpers with tests that simulate close, reconnect, replay snapshots, historical data, gap messages, and terminal replay events. A stream helper should show how the application behaves when history is incomplete, a socket closes, a replay pauses, or a resync starts.