Author

Topic: getting live btc price into spreadsheet (Read 4226 times)

member
Activity: 112
Merit: 10
May 18, 2013, 05:08:02 AM
#2
I build a function to do this.
Just go to Tools -> Script-Manager -> New
Name it something like MtGox.gs and insert the following code:
Code:
function getMtGoxPrice(s1, s2) {
  if (s1 == null){ s1 = "btc"; }
  if (s2 == null){ s2 = "usd"; }
  var symbol = s1+""+s2;
  symbol = symbol.toUpperCase();
  var url = "https://data.mtgox.com/api/2/"+symbol+"/money/ticker";
  var data = UrlFetchApp.fetch(url);
  var btcdata = data.getContentText();
  var object = JSON.parse(btcdata);
  var price = parseFloat(object["data"]["last"]["value"]);
  return price;
}

Now you can simply click into a spreadsheet cell and enter
Code:
=getMtGoxPrice()
or
Code:
=getMtGoxPrice("BTC", "EUR")
hero member
Activity: 518
Merit: 500
Any easy way to get latest mtgox price into google spreadsheet cell?

tia
Jump to: