Skip to main content

WebSockets

Every subscription helper returns an event emitter with "message" and "error" events and a close() method.

const sub = nord.subscribeTrades("BTCUSD");

sub.on("message", (update) => console.log(update));
sub.on("error", (error) => console.error(error));

// later
sub.close();

Helpers

CallStream
nord.subscribeOrderbook(symbol)Orderbook deltas for one market
nord.subscribeTrades(symbol)Trades for one market
nord.subscribeBars(symbol, resolution)Candles for one market
nord.subscribeRfqFills(symbolOrMarketId)RFQ fill requests for one market
nord.subscribeAccount(accountId)Balance, position, and order updates

Symbols are the market symbols from /info (for example BTCUSD), not market IDs. Candle resolutions are "1", "5", "15", "30", "60", "4H", "1D", "1W", and "1M" (minutes where numeric).

Helpers filter by symbol or account for you, so a handler only sees updates for the market or account it subscribed to.

One connection, many streams

Each helper opens its own connection. To multiplex, create the client directly:

const ws = nord.createWebSocketClient({
trades: ["BTCUSD", "ETHUSD"],
deltas: ["BTCUSD"],
candles: [{ symbol: "BTCUSD", resolution: "60" }],
accounts: [accountId],
rfqFills: ["BTCUSD"],
liquidations: true,
});

This is the right shape for a market-making or monitoring process: one socket carrying every stream it needs, instead of one socket per stream. Account IDs must be positive; invalid IDs throw before the socket is opened.

Applying orderbook deltas

Delta updates are incremental. To keep a local book:

  1. Subscribe to deltas and buffer updates.
  2. Fetch a snapshot with nord.getOrderbook({ marketId }).
  3. Discard buffered updates at or below the snapshot's updateId and apply the rest in order.
  4. If updateId continuity breaks, re-snapshot rather than patching.

Underlying protocol

The helpers wrap /ws/{streams} — see WebSocket streams for the raw stream names and message shapes, which is what you need if you are not using the SDK.

These materials are provided for informational purposes only and do not constitute financial, investment, legal, or tax advice, or an offer or solicitation to buy or sell any asset. Trading digital assets and derivatives involves substantial risk, including the possible loss of some or all capital. Products may not be available in all jurisdictions. Users are responsible for evaluating suitability and complying with applicable laws.