WebSocket
WebSocket Connection
Establish real-time WebSocket connections
Overview
WinNova provides a WebSocket API for real-time market data, orderbook updates, and order status notifications.
Connection Flow
Step 1: Obtain a WS Token
POST /api/ext/v1/ws/tokenScope: ws:read
This exchanges your API Key credentials for a short-lived WebSocket token.
Response
{
"success": true,
"data": {
"ws_token": "wst_abc123...",
"expires_at": "2026-04-04T11:30:00Z"
}
}Step 2: Connect
wss://api.winnova.pro/api/ws/ext/v1?token=wst_abc123...The token expires after 24 hours by default (maximum 7 days). You may pass an optional ttl (seconds) in the request body to request a shorter or longer lifetime.
Optional Request Body
You can pass a ttl field (in seconds) to request a non-default token lifetime:
{ "ttl": 3600 }- Minimum:
1second - Default:
86400(24 hours) - Maximum:
604800(7 days)
Example (JavaScript)
// Step 1: Get token
const { data } = await makeRequest('POST', '/api/ext/v1/ws/token');
// Step 2: Connect
const ws = new WebSocket(`wss://api.winnova.pro/api/ws/ext/v1?token=${data.ws_token}`);
ws.onopen = () => {
console.log('Connected');
// Subscribe to topics
ws.send(JSON.stringify({ action: 'subscribe', topics: ['market:MARKET_ID:price'] }));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};Mid-Session Token Refresh
If your connection is long-lived and you need to upgrade authentication (e.g. after a user logs in), you can send a new WS token over the existing connection without reconnecting:
{ "action": "auth", "token": "wst_newtoken..." }On success the server responds with:
{ "type": "subscribed", "topics": [], "message": "auth refreshed" }On failure:
{ "type": "error", "message": "auth failed: ..." }