The SDK maintains a single shared WebSocket connection to Hyperliquid and multiplexes all subscriptions over it. You subscribe to a market, receive a callback on every update, and call the returned unsubscribe function when you’re done. Reconnection and subscription restoration happen automatically in the background.Documentation Index
Fetch the complete documentation index at: https://docs.outcome.xyz/llms.txt
Use this file to discover all available pages before exploring further.
All subscriptions-order book, price, and trades-share one WebSocket connection. Opening multiple subscriptions does not open multiple connections.
Subscribe to the order book
subscribeOrderBook delivers a Level 2 book snapshot (bids and asks) on every change.
Subscribe to live prices
subscribePrice delivers both sides of a market via Hyperliquid’s allMids feed. Side names are resolved from the outcome’s sideSpecs so you always get the real labels.
Subscribe to the trade stream
subscribeTrades delivers each executed trade as it happens.
Auto-reconnect
The WebSocket reconnects automatically if the connection drops. The retry schedule uses exponential backoff starting at 1 second, capped at 30 seconds, with a maximum of 10 attempts. Once reconnected, all active subscriptions are restored without any action on your part.Create a price feed for charting
createPriceFeed merges historical candles with live price ticks into a single continuously-updating snapshot. It’s designed to power live charts without you needing to stitch together the initial fetch and the real-time stream yourself.
PriceFeedOptions
| Field | Type | Default | Description |
|---|---|---|---|
interval | string | "1h" | Candle interval accepted by Hyperliquid (e.g. "1m", "5m", "1h", "1d") |
lookbackMs | number | 14 days | How far back to fetch historical candles, in milliseconds |
sideIndex | number | 0 | Which side to track - 0 for Yes, 1 for No |
PriceFeedSnapshot
| Field | Type | Description |
|---|---|---|
marketId | string | The market ID passed to createPriceFeed |
candles | PriceFeedCandle[] | Full OHLCV array: historical candles merged with live ticks |
currentMid | number | null | Latest mid-price received (may be newer than the last candle close) |
ready | boolean | false until the initial candle fetch completes |
Subscribe to account positions
subscribePositions delivers updated position data for a wallet address. Because Hyperliquid does not expose spot balance updates over WebSocket, this subscription polls at 10-second intervals.