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:
- Open a WebSocket connection to the endpoint URL.
- The server performs the HTTP 101 upgrade.
- Upon successful connection, the server sends an initial message containing recent history (so your UI can render immediately without a separate REST call).
- 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β
| Limit | Value |
|---|---|
| Max connections per hub | 10,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"
}
}
| Field | Type | Description |
|---|---|---|
type | string | Always "trade". |
trade.amount | integer | Trade size in cents. |
trade.name | string | Display name of the trader. |
trade.token | string | The outcome token traded (e.g. "Yes", "No"). |
trade.event | string | Name of the event the trade belongs to. |
trade.market | string | Market ID. |
trade.avatar | string | URL 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β
| Parameter | Type | Description |
|---|---|---|
event_id | string | The event to subscribe to. |
Message Formatβ
{
"type": "chart_update",
"timestamp": "2026-03-15T14:30:05Z",
"ratios": {
"Yes": 6450,
"No": 3550
}
}
| Field | Type | Description |
|---|---|---|
type | string | Always "chart_update". |
timestamp | string | ISO 8601 timestamp of the update. |
ratios | object | Current 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β
| Parameter | Type | Description |
|---|---|---|
symbol | string | The asset trading pair symbol (e.g. BTCUSDT, ETHUSDT, SOLUSDT). |
Message Formatβ
{
"type": "price_update",
"symbol": "BTCUSDT",
"price": 8734521
}
| Field | Type | Description |
|---|---|---|
type | string | Always "price_update". |
symbol | string | The asset symbol this update is for. |
price | integer | Current 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β
| Feed | Endpoint | Message Type | Max Message Size |
|---|---|---|---|
| Trades | /api/v1/ws/trades | trade | 512 bytes |
| Event Chart | /api/v1/ws/events/{event_id}/chart | chart_update | 128 bytes |
| Asset Price | /api/v1/ws/assets/{symbol}/price | price_update | 128 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.