Skip to main content

Integration Guide

The following is a brief introduction to quickly get started using the API services in this centralized cryptocurrency exchange:

Get API Key

Before applying for an API key, you need to apply for an account at CoinEx. For the specific application process, please refer to Help Center.

Once you have your account ready, you can generate the API key in the Developer Console to ensure that you have the necessary permissions.

Prepare for API Calls

Depending on your requirements, select the appropriate API endpoint and refer to the corresponding API documentation to understand the request methods, parameters, and response results.

For details, you can explore the Module Grouping, and find the corresponding module and its corresponding API endpoint, or use the search function to quickly find it.

Build Requests

Use the programming language of your choice to construct a request that meets the API requirements, including setting the request method, URL, request headers and parameters, etc.

Info

The base URL of HTTP is: https://api.coinex.com/v2

The base URL for spot and futures WS are different, as follows:

Public Parameter:

Info

HTTP endpoints marked with signature required needs to use the following two public HTTP HEADER parameters for request authentication. For specific usage methods, please refer to Authentication

  • X-COINEX-KEY
  • X-COINEX-SIGN
Info

If you need to limit the validity time of the request, you can restrict the validity period through the following public HTTP HEADER parameters in all HTTP endpoints.

When the server receives the request, it will check the timestamp provided in the X-COINEX-TIMESTAMP. If the request was sent more than 5000 milliseconds (default value) ago, it will be considered invalid.This time window value can be customized by sending the optional parameter X-COINEX-WINDOWTIME.

  • X-COINEX-TIMESTAMP.Required parameter, used to indicate the time at which the request is being sent.
  • X-COINEX-WINDOWTIME.Optional parameter, used to indicate a time window for which the request is valid. The default value is 5000 milliseconds.
Info

In all APIs, time request parameters and response fields are millisecond-level timestamps.

Response Processing

Parse the response data returned by the API and perform corresponding processing as needed, such as error handling, data extraction, etc.

HTTP Response Processing

  1. For HTTP responses, please determine at first whether the status_code is 200, and then proceed to the next step of processing.
  2. A normal HTTP response will have a unified response structure. You need to determine whether the response is normal by judging the code field in the structure. code should be 0 under normal circumstances.

The unified structure of HTTP normal response is as follows:

{
"code": 0,
"data": ...
"message": "OK"
}

WS Response Processing

  1. In the WS protocol, it is recommended to handle the response to subscription requests before proceeding further. Upon sending a subscription request, the server will respond with a subscription result. The response from the WS server is compressed using zip and must be decompressed first.
  2. It's necessary to determine if the 'code' field in the response result is 0.

The unified structure of WS normal response is as follows:

{
"id": 4,
"message": "OK",
"code": 0
}
  1. After a successful subscription, the server will push the data when it is updated, and the pushed data can be processed according to your needs.

For specific error explanations, please refer to Error Handling

Security Considerations

Warning

Ensure that HTTPS protocol is used for data transmission in API calls. Additionally, securely manage your API keys to prevent any leakage. The importance of API keys is equivalent to that of your account password. To ensure your account and asset security, please manage and regularly update your keys appropriately.Once you lose your secret key, please go to CoinEx to remove the secret key in time.