Authentication
Headers
X-API-Key
Include the "X-API-Key" header in your API requests, and ensure it contains your API key.
X-API-Sign
Authenticated requests must be signed using the "X-API-Sign" header. The signature is generated with your private key, encoded payload, and the request method, following the HMAC-SHA512 algorithm:
Generating the signature
HMAC-SHA512 of ( + SHA256()) and base64-decoded
Signature Calculation Example:
For a POST request, you might calculate the signature as follows:
Request Method: POST
POST data: SHA256 hash of the JSON payload. Example of payload: "{"name":"John"}"
Concatenate the Request Method and SHA256 hash. Example: "POST" + "{"name":"John"}"
HMAC-SHA512: Apply HMAC-SHA512 using the concatenated string and the base64-decoded API Key secret
Code examples
const crypto = require('crypto');
function generateSignature(apiSecret, method, body) {
const payload = JSON.stringify(body);
const sha256Hash = crypto.createHash('sha256').update(payload).digest('hex');
const data = method + sha256Hash;
const signature = crypto.createHmac('sha512', Buffer.from(apiSecret, 'base64')).update(data).digest('base64');
return signature;
}
// Example Usage:
const apiKey = "your_api_key_here";
const apiSecret = "your_api_secret_here";
const method = "POST";
//When body is empty use empty object {}
const body = {
"order_direction": "buy",
"order_type": "limit",
"pair": "DEMONIZA/USDT",
"volume": "1",
"price": "0.85"
};
const signature = generateSignature(apiSecret, method, body);
console.log(`X-API-Sign: ${signature}`);
Last updated