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 Copy { " 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
Channel Sends 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 Copy { " 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
op What 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"
Field Type Description op"subscribe"channelstring
op: "unsubscribe"
Field Type Description op"unsubscribe"channelstring
op: "action"
Field Type Description op"action"actionobjectaction.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 shapesaction.signaturebase64the session key's ed25519 signature over actionMessage(unsigned), base64
op: "ping"
Field Type Description op"ping"idoptional string
Server messages
type What 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"
Field Type Description type"hello"modestringchainoff | localnet | mainnetengineconnecting | live | unreachablecontractVersionstringserverTimeepoch ms
type: "status"
Field Type Description type"status"engineconnecting | live | unreachableserverTimeepoch ms
type: "subscribed"
Field Type Description type"subscribed"channelstring
type: "unsubscribed"
Field Type Description type"unsubscribed"channelstring
type: "book_snapshot"
Field Type Description type"book_snapshot"channelstringdataobjectdata.marketSOL-PERP | BTC-PERP | ETH-PERPdata.seqintegersequence of the last change included; deltas continue from it data.bidsany[][]data.asksany[][]data.atepoch ms
type: "book_delta"
Field Type Description type"book_delta"channelstringdataobjectdata.marketstringdata.seqintegerdata.prevSeqintegerdata.bidsany[][]data.asksany[][]data.atepoch ms
type: "trades"
Field Type Description type"trades"channelstringsnapshotbooleandataobject[]data[].ididdata[].marketSOL-PERP | BTC-PERP | ETH-PERPdata[].pricedecimaldata[].sizedecimaldata[].takerSidebuy | selldata[].ackMicrosinteger µsthe taker order's receive-to-ack time in the engine data[].ackSourceengine | fixturedata[].atepoch msdata[].timeISO 8601 UTC
type: "ticker"
Field Type Description type"ticker"channelstringdataobjectdata.marketSOL-PERP | BTC-PERP | ETH-PERPdata.indexdecimalmedian of the Coinbase and Kraken tickers data.markdecimaldata.lastdecimal | nulldata.bestBiddecimal | nulldata.bestAskdecimal | nulldata.fundingRatesigned decimalthis hour's funding rate as a fraction of notional (longs pay when positive) data.nextFundingAtepoch msdata.nextFundingTimeISO 8601 UTCdata.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 decimaldata.openInterestdecimalopen interest in base units (one side) data.atepoch ms
type: "candle"
Field Type Description type"candle"channelstringdataobjectdata.startepoch msbucket start, epoch ms data.opendecimaldata.highdecimaldata.lowdecimaldata.closedecimaldata.volumedecimalbase units traded data.notionaldecimalUSDC traded data.tradesinteger
type: "latency"
Field Type Description type"latency"channelstringdataobjectdata.p50Microsinteger µsdata.p99Microsinteger µsdata.samplesintegerdata.windowSecondsintegerdata.sourceengine | fixturedata.atepoch ms
type: "batch"
Field Type Description type"batch"channelstringdataobjectdata.numberinteger1 or more. data.slotinteger | nullthe Solana slot the batch landed in; null while chain is off data.accountsTouchedintegerdata.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 | mainnetdata.atepoch msdata.timeISO 8601 UTC
type: "leaderboard"
Field Type Description type"leaderboard"channelstringdataobjectdata.itemsobject[]data.items[].rankinteger1 or more. data.items[].addressaddressdata.items[].filledNotionaldecimaldata.items[].pointsdecimaldata.items[].pnlsigned decimaldata.tradersintegerdata.atepoch ms
type: "account"
Field Type Description type"account"channelstringdataobjectdata.summaryobjectdata.summary.addressaddressdata.summary.admittedbooleanentered Season Zero with an invite code data.summary.collateralsigned decimaldeposits + faucet + realized PnL + funding - fees - withdrawals data.summary.unrealizedPnlsigned decimaldata.summary.equitysigned decimaldata.summary.initialMargindecimalinitial margin of open positions at their chosen leverage data.summary.maintenanceMargindecimaldata.summary.freeMargindecimalequity - initial margin of positions and resting orders, floored at 0 data.summary.notionaldecimaldata.summary.leverageUseddecimalnotional / equity data.summary.leverageRecord<string, integer>the chosen leverage per market (1 to max) data.summary.pointsdecimaldata.summary.rankinteger | nulldata.summary.filledNotionaldecimaldata.summary.faucetobjectdata.summary.faucet.enabledbooleandata.summary.faucet.amountdecimaldata.summary.faucet.nextClaimAtepoch ms | nullnull when a claim is possible now data.summary.atepoch msdata.positionsobject[]data.positions[].marketSOL-PERP | BTC-PERP | ETH-PERPdata.positions[].sidelong | shortdata.positions[].sizedecimalabsolute size in base units data.positions[].entryPricedecimaldata.positions[].markPricedecimaldata.positions[].notionaldecimaldata.positions[].leverageintegerdata.positions[].initialMargindecimaldata.positions[].maintenanceMargindecimaldata.positions[].unrealizedPnlsigned decimaldata.positions[].realizedPnlsigned decimaldata.positions[].fundingsigned decimalnet funding since the position opened; positive = received data.positions[].liquidationPricedecimal | nullnull when no price liquidates it data.positions[].openedAtepoch msdata.positions[].openedTimeISO 8601 UTCdata.ordersobject[]data.orders[].orderIdiddata.orders[].clientOrderIdstring | nulldata.orders[].marketSOL-PERP | BTC-PERP | ETH-PERPdata.orders[].sidebuy | selldata.orders[].kindlimit | marketdata.orders[].pricedecimal | nullnull for a market order data.orders[].sizedecimaldata.orders[].filledSizedecimaldata.orders[].remainingSizedecimaldata.orders[].timeInForcegtc | ioc | post_onlydata.orders[].reduceOnlybooleandata.orders[].statusresting | partially_filled | filled | cancelleddata.orders[].atepoch msdata.orders[].timeISO 8601 UTC
type: "account_event"
Field Type Description type"account_event"channelstringdataobject, one of several shapes
type: "ack"
Field Type Description type"ack"idstringdataobject, one of several shapes
type: "reject"
Field Type Description type"reject"idstringerrorobjecterror.codestring, one of 39 codeserror.messagestringerror.retryablebooleanerror.stagevalidation | auth | read | engine | upload | build | wallet | co_sign | simulation | send | confirmationerror.fieldErrorsoptional Record<string, string[]>error.programErroroptional objecterror.programError.programIdaddresserror.programError.namestringerror.programError.numberoptional integererror.retryAfterSecondsoptional integererror.requestIdoptional string
type: "error"
Field Type Description type"error"channeloptional stringerrorobjecterror.codestring, one of 39 codeserror.messagestringerror.retryablebooleanerror.stagevalidation | auth | read | engine | upload | build | wallet | co_sign | simulation | send | confirmationerror.fieldErrorsoptional Record<string, string[]>error.programErroroptional objecterror.programError.programIdaddresserror.programError.namestringerror.programError.numberoptional integererror.retryAfterSecondsoptional integererror.requestIdoptional string
type: "pong"
Field Type Description type"pong"idoptional stringserverTimeepoch ms