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
| Call | Stream |
|---|---|
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:
- Subscribe to deltas and buffer updates.
- Fetch a snapshot with
nord.getOrderbook({ marketId }). - Discard buffered updates at or below the snapshot's
updateIdand apply the rest in order. - If
updateIdcontinuity 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.