Connection
Connect to the Phoenix WebSocket endpoint: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 atype and subscription envelope:
Supported channels
| Channel | Subscription fields | Response type |
|---|---|---|
allMids | none | AllMidsData |
exchange | optional encoding | ExchangeMessage |
fundingRate | symbol | FundingRateMessage |
orderbook | symbol, optional bypassExecutionBand | L2BookUpdate |
traderState | authority, traderPdaIndex | TraderStateServerMessage |
market | symbol | MarketStatsUpdate |
trades | symbol | TradesMessage |
candles | symbol, timeframe | CandleData |
Control responses
The server confirms successful subscriptions with asubscriptionConfirmed message:
subscriptionError:
error channel:
Market subscriptions
Exchange
Use theexchange 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.
encoding field is optional. Omit it to use the default compressed snapshot response:
encoding to json to receive the initial snapshot as JSON. The examples below are abbreviated to show the fields relevant to cache synchronization:
delta with the next sequenceNumber to your local cache. If a sequence number is skipped, resubscribe and rebuild from a fresh snapshot.
| Delta kind | Sync behavior |
|---|---|
marketAdded | Add or replace the market config in the local market map. |
marketStatusChanged | Update the market’s marketStatus. |
marketClosed | Mark the market as closed and retain the finalized mark price if your client needs settlement context. |
marketTombstoned | Mark the market as tombstoned and stop treating it as tradeable. |
marketDeleted | Remove the market from the local market map. |
marketParameterUpdated | Patch the market’s risk, funding, fee, cap, or commodity metadata fields from the update payload. |
exchangeStatusChanged | Update exchange-level active, gated, and status feature flags. |
exchangeKeysUpdated | Replace exchange-level account and authority keys. |
All mids
Funding rate
Orderbook
SetbypassExecutionBand 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 are1s, 5s, 1m, 5m, 15m, 30m, 1h, 4h, and 1d.
channel set to candle:
Trader subscriptions
Trader state
snapshot or delta payloads.