· 8 years ago · Jan 14, 2018, 03:10 AM
1 const host = "https://api.kucoin.com";
2 const endpoint = "/v1/account/balances";
3
4 const APIKey = exchangeKeys.key;
5 const secretKey = exchangeKeys.secret;
6
7 const nonce = new Date().getTime()
8 const stringForSign = `${endpoint}/${nonce}/`;
9
10 const signatureStr = base64(stringForSign).replace(/\&$/, stringForSign);
11
12 const signatureResult = CryptoJS.HmacSHA256(
13 signatureStr.replace(/\&$/, ""),
14 secretKey
15 ).toString();
16
17 axios({
18 url: `${host}${endpoint}`,
19 headers: {
20 'Content-Type': 'application/json',
21 "KC-API-KEY": APIKey,
22 "KC-API-NONCE": nonce,
23 "KC-API-SIGNATURE": signatureResult
24 }
25 })
26 .then(response => {
27 console.log("SUCCESS");
28 console.log(response);
29 })
30 .catch(error => {
31 console.log("ERROR");
32 console.log(error);
33 });