Trade
WebSocket

API

WebSocket

Channels, keeping a book, sending actions, every message both ways.

One WebSocket at /ws carries market data, account updates and signed actions. Every frame is one JSON object. The client sends messages with an op; the server sends messages with a type.

Connect and subscribe

On connect the server sends hello. Subscribe to a channel by name:

JSON
{ "op": "subscribe", "channel": "book:SOL-PERP" }

The server answers subscribed, then the channel's messages. Account channels are public by address, like account reads over REST.

Channels

ChannelSends
book:<market>book_snapshot, then book_delta for each change.
trades:<market>trades with snapshot: true (recent trades, newest first), then trades with each new trade.
ticker:<market>ticker as it changes.
candles:<market>:<interval>candle: the current bucket's candle as it changes.
latencylatency: p50 and p99 receive-to-ack over the window.
batchesbatch: the latest, then each new one.
leaderboardleaderboard: the standings as they change.
account:<address>account (summary, positions, orders) as it changes, and account_event for each fill, order change, transfer, funding payment and liquidation.

<market> is one of SOL-PERP, BTC-PERP, ETH-PERP. <interval> is one of 1m, 5m, 15m, 1h, 4h, 1d.

Keeping a book

A book_snapshot carries the whole book and its seq. Each book_delta carries the levels that changed and a prevSeq equal to the seq before it. Apply deltas in order, removing a level whose size is "0". A delta whose prevSeq is not the last seq you applied means you missed one: unsubscribe and subscribe again for a fresh snapshot.

Sending actions

Send a signed action envelope (API) inside an action message:

JSON
{ "op": "action", "action": { "account": "…", "sessionKey": "…", "id": "buy-1", "nonce": 1795451178172, "action": { "type": "place_order", "market": "SOL-PERP", "side": "buy", "kind": "market", "size": "1" }, "signature": "…" } }

The answer is an ack or a reject carrying the envelope's id. A reject's error is the same object REST failures carry, with the same codes.

Client messages

opWhat it does
subscribeStarts a channel.
unsubscribeStops a channel.
actionSends a signed action; the answer is an ack or a reject with the same id.
pingAsks for a pong; the server also pings at the protocol level.
op: "subscribe"
FieldTypeDescription
op"subscribe"
channelstring
op: "unsubscribe"
FieldTypeDescription
op"unsubscribe"
channelstring
op: "action"
FieldTypeDescription
op"action"
actionobject
action.accountaddressthe trading wallet
action.sessionKeyaddressthe session key that signs; registered to `account`
action.idstringthe client's id for this action, echoed on its ack or reject 1 to 64 letters, digits, - or _.
action.nonceintegerepoch ms at signing; accepted within ±ACTION_WINDOW_MS of the server clock, once per session key
action.actionobject, one of several shapes
action.signaturebase64the session key's ed25519 signature over actionMessage(unsigned), base64
op: "ping"
FieldTypeDescription
op"ping"
idoptionalstring

Server messages

typeWhat it carries
helloSent once on connect: mode, chain mode, engine state, contract version, server time.
statusThe engine state changed (live or unreachable).
subscribedA subscribe took effect.
unsubscribedAn unsubscribe took effect.
book_snapshotThe whole book with its seq.
book_deltaChanged levels; size "0" removes a level. prevSeq is the seq it follows.
tradesTrades; the first after subscribing has snapshot: true.
tickerThe market ticker.
candleThe current bucket's candle.
latencyReceive-to-ack figures.
batchA settlement batch.
leaderboardThe standings and the trader count.
accountThe account's summary, positions and orders.
account_eventOne fill, funding payment, transfer, liquidation or order change.
ackAn action was accepted; data is the ack.
rejectAn action was refused; error is the error object, with the same codes as REST.
errorA message the server could not take (bad JSON, an unknown channel), not tied to an action.
pongThe answer to a ping.

Each message's fields:

type: "hello"
FieldTypeDescription
type"hello"
modestring
chainoff | localnet | mainnet
engineconnecting | live | unreachable
contractVersionstring
serverTimeepoch ms
type: "status"
FieldTypeDescription
type"status"
engineconnecting | live | unreachable
serverTimeepoch ms
type: "subscribed"
FieldTypeDescription
type"subscribed"
channelstring
type: "unsubscribed"
FieldTypeDescription
type"unsubscribed"
channelstring
type: "book_snapshot"
FieldTypeDescription
type"book_snapshot"
channelstring
dataobject
data.marketSOL-PERP | BTC-PERP | ETH-PERP
data.seqintegersequence of the last change included; deltas continue from it
data.bidsany[][]
data.asksany[][]
data.atepoch ms
type: "book_delta"
FieldTypeDescription
type"book_delta"
channelstring
dataobject
data.marketstring
data.seqinteger
data.prevSeqinteger
data.bidsany[][]
data.asksany[][]
data.atepoch ms
type: "trades"
FieldTypeDescription
type"trades"
channelstring
snapshotboolean
dataobject[]
data[].idid
data[].marketSOL-PERP | BTC-PERP | ETH-PERP
data[].pricedecimal
data[].sizedecimal
data[].takerSidebuy | sell
data[].ackMicrosinteger µsthe taker order's receive-to-ack time in the engine
data[].ackSourceengine | fixture
data[].atepoch ms
data[].timeISO 8601 UTC
type: "ticker"
FieldTypeDescription
type"ticker"
channelstring
dataobject
data.marketSOL-PERP | BTC-PERP | ETH-PERP
data.indexdecimalmedian of the Coinbase and Kraken tickers
data.markdecimal
data.lastdecimal | null
data.bestBiddecimal | null
data.bestAskdecimal | null
data.fundingRatesigned decimalthis hour's funding rate as a fraction of notional (longs pay when positive)
data.nextFundingAtepoch ms
data.nextFundingTimeISO 8601 UTC
data.volume24hdecimalUSDC notional traded over the last 24 h
data.open24hdecimalthe mark 24 h ago, and the change since as a fraction (0.0123 = +1.23%)
data.change24hsigned decimal
data.openInterestdecimalopen interest in base units (one side)
data.atepoch ms
type: "candle"
FieldTypeDescription
type"candle"
channelstring
dataobject
data.startepoch msbucket start, epoch ms
data.opendecimal
data.highdecimal
data.lowdecimal
data.closedecimal
data.volumedecimalbase units traded
data.notionaldecimalUSDC traded
data.tradesinteger
type: "latency"
FieldTypeDescription
type"latency"
channelstring
dataobject
data.p50Microsinteger µs
data.p99Microsinteger µs
data.samplesinteger
data.windowSecondsinteger
data.sourceengine | fixture
data.atepoch ms
type: "batch"
FieldTypeDescription
type"batch"
channelstring
dataobject
data.numberinteger1 or more.
data.slotinteger | nullthe Solana slot the batch landed in; null while chain is off
data.accountsTouchedinteger
data.stateHashstringhex SHA-256 of the full engine state after the batch
data.signaturesignature | nullthe batch transaction's signature; null while chain is off
data.chainoff | localnet | mainnet
data.atepoch ms
data.timeISO 8601 UTC
type: "leaderboard"
FieldTypeDescription
type"leaderboard"
channelstring
dataobject
data.itemsobject[]
data.items[].rankinteger1 or more.
data.items[].addressaddress
data.items[].filledNotionaldecimal
data.items[].pointsdecimal
data.items[].pnlsigned decimal
data.tradersinteger
data.atepoch ms
type: "account"
FieldTypeDescription
type"account"
channelstring
dataobject
data.summaryobject
data.summary.addressaddress
data.summary.admittedbooleanentered Season Zero with an invite code
data.summary.collateralsigned decimaldeposits + faucet + realized PnL + funding - fees - withdrawals
data.summary.unrealizedPnlsigned decimal
data.summary.equitysigned decimal
data.summary.initialMargindecimalinitial margin of open positions at their chosen leverage
data.summary.maintenanceMargindecimal
data.summary.freeMargindecimalequity - initial margin of positions and resting orders, floored at 0
data.summary.notionaldecimal
data.summary.leverageUseddecimalnotional / equity
data.summary.leverageRecord<string, integer>the chosen leverage per market (1 to max)
data.summary.pointsdecimal
data.summary.rankinteger | null
data.summary.filledNotionaldecimal
data.summary.faucetobject
data.summary.faucet.enabledboolean
data.summary.faucet.amountdecimal
data.summary.faucet.nextClaimAtepoch ms | nullnull when a claim is possible now
data.summary.atepoch ms
data.positionsobject[]
data.positions[].marketSOL-PERP | BTC-PERP | ETH-PERP
data.positions[].sidelong | short
data.positions[].sizedecimalabsolute size in base units
data.positions[].entryPricedecimal
data.positions[].markPricedecimal
data.positions[].notionaldecimal
data.positions[].leverageinteger
data.positions[].initialMargindecimal
data.positions[].maintenanceMargindecimal
data.positions[].unrealizedPnlsigned decimal
data.positions[].realizedPnlsigned decimal
data.positions[].fundingsigned decimalnet funding since the position opened; positive = received
data.positions[].liquidationPricedecimal | nullnull when no price liquidates it
data.positions[].openedAtepoch ms
data.positions[].openedTimeISO 8601 UTC
data.ordersobject[]
data.orders[].orderIdid
data.orders[].clientOrderIdstring | null
data.orders[].marketSOL-PERP | BTC-PERP | ETH-PERP
data.orders[].sidebuy | sell
data.orders[].kindlimit | market
data.orders[].pricedecimal | nullnull for a market order
data.orders[].sizedecimal
data.orders[].filledSizedecimal
data.orders[].remainingSizedecimal
data.orders[].timeInForcegtc | ioc | post_only
data.orders[].reduceOnlyboolean
data.orders[].statusresting | partially_filled | filled | cancelled
data.orders[].atepoch ms
data.orders[].timeISO 8601 UTC
type: "account_event"
FieldTypeDescription
type"account_event"
channelstring
dataobject, one of several shapes
type: "ack"
FieldTypeDescription
type"ack"
idstring
dataobject, one of several shapes
type: "reject"
FieldTypeDescription
type"reject"
idstring
errorobject
error.codestring, one of 39 codes
error.messagestring
error.retryableboolean
error.stagevalidation | auth | read | engine | upload | build | wallet | co_sign | simulation | send | confirmation
error.fieldErrorsoptionalRecord<string, string[]>
error.programErroroptionalobject
error.programError.programIdaddress
error.programError.namestring
error.programError.numberoptionalinteger
error.retryAfterSecondsoptionalinteger
error.requestIdoptionalstring
type: "error"
FieldTypeDescription
type"error"
channeloptionalstring
errorobject
error.codestring, one of 39 codes
error.messagestring
error.retryableboolean
error.stagevalidation | auth | read | engine | upload | build | wallet | co_sign | simulation | send | confirmation
error.fieldErrorsoptionalRecord<string, string[]>
error.programErroroptionalobject
error.programError.programIdaddress
error.programError.namestring
error.programError.numberoptionalinteger
error.retryAfterSecondsoptionalinteger
error.requestIdoptionalstring
type: "pong"
FieldTypeDescription
type"pong"
idoptionalstring
serverTimeepoch ms