Public market prices use a separate socket: Market data.
Subscribe
Send one frame after the upgrade:INVALID_SUBSCRIPTION. A subscription your key may not use
closes with SUBSCRIPTION_DENIED. There is no unsubscribe: close the socket.
Frames
Every server frame is{ "channel": ..., "data": ... }.
event_type selects the shape of payload. Ignore event types you do not recognize.
Snapshot
The snapshot is your current state and the cursor it matches. Replace your local state with it, then apply events after that cursor. A class cut short is listed intruncated with the route that pages
the rest:
href with a {placeholder} is per resource: fill it in for each item. Balances, positions and maker capital are not snapshot
classes: read them over HTTP when you connect, and again on their events.
Apply events
- Delivery is at least once. Skip an event whose
event_idyou have seen, or whosecursor.sequenceis not above yours. - Apply events in
sequenceorder. Sequences skip numbers; a skipped number is not a gap. - Save the event’s
cursorafter you apply it.
Resume
Send your last applied cursor. Resuming needsreplay:read.
The stream is the only replay; there is no HTTP event log. The replay window is on
Limits.
Heartbeats, drain and reset
- The server sends a WebSocket ping every
heartbeat_interval_ms. Answer with a pong within 5 seconds, or the server drops the connection. - Most WebSocket APIs answer pings for you and never show them, so a ping can’t tell you a socket died. Subscribe with
publication_freshness: trueand treat a few missed heartbeats as a dead socket: close it and resume from your cursor. Give up the same way on a connect whosesubscriptionResponsedoesn’t arrive. The SDK does both. - On
drain, open a new connection, resume from your cursor, then close the old one. The server closes it withCONNECTION_DRAINbydeadline. - On
reset, discard local state and reconnect without a cursor.
retry says what
to do:
An account holds at most 4 open streams. With an API key, a fifth is refused with
429 and Retry-After. A wallet
session’s fifth replaces its oldest, which closes with STREAM_REPLACED. A dropped stream can hold its slot for up
to 30 seconds.
