trade.qfex.com require authentication. You must authenticate within 1 minute of connecting or the server will close the connection. Authentication uses an HMAC-SHA256 signature or a valid JWT token.
How it works
- Connect to wss://trade.qfex.com?api_key=YOUR_PUBLIC_KEY.
- Generate a cryptographically secure random nonce (hex encoded, max 100 characters) and capture the current Unix timestamp.
- Build the string
${nonce}:${unix_ts}and compute an HMAC-SHA256 using your secret key. Hex-encode the result to get the signature. - Send the auth payload with the
hmacblock shown below. The nonce must be unique within a 15 minute window. - If you want the authenticated Trade WebSocket session to use a subaccount, include an optional
account_idfield alongside eitherhmacorjwt. When omitted, the connection uses the primary account.
Sample Code
Example Response
After the client successfully authenticates, the server keeps the connection
alive by periodically sending heartbeat messages in the form of WebSocket
ping
frames.