Skip to main content

WebSocket Feeds

InTots provides three WebSocket endpoints for real-time streaming data. Use these to keep your UI up to date without polling.

All WebSocket paths are relative to the base URL /api/v1/.


Connection Protocol​

All three feeds use the standard WebSocket upgrade handshake:

  1. Open a WebSocket connection to the endpoint URL.
  2. The server performs the HTTP 101 upgrade.
  3. Upon successful connection, the server sends an initial message containing recent history (so your UI can render immediately without a separate REST call).
  4. Subsequent messages arrive as events occur.

Keep-Alive​

  • The server sends ping frames every 50 seconds.
  • The client must respond with a pong frame (most WebSocket libraries handle this automatically).
  • The server enforces a read deadline of 60 seconds. If no pong is received within that window, the connection is closed.

Limits​

LimitValue
Max connections per hub10,000
Max message size (trades feed)512 bytes
Max message size (chart / asset feeds)128 bytes

1. Live Trades Feed​

Stream of all trades executed across the platform in real time.

GET /api/v1/ws/trades

Message Format​

{
"type": "trade",
"trade": {
"amount": 50000,
"name": "alice",
"token": "Yes",
"event": "Will ETH hit $5k?",
"market": "mkt_001",
"avatar": "https://cdn.intots.com/avatars/alice.jpg"
}
}
FieldTypeDescription
typestringAlways "trade".
trade.amountintegerTrade size in cents.
trade.namestringDisplay name of the trader.
trade.tokenstringThe outcome token traded (e.g. "Yes", "No").
trade.eventstringName of the event the trade belongs to.
trade.marketstringMarket ID.
trade.avatarstringURL to the trader's avatar image.

Use Cases​

  • Global activity ticker ("Alice just bought 500 shares of Yes on ...").
  • Volume monitoring dashboards.
  • Social proof indicators on event pages.

Example​

const ws = new WebSocket('wss://api.intots.com/api/v1/ws/trades');

ws.onopen = () => {
console.log('Connected to trades feed');
};

ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
if (msg.type === 'trade') {
const { name, amount, token, event: eventName } = msg.trade;
console.log(`${name} traded ${amount / 100} on "${token}" in "${eventName}"`);
}
};

2. Event Chart Feed​

Real-time price updates for a specific event. Subscribe by event ID.

GET /api/v1/ws/events/{event_id}/chart

Path Parameters​

ParameterTypeDescription
event_idstringThe event to subscribe to.

Message Format​

{
"type": "chart_update",
"timestamp": "2026-03-15T14:30:05Z",
"ratios": {
"Yes": 6450,
"No": 3550
}
}
FieldTypeDescription
typestringAlways "chart_update".
timestampstringISO 8601 timestamp of the update.
ratiosobjectCurrent price for each outcome, on the 0--10000 scale.

Use Cases​

  • Live-updating price charts on event detail pages.
  • Real-time probability displays.
  • Combine with historical chart data for a seamless experience.

Example​

const eventId = 'evt_abc123';
const ws = new WebSocket(`wss://api.intots.com/api/v1/ws/events/${eventId}/chart`);

ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
if (msg.type === 'chart_update') {
updateChart(msg.timestamp, msg.ratios);
}
};

3. Asset Price Feed​

Real-time price updates for crypto assets. Subscribe by trading symbol.

GET /api/v1/ws/assets/{symbol}/price

Path Parameters​

ParameterTypeDescription
symbolstringThe asset trading pair symbol (e.g. BTCUSDT, ETHUSDT, SOLUSDT).

Message Format​

{
"type": "price_update",
"symbol": "BTCUSDT",
"price": 8734521
}
FieldTypeDescription
typestringAlways "price_update".
symbolstringThe asset symbol this update is for.
priceintegerCurrent asset price in cents.

Use Cases​

  • Live crypto price tickers on event pages for crypto loop events.
  • Price alerts and threshold monitoring.
  • Display current reference prices alongside prediction markets.

Example​

const ws = new WebSocket('wss://api.intots.com/api/v1/ws/assets/BTCUSDT/price');

ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
if (msg.type === 'price_update') {
console.log(`${msg.symbol}: $${(msg.price / 100).toFixed(2)}`);
}
};

Reconnection Strategy​

WebSocket connections can drop due to network issues, server deployments, or idle timeouts. Implement a reconnection strategy in production:

function connect(url, onMessage) {
const ws = new WebSocket(url);
let reconnectDelay = 1000;

ws.onopen = () => {
reconnectDelay = 1000; // Reset on successful connect
};

ws.onmessage = onMessage;

ws.onclose = () => {
setTimeout(() => {
reconnectDelay = Math.min(reconnectDelay * 2, 30000); // Exponential backoff, max 30s
connect(url, onMessage);
}, reconnectDelay);
};

return ws;
}

Summary​

FeedEndpointMessage TypeMax Message Size
Trades/api/v1/ws/tradestrade512 bytes
Event Chart/api/v1/ws/events/{event_id}/chartchart_update128 bytes
Asset Price/api/v1/ws/assets/{symbol}/priceprice_update128 bytes

All feeds share the same connection protocol: standard WebSocket upgrade, server-side ping every 50s, 60s read deadline, and a maximum of 10,000 concurrent connections per hub.