AUTOMATE SCRIPT

Integration of Bitstamp api with Google sheets using Google apps script

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 = '<Your API key here>';
  var secret = '<Your API secret here>';
  var customer_id = '<Your customer id here>';
  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);
}