1

I'm working with getting crypto pricing on my google sheet but I keep getting an error message. I've looked around and haven't really come across anything for CoinGecko. Below is the error message. "Exception: Request failed for https://api.coingecko.com returned code 429. Truncated server response: error code: 1015 (use muteHttpExceptions option to examine full response) (line 843).".

Here is the code starting line 843 to 865

var res = await UrlFetchApp.fetch(url);
var content = res.getContentText();
var parsedJSON = JSON.parse(content);

var data=[]
if (type=="price"){
  for (var i = parsedJSON['prices'].length - 1; i >= 0; i--) {
    data.push([toDateNum(parsedJSON['prices'][i][0]),parsedJSON['prices'][i][1]]);
    };}
else if (type=="volume")
{ for (var i = parsedJSON['total_volumes'].length - 1; i >= 0; i--) {
    data.push([toDateNum(parsedJSON['total_volumes'][i][0]),parsedJSON['total_volumes'][i][1]]);
    };}
else if (type=="marketcap")
{ for (var i = parsedJSON['market_caps'].length - 1; i >= 0; i--) {
    data.push([toDateNum(parsedJSON['market_caps'][i][0]),parsedJSON['market_caps'][i][1]]);
    };}
else 
{ data="Error";}

if (data!="Error")
  cache.put(id_cache, JSON.stringify(data),expirationInSeconds);
return data;

Any insight would be great. Here's the link to the GS to see entire code in apps script.https://docs.google.com/spreadsheets/d/1Jtfcw7qLWbMcHfSWfJcExBVo3DRI1iP74wPBdPeybWA/edit#gid=388229362

Rubén
  • 34,714
  • 9
  • 70
  • 166
Mitchell Bivens
  • 97
  • 2
  • 12

1 Answers1

2

When you have the spreadsheed and need to past number 1 line they told you, change the number from 250 to 251. IT WILL WORK

From =ImportJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false","/name,/current_price,/market_cap,/price_change,/total_volume,/high_24h,/low_24h","noTruncate",doNotDelete!$A$1)

To =ImportJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=251&page=1&sparkline=false","/name,/current_price,/market_cap,/price_change,/total_volume,/high_24h,/low_24h","noTruncate",doNotDelete!$A$1)

  • Please make use of the code embed function, this will gain a much better understanding and readable answers for our eyes :). The rest looking good, keep up the good work! – dutchsociety Oct 30 '21 at 00:09
  • Thank you! Sorry for the delay in the response. I've been really bad sick the past couple of weeks and just getting back on. – Mitchell Bivens Nov 08 '21 at 21:57