Reputation: 21
I am looking to bring in the "bid" values from each "ticker" from this API call https://api.etherdelta.com/returnTicker into Google Sheet cells.
An example cell value will have something like: =crypt("PPT)
.
Here is the code I have so far, but I am having a hard time figuring out how I can get the data for each ticker (I know I haven't declared "ticker" anywhere in the code).
function crypt(ticker) {
var url = "https://api.etherdelta.com/returnTicker";
var response = UrlFetchApp.fetch(url);
var text = response.getContentText();
var json = JSON.parse(text);
var price = json[bid];
return parseFloat(bid);
}
Upvotes: 2
Views: 975
Reputation: 201613
How about the following modifications?
ETH_
.ETH_
+ ticker is a key of the object.
=crypt("PPT")
is used, the key is ETH_PPT
and "bid" you want is in the value of ETH_PPT
.The modified script which was reflected above is as follows.
function crypt(ticker) {
var url = "https://api.etherdelta.com/returnTicker";
var response = UrlFetchApp.fetch(url);
var text = response.getContentText();
var json = JSON.parse(text);
var price = json["ETH_" + ticker].bid; // Modified
return parseFloat(price); // Modified
}
This modified script retrieves the value of bid
for each ticker by putting =crypt("PPT")
to a cell in the spreadsheet.
If I misunderstand your question, I'm sorry.
Upvotes: 2