Skip to main content

Websocket Documentation

This document provides instructions on how to connect to and interact with the WebSocket service for real-time price updates.

Authentication

All WebSocket requests must be authenticated using an API key.

  • Header: X-API-Key

To authenticate your request, include your API key in the X-API-KEY header. Requests without a valid API key will be rejected with a 401 Unauthorized error.

Important

To access the WebSocket service, the IP address used must be whitelisted by our team.

Message Formats

All requests and server responses use JSON.

Subscribe

Method: "subscribe" — request real-time updates for one or more pairs.

Request Parameters

ParameterTypeRequiredDescription
idstringNoClient-provided identifier.
methodstringYesThe request action method.
paramsobjectYesContains subscription parameters like "pairs".
params.pairsarray[string]YesArray of pair codes. (Crypto:ALL:BTC/USDT)

Response Parameters

Notice Response

ParameterTypeRequiredDescription
methodstringYesThe request action method.
messagestringYesSuccess / Error message.
codestringYesStatus request code.
idstringNoClient-provided identifier.
dataobjectNoResponse data from server

Push Data Response

ParameterTypeRequiredDescription
codestringYesThe code representing the pair.
askstringYesThe ask price.
bidstringYesThe bid price.
pricestringYesThe current price.

Request

{
"id": "ca3569cb-97ff-439a-8088-0f252c28b452",
"method": "subscribe",
"params": {
"pairs": [
"Crypto:ALL:BTC/USDT",
"Crypto:ALL:BNB/USDT"
]
}
}

Notice: Successful Response

{
"id": "61b0d7ba-568c-418f-91d3-a291673001ca",
"method": "subscribe",
"message": "Success",
"code": "200",
"data": null
}

Push Data Response

{
"code": "Crypto:ALL:BTC/USDT",
"ask": "109999.6793997101",
"bid": "109779.8998204899",
"price": "109889.7896101"
}

Notice: Error Response - Pair Not Found

{
"method": "error",
"message": "pair not found: Crypto:ALL:XXX/USDT",
"code": "500",
"id": "a9611418-a501-4138-a2da-5bdb9fde235a",
"data": null
}

Unsubscribe

Method: "unsubscribe" — stop receiving updates for given pairs.

Request Parameters

ParameterTypeRequiredDescription
idstringNoClient-provided identifier.
methodstringYesThe request action method.
paramsobjectYesContains unsubscription parameters like "pairs".
params.pairsarray[string]YesArray of pair codes. (Crypto:ALL:BTC/USDT)

Response Parameters

Notice Response

ParameterTypeRequiredDescription
methodstringYesMethod from request
messagestringYesSuccess / Error Message
codestringYesStatus request code

Request

{
"id": "ca3569cb-97ff-439a-8088-0f252c28b452",
"method": "unsubscribe",
"params": {
"pairs": [
"Crypto:ALL:BTC/USDT"
]
}
}

Notice: Successful Response

{
"method": "unsubscribe",
"message": "success",
"code": "200"
}

Heartbeat

Use "ping" to keep the connection alive.

Request Parameters

ParameterTypeRequiredDescription
idstringNoClient-provided identifier.
methodstringYesThe request action method
paramsobjectNoSpecifies the parameter requested.

Request

{
"method": "ping"
}

Response

Pong!
Important

Important: If the server does not receive a ping within 30 seconds, the websocket connection will be closed.

Limitations

Connection Limitations

WebSocket connection limits are based on the allowed connections per API key, not on IP address restrictions.

For example, one API key allows only one WebSocket connection. If an IP address (A) has already initiated a WebSocket connection, attempting a second connection from the same IP address (A) will be rejected. Similarly, attempting a second connection from a different IP address (B) will also be rejected because the API key permits only one WebSocket connection.

For example user have a limit of three connections, one API key allows up to three WebSocket connections. You can have three WebSocket connections simultaneously from IP address (A), or one each from IP address (A), IP address (B), and IP address (C), as long as the total connections do not exceed three.

Subscription Limitations

Each WebSocket connection allows one active subscription at a time. Sending a new subscription request overwrites the previous one. Example: If you initially subscribe to A, B, C and want to add E, F, G, you must resend A, B, C, E, F, G in a single request. Once subscribed, real-time data will be pushed automatically.

Max subscription pairs per connection is 100 pairs.

Status Code

Status CodeMeaningDescription
200SuccessThe operation was successful.
50000Internal Server ErrorAn unexpected error occurred on the WebSocket service.
50002Websocket MaintenanceThe websocket service is temporarily down for maintenance.
50004Invalid RequestThe request format is invalid or contains malformed data.
50005UnauthorizedThe API key is missing, invalid, or expired.
50006Too Many RequestsThe request rate limit has been exceeded.
50007SuspendedThe API key has been suspended.
50008Resource Not FoundThe requested resource (pair, endpoint) does not exist.
50010Access DeniedThe API key does not have permission to access this resource.
50101Price Not FoundNo price data could be found for the requested pair.
50102Price UnavailableThe price data is temporarily unavailable.
50104Pair Not FoundThe requested pair does not exist or is not supported.
50109No Access to Asset TypeThe API key is not permitted to access this asset type.