API Validation
Request Header
The Content-Type must be set to application/x-www-form-urlencoded in all request headers.
Generate Api Key
To begin, generate and Open API token management section in your personal center.
Next, you will receive an API key and a secret key, both of which you must remember.
The API key and secret key will be generated randomly.
Generate Sign
Required Parameters
| Parameter | Description |
|---|---|
| api_key | the key is in the user api management |
| time | it is the current timestamp |
| sign | the string is generated according to signature rule |
Http Method: GET
Add the required parameters to the query parameters.
api_key=*****&time=1736303665297Sort the keys of the query parameters in ascending order, then iterate through the keys to get their corresponding values. Combine the keys and values. If a value is empty string, the key and value do not need to be combined.
api_key*****key1value1key2value2time1736303665297Append the secret key to the end of the sign.
api_key*****key1value1key2value2time1736303665297secretkeyPerform MD5 hashing on the sign, then add the sign and the result to the query parameters.
api_key=*****&time=1736303665297&key1=value1&key2=value2&sign=SignResultExample
api key = APIKEY
secret key = SECRETKEY
timestamp = 1736500909794
request path = /open/api/v2/new_order?pageSize=&page=&symbol=btcusdtGenerate the string to be signed.
api_keyAPIKEYsymbolbtcusdttime1736500909794SECRETKEYThe signature is the result of MD5 processing.
0d337977b62d9be012d2972eab64d00fFinally, add the sign to the query parameters.
request path = /open/api/v2/new_order?pageSize=&page=&symbol=btcusdt&api_key=APIKEY&time=1736500909794&sign=0d337977b62d9be012d2972eab64d00fHttp Method: POST
Add the required parameters to the request body (form data).
api_key=*****&time=1736303665297Sort the keys of the form data in ascending order, then iterate through the keys to get their corresponding values. Combine the keys and values. If a value is empty string, the key and value do not need to be combined.
api_key*****key1value1key2value2time1736303665297Append the secret key to the end of the sign.
api_key*****key1value1key2value2time1736303665297secretkeyPerform MD5 hashing on the sign, then add the sign and the result to the form data.
api_key=*****&time=1736303665297&key1=value1&key2=value2&sign=SignResultExample
api key = APIKEY
secret key = SECRETKEY
timestamp = 1736501544686
request path = /open/api/cancel_order_all
form data = 'symbol=btcusdt'Generate the string to be signed.
api_keyAPIKEYsymbolbtcusdttime1736501544686SECRETKEYThe signature is the result of MD5 processing.
1868407a77e9785c6d7c4d1b8a743200Finally, add the sign to the query parameters.
form data = 'symbol=btcusdt&time=1736501544686&api_key=APIKEY&sign=1868407a77e9785c6d7c4d1b8a743200javascript example
const timestamp = new Date().getTime();
const method = 'get';
const timeKey = "time";
const apiKeyKey = "api_key";
const apiKey = "APIKEY";
const secretKey = "SECRETKEY";
let params = new Array();
params.push(generateParameterObject('key1', 'value1'));
params.push(generateParameterObject('key2', ''));
params.push(generateParameterObject(timeKey, timestamp.toString()));
params.push(generateParameterObject(apiKeyKey, apiKey));
let keys = new Array();
let paramMap = new Map();
params.forEach((param)=>{
let key = param.key;
let value = param.value;
if(value=="" || value==null || value==undefined) {
return;
}
keys.push(key);
paramMap.set(key, value);
});
keys.sort();
let sign = new String();
for(let i=0;i<keys.length;i++) {
let key = keys[i];
let value = paramMap.get(key);
sign+=key+value;
}
sign+=secretKey;
//need to includ the library of CryptoJS
sign=CryptoJS.MD5(sign).toString();
params.push(generateParameterObject('sign', sign));
let parametersString = '?'+params.map((param)=>{
let key = param.key;
let value = param.value;
return `${key}=${value}`;
})
.join("&");
console.log(parametersString);
switch(method) {
case 'get':
//TODO append parametersString to the end of the request url
break;
case 'post':
//TODO add parametersString to the body of the request
break;
}
function generateParameterObject(key, value) {
let obj = new Object();
obj.key = key;
obj.value = value;
return obj;
}