Go deeperAPI reference
Go deeper

API reference

The terminal is a client of a small HTTP API on the same origin. Market data and pool state are public. Anything that acts for a wallet needs that wallet's session, and nothing here can move funds without a transaction the wallet signs.

Conventions

  • JSON in, JSON out, same origin as the site. Request bodies are application/json and at most 4 KiB.
  • Amounts are decimal strings, never floats. Token amounts are raw tokens to eight places, USDC to six.
  • Requests that change anything must carry this site's own Origin.
  • Responses are never cached: Cache-Control: no-store.
  • Errors always have the same shape: { "error": { "code", "message" } }. The message is written for people.

Public data

MethodPathReturns
GET/api/market-dataEvery market: reference price, its source and age, session and calendar, mint, decimals, multiplier, mint verification, OPEN or STALE with the reason, and price history. Add ?chart= and a market ID to receive only that market's history.
GET/api/settlementThe OPmode markets: network, program, market account and readiness for each, with the reason when a market is not ready, and the current Pyth reference price with its source time. Adding ?market={id} also asks for a fresh on-chain reference for that market.
GET/api/settlement/liquidity?market={id}One pool's vault balances, total shares and fee share, read at a slot. Signed in, it adds your shares and balances.
GET/api/healthWhether the database and the pricing engine are up, and how many markets have a usable reference. 503 when the database or engine is down.

Market IDs are lower-case tickers without the x, and without the dot for BRK.Bx (brkb). The ten OPmode markets are nvda, spy, qqq, gld, tsla, aapl, msft, meta, coin and crcl.

Wallet session

MethodPathPurpose
POST/api/wallet/nonceBody: address. Returns a sign-in challenge, valid five minutes, usable once.
POST/api/wallet/verifyBody: challengeId, address, publicKey, signedMessage, signature (bytes as base64). Opens a seven-day session.
GET/api/wallet/sessionWho is signed in, and their eligibility status.
POST/api/wallet/eligibilityBody: accepted, country, termsVersion, countryPolicyVersion.
GET/api/wallet/balancesSOL, USDC and stock tokens for the signed-in address, read at one slot.
POST/api/wallet/logoutRevokes the session.

Quick orders

MethodPathPurpose
POST/api/live/ordersBody: marketId, side (buy or sell), cash (USDC or SOL, the side that is not the stock; default USDC), inputAmount, requestKey (UUID), slippageBps (1 to 300; the terminal sends 50). Returns an estimated output, minimum received and unsigned transaction.
POST/api/live/orders/{id}/executeBody: signedTransaction (base64). Submits the saved order's wallet-signed transaction.
GET/api/live/orders/{id}Refreshes status, signature and explorer link.
GET/api/live/ordersThe wallet's saved Quick orders.

OPmode orders

Check /api/settlement first. A market whose readiness is not READY cannot be quoted.

MethodPathPurpose
POST/api/settlement/ordersBody: marketId, side (BUY or SELL), inputAmount, requestKey (a UUID you generate). Returns a firm quote and the unsigned transaction.
POST/api/settlement/orders/{id}/executeBody: signedTransaction (base64). Submits exactly those bytes.
GET/api/settlement/orders/{id}Current status, signature, receipt address and explorer link.
POST/api/settlement/orders/{id}/recoverRe-checks an order whose outcome is unknown.
GET/api/settlement/ordersThe wallet's recent orders, newest first.

Pool deposits and withdrawals

MethodPathPurpose
POST/api/settlement/liquidity/ordersBody: marketId, kind (DEPOSIT or WITHDRAW), inputAmount (USDC for a deposit, shares for a withdrawal), requestKey. Returns the estimated amounts, the minimums and maximums written into the transaction, and the unsigned transaction.
POST/api/settlement/liquidity/orders/{id}/executeBody: signedTransaction (base64).
GET/api/settlement/liquidity/orders/{id}Current status and explorer link.
POST/api/settlement/liquidity/orders/{id}/recoverRe-checks a transaction whose outcome is unknown.
GET/api/settlement/liquidity/ordersThe wallet's deposits and withdrawals.

requestKey makes order creation safe to retry. Sending the same key with the same body returns the same order; sending it with a different body is refused. Statuses are QUOTED, SUBMITTING, CONFIRMED, FINALIZED, FAILED, EXPIRED and UNKNOWN, with the meanings given in Receipts and history.

Errors you should handle

HTTPCodeMeaning
400INVALID_ORDER · INVALID_AMOUNT · QUOTE_EXPIRED · INSUFFICIENT_BALANCE · NO_EXECUTABLE_ROUTEThe request cannot be quoted or executed as sent. Fix it, or ask for a new quote.
401WALLET_SESSION_REQUIREDSign in first.
403ELIGIBILITY_REQUIRED · JURISDICTION_BLOCKEDThe wallet has not attested, or may not trade.
403ORIGIN_REJECTEDA mutation came from another origin.
409REQUEST_KEY_REUSED · ORDER_PENDING · LIQUIDITY_RESERVED · SETTLEMENT_INVENTORY_LIMITThe key was used for a different order, an earlier order is unresolved, or open quotes hold the inventory.
409PYTH_QUOTE_REFRESHThe underlying price moved, or less than five seconds of review would remain. Request a fresh quote.
422AMOUNT_TOO_SMALLAfter the fee, the output rounds down to nothing.
429RATE_LIMITSlow down. Twelve quote requests a minute per wallet, on each route.
503SETTLEMENT_PAUSED · SETTLEMENT_REFERENCE_STALE · SETTLEMENT_SIZE_LIMIT · SETTLEMENT_WINDOW_LIMIT · SETTLEMENT_INVENTORY_LIMIT · SETTLEMENT_PRICE_BANDThe OPmode pool cannot quote this order now: paused, reference refreshing, over a limit, short of inventory, or outside the band. OPmode's wallet balance checks also answer 503.
503PYTH_REFERENCE_PENDING · PYTH_SESSION_UNAVAILABLE · PYTH_SOURCE_STALE · PYTH_CONFIDENCE_LIMIT · PYTH_PUBLISHERS_INSUFFICIENT · PYTH_REPORT_MISMATCH · USDC_PARITY_UNAVAILABLEOPmode's underlying Pyth reference cannot be used now: it is being prepared or confirmed on chain, the US session is closed or unverified, the source is too old, too uncertain or has too few publishers, or the USDC parity check failed.
503LIVE_UNAVAILABLE · PROVIDER_UNAVAILABLE · INSTRUMENT_UNAVAILABLEQuick cannot route this market right now. Retry later; there is no fallback.

Polling and reservations

An OPmode quote reserves real pool inventory until it expires, so request one only when you intend to use it. For display, poll /api/market-data no faster than once every two seconds; references refresh every few seconds, so polling harder gets you the same answer.