Skip to main content
The Orderbook API exposes two WebSocket streams: /ws/depth for live order book depth diffs and /ws/user-events for authenticated order events. Both require authentication. Prerequisites:

Connection

Both streams require a valid JWT in the token query parameter, and take the target markets as a comma-separated list in the books query parameter:
The host is the API base URL for your environment with the wss:// scheme — see environments.
Treat WebSocket URLs as sensitive because they contain the JWT. Avoid logging full URLs in production.

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 — or GET /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.