WebSocketClient setup
TheWebSocketClient connects to the Limitless Exchange WebSocket server for real-time market data, position updates, order lifecycle events, and transaction notifications.
Constructor options
Public subscriptions (market prices) do not require authentication. Authenticated subscriptions (positions, order events, transactions) require
hmacCredentials — see Authentication to generate a token.Public subscriptions
Market prices
Subscribe to real-time price updates for one or more markets. No authentication required.The server answers every
subscribe_market_prices call, first or repeat, with one orderbookUpdate per CLOB slug carrying the full current book, including books with empty bids and asks. You do not need a REST call to seed local state. See Initial snapshot.Authenticated subscriptions
These subscriptions requirehmacCredentials passed to the constructor. The SDK signs the WebSocket handshake automatically.
Positions
Subscribe to real-time updates when your positions change:Order events
Subscribe to CLOB order lifecycle and settlement events for your account:orderEvent uses source as a discriminator:
source: 'OME'— off-chain order state changes: placement, update, cancellation.source: 'SETTLEMENT'— on-chain settlement results for the taker order and each matched maker order.
clientOrderId is the id of the recipient’s own orderId. If only one side of a trade supplied a clientOrderId, only that side’s event includes it. Counterparty order ids inside takerOrderId or makerMatches[] are not resolved to client ids.
Transactions
Subscribe to transaction confirmations:Events
orderbookUpdate (CLOB markets)
Fired once per slug right after you subscribe, then whenever a CLOB market orderbook changes. Contains the full current orderbook.newPriceData (AMM markets)
Fired when AMM market prices update.oraclePriceData
Fired when the oracle backing a subscribed market publishes a new price (e.g. Chainlink, Pyth). Delivered on the samesubscribe_market_prices channel as orderbookUpdate and newPriceData, so no separate subscription is required.
OraclePriceData fields: marketAddress (nullable), marketSlug, timestamp (unix ms), value (number).
positions
Fired when any of your positions change (fill, cancel, resolution).tx
Fired on transaction events related to your account.Type definitions
Connection management
Disconnect handling
Listen for disconnections and clean up resources:When
autoReconnect is enabled, the client automatically attempts to reconnect. However, you must re-send your subscriptions after reconnection. Listen for the reconnect event to resubscribe.