Integrate
Realtime
Live portfolio and risk events for an address, pushed over Socket.IO the moment a snapshot lands. Use it for interfaces; use webhooks for servers.
With the SDK#
Realtime needs the optional peer socket.io-client. Without it the SDK throws a clear error rather than failing somewhere obscure.
bash
npm install @rivisk/sdk socket.io-clientts
const rivisk = new RiviskClient({ baseUrl, realtimeUrl: 'http://localhost:4001' }); const unsubscribe = await rivisk.realtime.subscribe(address, (message) => { if (message.event === 'risk.updated') render(message.data);}); // laterunsubscribe();rivisk.close();One socket carries every subscription. The SDK re-sends them after a reconnect: rooms live on the server and do not survive a dropped connection, and without that a monitor would silently stop receiving events while still looking connected.
Messages#
json
{ "event": "risk.updated", "address": "SP10GK6MG2GM7BCVYV7XBHK1JVJDHFDMNBENNBRC3", "data": { "riskLevel": "critical", "riskScoreBps": 9979, "healthFactorE4": 11798, "reportHash": "…" }, "timestamp": "2026-09-21T12:00:00.000Z"}The four event names and their data are the same as for webhooks. Every event goes to both, through one code path, so the two cannot drift.
Wire protocol#
For clients that do not use the SDK:
| Direction | Event | Payload |
|---|---|---|
| client → server | portfolio:subscribe | The address, as a string |
| client → server | portfolio:unsubscribe | The address, as a string |
| server → client | rivisk:event | The message above |
ts
import { io } from 'socket.io-client'; const socket = io('http://localhost:4001', { transports: ['websocket'] });socket.on('connect', () => socket.emit('portfolio:subscribe', address)); // re-subscribe on every connectsocket.on('rivisk:event', (message) => console.log(message));
