API Access and Usage#
Before using the DEX API, you need to create a project and generate an API key in the developer portal. For step-by-step instructions and additional resources, please refer to the guide available here.
Authentication#
All API requests must include the following headers:
- OK-ACCESS-KEY: Your API key.
- OK-ACCESS-TIMESTAMP: Request timestamp in UTC (ISO format, e.g.,
2020-12-08T09:08:57.715Z
). - OK-ACCESS-PASSPHRASE: The passphrase specified when creating the API key.
- OK-ACCESS-SIGN: Request signature.
Signature steps:
- Step 1: Concatenate the
timestamp
, HTTP method (e.g.,GET
/POST
),requestPath
, andbody
(if applicable) into a string. - Step 2: Sign the pre-hashed string (from Step 1) using the HMAC SHA256 algorithm with your secret key (generated during API key creation).
- Step 3: Encode the signature using Base64.
Explanation
- For example, sign = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp + 'GET' + '/api/v5/dex/aggregator/swap', SecretKey))
- Timestamp and OK-ACCESS-TIMESTAMP must be the same
- GET is the method (HTTP request method, all letters are uppercase)
- /api/v5/dex/aggregator/swap is the requestPath (request interface path)
- Body is empty. If the request has no request body (usually a GET request), body can be omitted
Note
- The time difference between the timestamp and the server must not exceed 30 seconds
- The POST request must include the original request in the signature
- The secret key is only visible during its creation. Please store it in a safe place that is accessible only by you
Legacy API#
The Wallet API, Marketplace API, and DeFi API will no longer be updated. If you are using these APIs, please visit here for more information.
Table of contents