Skip to main content
Invalid JSON, missing required fields, or unknown methods may disconnect the client with a structured error.

Client messages

subscribe

Subscribes the client to a coin or stream. Subscribe to order book diffs for a coin:
The coin value must be a non-empty string. Subscribing twice to the same coin is safe and idempotent. Subscribe to mempool transactions:
Currently, the only valid stream value is mempool. If the mempool stream is not enabled on the server, the server replies with a non-disconnecting mempool_unavailable error.

unsubscribe

Unsubscribes from a coin or stream.

esp

Upgrades the connection to binary protocol mode.
The version field must match the server binary protocol version. Current binary protocol version: 1. If the version does not match, the client is disconnected with the version_mismatch error.

prime

Enables additional binary streams after esp.
After prime, the client can receive:
  • Ping frames
  • Timing metrics
  • Server error events
prime must be sent after esp. Calling prime before esp disconnects the client with the not_esp error.

unprime

Disables the additional prime streams.
Like prime, this must be called after esp.

JSON mode

JSON mode is the default mode before esp is sent. In this mode, server-to-client frames are text frames containing newline-delimited JSON order book diffs. A single WebSocket frame may contain multiple JSON lines separated by \n. Example:
JSON mode is intended for quick testing and inspection. For production integrations, use binary mode.

Binary mode

After esp, all server-to-client data frames are binary WebSocket frames. The first byte of every frame is a tag that identifies the frame type. All multi-byte integers are little-endian.

Block frame

Tag:
Size:
Block frames are emitted after every block applied by the node. Layout:
Node-side block latency can be calculated as:

TinyOrder frame

Tag:
Size:
TinyOrder frames are emitted for order book diffs on subscribed coins. All strings are length-prefixed with a single u8 byte. The following fields are encoded as UTF-8 decimal strings and should be parsed as text:
  • coin
  • price
  • qty
  • user
Layout:
Both opens and cancels arrive as TinyOrder frames. A full cancel is represented as:
Partial fills are not surfaced as separate events. Instead, the resting order quantity changes.

MempoolTx frame

Tag:
Size:
MempoolTx frames are emitted for mempool transactions when the client is subscribed to the mempool stream. These frames can be large because the payload is length-prefixed with a u32. Layout:

Error frames

Errors are delivered as JSON text frames. Example:
The code field is a stable contract and can be used programmatically. The message field is intended for humans and may change. After prime, clients may also receive informational server error events. These do not necessarily indicate a client-side issue.