Skip to content
RealMarketAPI

websocket candles api nodejs

WebSocket Candles API for Node.js: Reconnect-Safe Setup

Integrate websocket candle feeds in Node.js with deterministic reconnect and stale-state handling.

Summary

Stream candle updates while keeping reconnect and replay behavior predictable.

Runnable example

Node.js websocket connection. Replace YOUR_KEY with your API key.

Node.js websocket connection
const ws = new WebSocket(
  "wss://api.realmarketapi.com/candles?ApiKey=YOUR_KEY&symbolCode=BTCUSD&timeFrame=M1"
);
ws.onmessage = (evt) => console.log(evt.data);

Production notes

  • 01Add exponential backoff with jitter for reconnect attempts.
  • 02Expose clear disconnected/degraded UI states to end users.
  • 03Bound in-memory message buffers during outage recovery.

Run this example with your own key

Create a free account, then try the request in the playground before wiring it into production.