-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathAPI_Kucoin.js
26 lines (21 loc) · 879 Bytes
/
API_Kucoin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// I assume that key and secret API are in the "Config" spreadsheet. The key is in cell B14 and the secret in cell B15
function Kucoin () {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Config");
var key = sheet.getRange("B14").getValue()
var secret = sheet.getRange("B15").getValue();
var nonce = Math.floor(new Date().getTime())
var postdata = "timestamp=" + nonce
var shaObj = new jsSHA("SHA-256", "TEXT");
shaObj.setHMACKey(secret, "TEXT");
shaObj.update(postdata);
var signature = shaObj.getHMAC("HEX");
var path = api + "?" + postdata + "&signature=" + signature;
var url = "https://www.binance.com" + path;
var options = {
method: 'get',
headers: {'X-MBX-APIKEY': key}
};
var response = UrlFetchApp.fetch (url, options);
var data = JSON.parse(response.getContentText());
return data
}