Skip to main content
radion.realtime is the WebSocket client. It runs the whole connection for you. It connects, reconnects after an unexpected drop, puts your subscriptions back, and sends each incoming frame to the handlers you set up.

Connect

connect() opens the socket and finishes once the connection is up. If the first try fails, it errors.
const radion = new Radion({ apiKey: process.env.RADION_API_KEY });

await radion.realtime.connect();
radion.realtime.subscribe({ id: "trading", channel: "trading" });
radion.realtime.onChannel("trading", (event) => console.log(event.data));
The client just remembers what you want. You can call subscribe before or after connect. Either way, the client sends your subscriptions once the socket is open.

Lifecycle

  1. Connectconnect() opens the socket with your X-API-Key header.
  2. Subscribe — add your subscriptions. The client sends them on open and again on every reconnect.
  3. Receive — channel events go to your handlers. Lifecycle events tell you the connection state.
  4. Closeclose() shuts down cleanly and stops all reconnect tries.

Reference

Subscriptions

Subscribe with ids and filters.

Events

Channel, wildcard, and lifecycle handlers.

Reconnect & heartbeats

Backoff, keep-alive, and resubscribe.

Errors

The error hierarchy and server codes.
Last modified on July 5, 2026