Script request failed but browser request not

32 views Asked by At

Which day I can not understand the reason for such a problem. I'm trying to get data from the Coingecko API in Google App Script. The simplest script

function ping() {
  var url = 'https://api.coingecko.com/api/v3/ping';
  var params = {
    'cache-control': 'public,max-age=300',
    'content-type': 'application/json', 
    'expires': 'Tue,04 Oct 2022 23:59:39 GMT'
  };

  var response = UrlFetchApp.fetch(url, params);
  var data = JSON.parse(response.getContentText());

  Logger.log(data);
}

gives an error message

Exception: Request failed for https://api.coingecko.com returned code 429. Truncated server response: {"status":{"error_code":429,"error_message":"You've exceeded the Rate Limit. Please visit https://www.coingecko.com/en/api/pricing to subscribe to ... (use muteHttpExceptions option to examine full response)

But! I immediately enter a request in any browser https://api.coingecko.com/api/v3/ping And I get a normal response

{"gecko_says":"(V3) To the Moon!"}

What does this mean and how to deal with it?

0

There are 0 answers