OpenAPI Basic Information
API Basic Information
All interfaces return a JSON object or array.
If there are arrays in the response, the elements are arranged in reverse chronological order, with earlier data appearing first.
All times and timestamps are in UNIX format, with the unit being milliseconds.
HTTP Error Codes
HTTP
4XX
error codes are used to indicate incorrect request content, behavior, or format.HTTP
410
error code indicates a warning that the access frequency limit is exceeded, and the IP is about to be blocked.HTTP
418
indicates that continuing to access after receiving a 429 will result in IP ban. Frequent violations of the limit will gradually extend the ban duration, from a minimum of 2 minutes to a maximum of 3 days.HTTP
5XX
return codes signify internal system errors; this indicates that the problem is on the server side. When dealing with this error, do not treat it as a failed task, as the execution status is unknown; it could be successful or could have failed.HTTP
504
means that the API server has submitted a request to the business core but failed to get a response. It is important to note that a 504 code does not mean the request failed but is unknown. It might have been executed successfully, or it might have failed, and further confirmation is needed.Any interface may return an ERROR; the error return payload is as follows:
General Information
All requests are based on the HTTPS protocol, and the Content-Type in the request header needs to be uniformly set to 'application/json'.
For interfaces using the GET method, parameters must be sent in the query string.
For interfaces using the POST method, parameters must be sent in the request body.
There is no requirement for the order of parameters.
LIMITS
Access restrictions are based on IP or UID, not API Key.
The statistics by IP and by UID (account) are independent of each other.
The total weight of single interface weight according to IP statistics is 12,000 per minute
The total amount of interface weights by UID is 60,000 per minute
Each interface will indicate whether the statistics are by IP or by UID, and the weight value of the corresponding request once
There will be a limited frequency description below each interface.
A 429 will be returned when either rate limit is violated.
Endpoint Security Type
Each interface has its own authentication type, which determines the kind of authentication required during access.
If an API-key is needed, it should be transmitted in the HTTP header using the X-CH-APIKEY field.
Both API-key and API-secret are case sensitive.
You can modify the permissions associated with the API-key in the web user center, such as reading account information, sending trade orders, or sending withdrawal instructions.
SIGNED (TRADE 与 USER_DATA) endpoint security
When calling the TRADE or USER_DATA interfaces, the signature parameter should be transmitted in the HTTP header using the X-CH-SIGN field.
The signature uses the HMAC SHA256 algorithm. The API-Secret corresponding to the API-KEY is used as the key for HMAC SHA256.
The X-CH-SIGN request header is formed by concatenating the timestamp + method + requestPath + body string (where '+' denotes string concatenation).
The value of the timestamp is the same as in the X-CH-TS request header. The method is the request method, in all uppercase letters: GET/POST.
requestPath is the request interface path, for example: /sapi/v1/order?orderId=211222334&symbol=BTCUSDT.
body is the string of the request body (post only). If it is a GET request, then the body can be omitted.
The signature is not case sensitive.
Timing Security
The signature interface needs to pass the timestamp in the
X-CH-TS
field in the HTTP header, and its value should be the unix timestamp of the request sending time e.g.1528394129373
An additional parameter,
recvWindow
, may be sent to specify the number of milliseconds aftertimestamp
the request is valid for. IfrecvWindow
is not sent, it defaults to 5000.In addition, if the server calculates that the client's timestamp is more than one second ‘in the future’ of the server’s time, it will also reject the request.
The logic is as follows:
Serious trading is about timing. Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With recvWindow
, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.
It recommended to use a small recvWindow of 5000 or less!
SIGNED Endpoint Examples for POST /sapi/v1/order
Here is a step-by-step example of how to send a vaild signed payload from the Linux command line using echo
, openssl
, and curl
.
Signature example
body:
HMAC SHA256 Signature:
Curl command :
Last updated