In this Post, we Integrate google sheets to Bitstamp API through the ‘authenticated’ section of the API so I can access my account information.
This Script is to Get account balances from Bitstamp.
function Bitstamp() {
eval(UrlFetchApp.fetch('https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.3.1/sha256.js').
getContentText());
var key = '';
var secret = '';
var customer_id = '';
var nonce = new Date().getTime().toString();
var message = nonce + customer_id + key
var shaObj = new jsSHA("SHA-256", "BYTES");
shaObj.setHMACKey(secret, "BYTES");
shaObj.update(message);
var signature = shaObj.getHMAC("HEX").toString().toUpperCase();
Logger.log(signature)
var url = "https://www.bitstamp.net/api/v2/balance/";
var formData = {
"key": key,
"signature": signature,
"nonce": nonce
};
var options = {
"method": "post",
"muteHttpExceptions": true,
"payload": formData
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response);
var data = JSON.parse(response.getContentText());
Logger.log(data);
}