Skip to main content

Connection

Connect to the Phoenix WebSocket endpoint:
The Rust SDK uses PHOENIX_WS_URL when it is set. Otherwise, it derives the WebSocket URL from PHOENIX_API_URL by switching http to ws and using /v1/ws. Messages are UTF-8 JSON objects.

Client messages

Subscribe with a type and subscription envelope:
Unsubscribe with the same subscription object:

Supported channels

Control responses

The server confirms successful subscriptions with a subscriptionConfirmed message:
Subscription-level errors use subscriptionError:
Server errors use the error channel:

Market subscriptions

Exchange

Use the exchange channel to keep local exchange and market-parameter metadata in sync. The server sends an initial snapshot followed by ordered deltas when exchange keys, exchange status, markets, or market parameters change.
The encoding field is optional. Omit it to use the default compressed snapshot response:
Set encoding to json to receive the initial snapshot as JSON. The examples below are abbreviated to show the fields relevant to cache synchronization:
After the snapshot, apply each delta with the next sequenceNumber to your local cache. If a sequence number is skipped, resubscribe and rebuild from a fresh snapshot.
Handle exchange deltas as cache mutations:

All mids

Funding rate

Orderbook

Set bypassExecutionBand to true to receive the full orderbook during commodities after-hours, including price levels outside the tradeable execution band.

Market stats

Trades

Candles

Supported timeframes are 1s, 5s, 1m, 5m, 15m, 30m, 1h, 4h, and 1d.
The server sends candle updates with channel set to candle:

Trader subscriptions

Trader state

Trader state messages are either snapshot or delta payloads.