All private REST requests must contain the following headers:
OK-ACCESS-KEY
The API key as a string (follow this guide to generate an API key)OK-ACCESS-SIGN
The Base64-encoded signature (go to the Signature subsection for details)OK-ACCESS-TIMESTAMP
The UTC timestamp of your request, e.g., 2020-12-08T09:08:57.715ZOK-ACCESS-PASSPHRASE
The passphrase you specified when creating the API keySome endpoints, such as WaaS, require an additional header:
OK-ACCESS-PROJECT
The project ID of your project (can be found under project details)Request bodies should have content type application/json
and be in valid JSON format.
The OK-ACCESS-SIGN
header is generated as follows:
Example:
sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp + 'GET' + '/api/v5/account/balance?ccy=BTC', SecretKey))
timestamp
value is the same as the OK-ACCESS-TIMESTAMP
header with millisecond ISO format
2020-12-08T09:08:57.715Z
GET
and POST
/api/v5/account/balance
{"instId":"BTC-USDT","lever":"5","mgnMode":"isolated"}
GET
request parameters are counted as requestpath, not bodyPostman is a popular API development and testing tool that allows developers to design, test, and document APIs. It provides a user-friendly graphical interface for making HTTP requests to APIs.
If you have not installed Postman, you can download it for free from the Postman website: https://www.postman.com/
Under the Headers tab, add the following key-value pairs:
OK-ACCESS-KEY
OK-ACCESS-PASSPHRASE
OK-ACCESS-PROJECT
(if required)OK-ACCESS-SIGN
) and timestamp (OK-ACCESS-TIMESTAMP
)GET requests:
var method = pm.request.method;
var now = new Date();
var isoString = now.toISOString();
var path = pm.request.url.getPathWithQuery();
var sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(isoString + method + path, pm.variables.replaceIn('{{secret_key}}')));
pm.request.headers.add({
key: 'OK-ACCESS-SIGN',
value: sign
});
pm.request.headers.add({
key: 'OK-ACCESS-TIMESTAMP',
value: isoString
});
POST requests:
var method = pm.request.method;
var now = new Date();
var isoString = now.toISOString();
var path = pm.request.url.getPathWithQuery();
var bodyStr = pm.request.body.raw;
var sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(isoString + method + path + bodyStr, pm.variables.replaceIn('{{secret_key}}')))
pm.request.headers.add({
key: 'OK-ACCESS-SIGN',
value: sign
});
pm.request.headers.add({
key: 'OK-ACCESS-TIMESTAMP',
value: isoString
});