Payout API-Authentication
API Authentication is done using an API key and a secret.
As an example, we will use the "/payout/create-single" endpoint to show how to authenticate. This can be used for all endpoints that requires authentication.
These are encoded as HTTP headers named:
x-api-key (Your API key)
12256412
x-signature (Signature created using your API secret)
49c6260c194f4d7ed5cb917dc70b9821673246b2abc1cf28f05df6a75fd24181e00f8e57b321d15ae45db58b3bffe27a
x-nonce (Timestamp in millisecond)
1618307861949
Javascript Example
const crypto = require("crypto");
const axios = require("axios");
const apiDomain = "{{API_DOMAIN}}";
const apiKey = "{{API_KEY}}";
const apiSecret = "{{API_SECRET}}";
async function sendRequest() {
const apiPath = "/trade/create-quote";
const nonce = Date.now().toString();
const httpMethod = "POST";
const signatureContent = JSON.stringify({ httpMethod, path: apiPath, nonce });
const sig = crypto.createHmac("sha384", apiSecret)
.update(signatureContent)
.digest("hex");
try {
const data = {
buy: "BTC",
sell: "USD",
trade_qty: 30,
trade_act: "buy",
receive_address: "bc1q554ltaa0ypzaf75f5kmpy73d5mudrr6rr9wl8u",
ref: "ref01"
};
const resp = await axios(`${apiDomain}${apiPath}`, {
method: httpMethod,
headers: {
"x-nonce": nonce,
"x-api-key": apiKey,
"x-signature": sig,
},
data: data
});
console.log("Result: ", resp.data);
} catch (error) {
console.log("error", error);
}
}
sendRequest();
Last updated