WebSocket streams
Streams are selected in the URL path, not by a subscribe message. Connect to:
wss://api-mainnet.n1.xyz/ws/<stream>[&<stream>...]
wss://api-devnet.n1.xyz/ws/<stream>[&<stream>...]
Multiple streams are joined with & in the path segment, so one connection can
carry everything a process needs.
Streams
| Stream | Form | Contents |
|---|---|---|
| Trades | trades@<symbol> | Executed trades for a market |
| Orderbook deltas | deltas@<symbol> | Incremental book updates for a market |
| Candles | candle@<symbol>:<resolution> | OHLCV bars |
| Account | account@<accountId> | Balance, position, and order updates |
| RFQ fills | rfq-fills@<market> | RFQ fill requests and results |
| Vault | vault@<vaultId> | Vault state updates |
| Liquidations | liquidations | Liquidation events, exchange-wide |
Resolutions are 1, 5, 15, 30, 60, 4H, 1D, 1W, 1M.
Example — trades and deltas for BTCUSD plus one account, on one socket:
wss://api-mainnet.n1.xyz/ws/trades@BTCUSD&deltas@BTCUSD&account@42
Message envelope
Messages are JSON and identify their stream, so a multiplexed connection can be
dispatched on the stream name. Values arrive as scaled integers: divide by the
market's priceDecimals / sizeDecimals or the token's decimals from
/info.
Keeping a book in sync
Deltas are incremental and carry an updateId. Buffer deltas, take a snapshot
from GET /market/{market_id}/orderbook, drop buffered updates at or below the
snapshot's updateId, then apply the rest in order. Re-snapshot if updateId
continuity breaks.
Reconnecting
Assume disconnects. On reconnect, re-open the same stream URL and re-establish state from REST before trusting incremental updates: a snapshot for books, and account state for balances, positions, and orders. The TypeScript SDK handles reconnection and provides typed handlers if you would rather not build this yourself.