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.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | No | Client-provided identifier. |
| method | string | Yes | The request action method. |
| params | object | Yes | Contains subscription parameters like "pairs". |
| params.pairs | array[string] | Yes | Array of pair codes. (Crypto:ALL:BTC/USDT) |
Response Parameters
Notice Response
| Parameter | Type | Required | Description |
|---|---|---|---|
| method | string | Yes | The request action method. |
| message | string | Yes | Success / Error message. |
| code | string | Yes | Status request code. |
| id | string | No | Client-provided identifier. |
| data | object | No | Response data from server |
Push Data Response
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | The code representing the pair. |
| ask | string | Yes | The ask price. |
| bid | string | Yes | The bid price. |
| price | string | Yes | The 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | No | Client-provided identifier. |
| method | string | Yes | The request action method. |
| params | object | Yes | Contains unsubscription parameters like "pairs". |
| params.pairs | array[string] | Yes | Array of pair codes. (Crypto:ALL:BTC/USDT) |
Response Parameters
Notice Response
| Parameter | Type | Required | Description |
|---|---|---|---|
| method | string | Yes | Method from request |
| message | string | Yes | Success / Error Message |
| code | string | Yes | Status 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | No | Client-provided identifier. |
| method | string | Yes | The request action method |
| params | object | No | Specifies the parameter requested. |
Request
{
"method": "ping"
}
Response
Pong!
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 Code | Meaning | Description |
|---|---|---|
200 | Success | The operation was successful. |
50000 | Internal Server Error | An unexpected error occurred on the WebSocket service. |
50002 | Websocket Maintenance | The websocket service is temporarily down for maintenance. |
50004 | Invalid Request | The request format is invalid or contains malformed data. |
50005 | Unauthorized | The API key is missing, invalid, or expired. |
50006 | Too Many Requests | The request rate limit has been exceeded. |
50007 | Suspended | The API key has been suspended. |
50008 | Resource Not Found | The requested resource (pair, endpoint) does not exist. |
50010 | Access Denied | The API key does not have permission to access this resource. |
50101 | Price Not Found | No price data could be found for the requested pair. |
50102 | Price Unavailable | The price data is temporarily unavailable. |
50104 | Pair Not Found | The requested pair does not exist or is not supported. |
50109 | No Access to Asset Type | The API key is not permitted to access this asset type. |