op field. Messages the server sends have a type field. In the transcripts below, -> is a message you send and <- is a message from the server.
Unknown extra fields in your messages are ignored.
Client messages
subscribe
Starts a subscription on a channel.Your name for this subscription, 1 to 64 characters from
A-Z a-z 0-9 _ . : - (regex ^[\w.:-]+$). It must not match another active subscription on this connection. The server echoes it on every message for this subscription.One of
fast-trade, token-details, market-details or ohlcv. Any other value returns UNKNOWN_CHANNEL.Channel parameters. The channel validates them. See each channel page for the allowed fields.
Resume position. Either a cursor string such as
"38123457-0:4", or a map with one entry, {"<channel>|<chain>": "<cursor>"}. When set, the server replays what you missed after that cursor before going live. Not allowed together with maxUpdatesPerMinute. See Cursors and resuming.error with the same id, and the id stays free to reuse (except for DUPLICATE_SUBSCRIPTION, where the id belongs to the existing subscription).
unsubscribe
Stops a subscription. Theid can be reused right away.
The
id of an active subscription. An unknown id returns NOT_FOUND with message Unknown subscription <id>.ping
Application-level ping. The server answers withpong.
Server messages
The protocol also defines a
snapshot message type. It is reserved and is never sent on /v1/ws. Ignore unknown message types so that your client keeps working if new ones are added.welcome
subscribed
The subscription’s starting position. For a live subscription it is the current stream position, a whole-block cursor such as
38123456-0. When you resume with since, it is the cursor you sent. Not present for sampled subscriptions (those with maxUpdatesPerMinute).since, replayed events follow this message. Live events follow once the replay has caught up.
unsubscribed
event
One matched trade. The shape ofdata depends on the channel.
Position of this trade,
<block>-0:<index>. Store it to resume later. Not present for sampled subscriptions.cursor
A checkpoint. It means the subscription has processed everything up to and including this block, even if nothing in it matched your parameters.gap
Blocks were skipped upstream. Trades in these blocks were not, and will not be, delivered on this stream.error
The subscription id the error belongs to. Absent when the message itself could not be parsed (invalid JSON, a binary frame, or an envelope that fails validation, such as a bad
id or malformed since). In that case you can’t tell which request failed, so validate id and since on your side before sending.Machine-readable code. See the error table.
Human-readable description. For validation errors, it lists each problem as
field: message, separated by ; .Present on some errors. Validation errors have an array of
{ "field": string, "message": string }. For a subscribe whose params fail, field is the path inside params (for example tokens.0), or "" for a rule that covers several fields. For an envelope error without id, field is the path inside your message (for example id or since). RESUME_EXPIRED has { "retainedFrom": "<block>" }, and Unknown pairs in since has { "pairs": [...] }.reconnect
The server is shutting down. Your connection will be closed with code1012 within about 20 seconds.
since set to your latest cursors. See the reconnect loop.
pong
{"op":"ping"}.
Sampling with maxUpdatesPerMinute
Every channel accepts an optionalmaxUpdatesPerMinute integer from 1 to 600. It turns the subscription into a sampled subscription, which limits how often you receive events.
-
The minimum interval between events is
ceil(60000 / maxUpdatesPerMinute)milliseconds. For example,60gives one event per second at most. -
When the interval has passed, the server sends the first matching trade and drops every other trade until the next interval. It does not send the latest trade, and it does not merge trades. On
ohlcv, a matching trade that produces no event (see ohlcv) still uses up the interval. -
The interval applies separately to each followed item:
-
Sampled subscriptions have no cursors.
subscribedandeventmessages carry nocursor, and nocursorcheckpoints are sent. -
A sampled subscription cannot resume. Sending
sincetogether withmaxUpdatesPerMinutefails with: