WebSocket
Real-time notifications and live updates via WebSocket.
Connection
Connect to the WebSocket endpoint with your JWT token:
wss://api.judgemarket.com/ws?token=YOUR_JWT_TOKEN
The connection stays alive as long as the token is valid. When the access token expires, the connection will close and you should reconnect with a refreshed token.
Message Format
All messages are JSON with a type field:
{
"type": "NOTIFICATION",
"payload": {
"title": "Order Filled",
"content": "Your Bid order for Elon Musk was fully filled at 86.31 Φ."
}
}
Message Types
- NOTIFICATION — push notification (order filled, transfer received, reward claimed)
Reconnection
If the connection drops unexpectedly, implement exponential backoff:
let delay = 1000;
const maxDelay = 30000;
function reconnect(token) {
setTimeout(() => {
const ws = new WebSocket(`wss://api.judgemarket.com/ws?token=${token}`);
ws.onclose = () => {
delay = Math.min(delay * 2, maxDelay);
reconnect(token);
};
ws.onopen = () => { delay = 1000; };
}, delay);
}