Skip to content

Instantly share code, notes, and snippets.

@stw
Created June 7, 2017 14:01
Show Gist options
  • Save stw/dfb5f8206d197a04c24efbd60d5a3d3e to your computer and use it in GitHub Desktop.
Save stw/dfb5f8206d197a04c24efbd60d5a3d3e to your computer and use it in GitHub Desktop.
Pull Bittrex field
function search(nameKey, myArray){
for (var i=0; i < myArray.length; i++) {
if (myArray[i].MarketName === nameKey) {
return myArray[i];
}
}
}
function pullBittrex(market) {
var response = UrlFetchApp.fetch("https://bittrex.com/api/v1.1/public/getmarketsummaries");
var json = JSON.parse(response);
return search(market, json.result);
}
/**
* Pulls the bittrex field for the given market.
*
* @param {market, field} market.
* @return the field for the market.
* @customfunction
*/
function updateBittrexField(market, field) {
return pullBittrex(market)[field];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment