Bitcoin Forum
May 17, 2024, 01:07:38 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getting live btc price into spreadsheet  (Read 4231 times)
empoweoqwj (OP)
Hero Member
*****
Offline Offline

Activity: 518
Merit: 500


View Profile
May 18, 2013, 07:12:10 AM
 #1

Any easy way to get latest mtgox price into google spreadsheet cell?

tia
DaSheep
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile
May 18, 2013, 10: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")

"That’s all I know."
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!