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.
Runnable example
Node.js websocket connection
const ws = new WebSocket( "wss://api.realmarketapi.com/ws/candles?ApiKey=YOUR_KEY&SymbolCode=BTCUSDT&TimeFrame=M1" ); ws.onmessage = (evt) => console.log(evt.data);
Production notes
- Add exponential backoff with jitter for reconnect attempts.
- Expose clear disconnected/degraded UI states to end users.
- Bound in-memory message buffers during outage recovery.