WebSocket
WebSocket Protocol
Real-time event streaming via WebSocket. Receive P0/P1/P2 signals with sub-100ms latency for critical events.
Connection
WebSocket URL
wss://nexusglass.live/ws/fastfeedAuthentication is done via query parameter. The WebSocket endpoint requires a PULSE-tier (L3) or higher API key.
Connection URL
wss://nexusglass.live/ws/fastfeed?token=YOUR_API_KEY
Query Parameters
| Param | Required | Description |
|---|---|---|
token | required | API key for authentication |
symbols | optional | Comma-separated symbols to filter, e.g. BTCUSDT,ETHUSDT |
events | optional | Comma-separated event types to subscribe to |
Message Types
| Type | Direction | Description |
|---|---|---|
HANDSHAKE | Server → Client | Sent on successful connection. Contains tier info and allowed priorities. |
SNAPSHOT | Server → Client | Initial state snapshot of recent events. Sent after handshake. |
EVENT | Server → Client | Real-time event notification. Contains full event payload. |
ERROR | Server → Client | Error notification (auth failure, rate limit, etc.). |
PING | Client → Server | Keepalive ping. Server responds with PONG. |
PONG | Server → Client | Response to client PING. |
Message Examples
Handshake (on connect)
HANDSHAKE
{
"type": "HANDSHAKE",
"payload": {
"tier": "PULSE",
"priorities": ["P0", "P1", "P2"],
"delay_ms": 0,
"server_time": "2026-03-17T10:30:00Z"
}
}Event (real-time signal)
EVENT
{
"type": "EVENT",
"payload": {
"id": 12346,
"type": "LIQUIDATION_CLUSTER_ARMED",
"priority": "P0",
"symbol": "BTCUSDT",
"confidence": 0.92,
"data": {
"cluster_price": 98500,
"cluster_side": "LONG_LIQ",
"intensity_usd": 5200000,
"distance_pct": 1.8
},
"detected_at": "2026-03-17T10:30:45Z",
"latency_ms": 42
}
}Error
ERROR
{
"type": "ERROR",
"payload": {
"code": "AUTH_FAILED",
"message": "Invalid or expired API key"
}
}Code Examples
import asyncio
import json
import websockets
API_KEY = "YOUR_API_KEY"
URL = f"wss://nexusglass.live/ws/fastfeed?token={API_KEY}"
async def listen():
async with websockets.connect(URL) as ws:
async for raw in ws:
msg = json.loads(raw)
if msg["type"] == "HANDSHAKE":
print(f"Connected: tier={msg['payload']['tier']}")
elif msg["type"] == "EVENT":
ev = msg["payload"]
print(f"[{ev['priority']}] {ev['type']} "
f"{ev['symbol']} conf={ev['confidence']}")
elif msg["type"] == "ERROR":
print(f"Error: {msg['payload']['message']}")
break
asyncio.run(listen())Reconnection & Gap Recovery
Automatic reconnection
Implement exponential backoff (1s, 2s, 4s, 8s, max 30s) on disconnect. The server sends a SNAPSHOT on reconnect.
Gap recovery via REST
Track the last received event id. On reconnect, call GET /api/v1/fastfeed/events?since_id=LAST_ID to recover any missed events.
Heartbeat
Send a PING frame every 30 seconds. If no PONG is received within 10 seconds, reconnect.
