/ws/depth for live order book depth diffs and /ws/user-events for authenticated order events. Both require authentication.
Prerequisites:
- A valid JWT — see authentication
- Order book IDs from
GET /books— see market discovery
Connection
Both streams require a valid JWT in thetoken query parameter, and take the target markets as a comma-separated list in the books query parameter:
wss:// scheme — see environments.
Reliable depth handling
For reliable depth handling:1
Connect to the depth stream
Open
/ws/depth for the books you track.2
Buffer diffs while fetching the snapshot
Buffer incoming diffs while fetching the REST depth snapshot from
GET /depth/:orderbookId.3
Apply buffered diffs after the snapshot
Replay the buffered diffs on top of the snapshot to bring the local book current.
4
Continue applying live diffs
Keep applying live diffs as they arrive.
User events
The user-event stream carries order events for the authenticated account. Use it — orGET /orders/:orderId/history — to confirm the final ORDER_CANCELED event after a cancellation request, and to track order events and recover state after reconnects alongside GET /orders.
Reconnects and token expiry
Re-authenticate before each reconnect attempt. Active WebSocket connections are verified at handshake time; a connection can remain open after its original JWT expires.Next steps
Orders
Place orders, then confirm fills and cancellations on the user-event stream.
Market data
Fetch the REST depth snapshot that anchors your snapshot-plus-diff book.
Limits and errors
Meet the production checklist for reconnects, backoff, and book rebuilds.
TypeScript bot client
See a working depth-stream subscription with connection handlers.