Skip to main content
All messages are JSON objects sent as text frames. Messages you send have an 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.
"subscribe"
required
Operation name.
string
required
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.
string
required
One of fast-trade, token-details, market-details or ohlcv. Any other value returns UNKNOWN_CHANNEL.
object
required
Channel parameters. The channel validates them. See each channel page for the allowed fields.
string | object
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.
If the subscribe fails, you get an 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. The id can be reused right away.
"unsubscribe"
required
Operation name.
string
required
The id of an active subscription. An unknown id returns NOT_FOUND with message Unknown subscription <id>.

ping

Application-level ping. The server answers with pong.
This is optional. It does not count as a heartbeat answer, since only WebSocket protocol pongs do, and it counts toward the message rate limit. See Heartbeats.

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

string
Random UUID for this connection.
number
Interval between the server’s WebSocket protocol pings, in milliseconds.

subscribed

string
Your subscription id.
string
Channel name.
string
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).
When you resume with since, replayed events follow this message. Live events follow once the replay has caught up.

unsubscribed

string
The subscription that was removed.

event

One matched trade. The shape of data depends on the channel.
string
Your subscription id.
string
Channel name.
string
Position of this trade, <block>-0:<index>. Store it to resume later. Not present for sampled subscriptions.
object
The payload:
Events for one subscription arrive in chain order: by block, then by position in the block.

cursor

A checkpoint. It means the subscription has processed everything up to and including this block, even if nothing in it matched your parameters.
string
Your subscription id.
string
Whole-block cursor, <block>-0.
Checkpoints are sent about every 30 seconds to each live, non-sampled subscription whose position has moved since its last event or checkpoint. Quiet subscriptions get them too, so their stored cursor doesn’t go stale. See Cursors and resuming.

gap

Blocks were skipped upstream. Trades in these blocks were not, and will not be, delivered on this stream.
string
Your subscription id.
string
Channel name.
number
First skipped block, inclusive.
number
Last skipped block, inclusive.
Gaps are sent to sampled subscriptions too. See Gaps for how to backfill them.

error

string
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.
string
Machine-readable code. See the error table.
string
Human-readable description. For validation errors, it lists each problem as field: message, separated by ; .
array | object
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": [...] }.
Errors never close the connection. Connection-level problems are reported with close codes instead. See Limits, close codes and errors.

reconnect

The server is shutting down. Your connection will be closed with code 1012 within about 20 seconds.
No fields. Open a new connection and resubscribe with since set to your latest cursors. See the reconnect loop.

pong

No fields. Reply to {"op":"ping"}.

Sampling with maxUpdatesPerMinute

Every channel accepts an optional maxUpdatesPerMinute 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, 60 gives 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. subscribed and event messages carry no cursor, and no cursor checkpoints are sent.
  • A sampled subscription cannot resume. Sending since together with maxUpdatesPerMinute fails with:
Use sampling for display widgets that only need a periodic refresh. Don’t use it when you need every trade, such as for alerts, trade tapes or anything you want to resume.