Created
March 24, 2014 06:17
-
-
Save zkarpinski/9735060 to your computer and use it in GitHub Desktop.
Returns the last trade price for a desired crypto-currency coin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*NOTE* 500 Server Internal Server Error status very common when used with multiple coins | |
//Returns the price of the desired coin in BTC or LTC | |
function GetCryptCoin(coin,base){ | |
const url = "http://pubapi.cryptsy.com/api.php?method=marketdatav2"; | |
if (base === null){base = "BTC"} | |
var response = UrlFetchApp.fetch(url).getResponseCode(); | |
if (response == 200) { | |
var cryptsydata = UrlFetchApp.fetch(url).getContentText(); | |
var object = JSON.parse(cryptsydata); | |
return object["return"]["markets"][coin + "\/"+base]["lasttradeprice"]; | |
} else { | |
return "Can't contact server"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment