list icon indicating copy to clipboard operation
list copied to clipboard

Coinmarketcap API change of endpoint URI + API Key

Open gonzague opened this issue 4 years ago • 2 comments

Hey,

The Coinmarketcap API requires a key and the endpoints have changed :-) It's now reachable over https://pro-api.coinmarketcap.com/v1/** and it is possible to get a free API Key here https://pro.coinmarketcap.com

however I dont know how to fix the .js files

Thanks!

gonzague avatar Mar 22 '21 08:03 gonzague

Hey there,

Try this: replace "coinmarketcap" (for me, line 7) with this:

function coinmarketcap() {
  var options = {
    'headers' : {
      'X-CMC_PRO_API_KEY' : 'YOUR_API_KEY'
    }
  } 
  var url = "https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?convert=EUR&limit=400";
  var response = UrlFetchApp.fetch(url, options);
  var text = response.getContentText();
  var obj_array = JSON.parse(text);
  return obj_array;
}

I can't verify it works with the rest of the scripts as I'm having trouble with a seemingly separate problem with the Binance API and Google Docs. However, the code above is valid at least. You might have to edit the above URL with the correct end point as I'm not sure if the script expects "listings/latest". I'll update here if I get everything working correctly :).

stevegwh avatar Mar 24 '21 15:03 stevegwh

The code above works great thank you, however in my portfolio the Coins just have these symbols for values: ?????? Hoping this project gets updated :)

Thank you

KZkici avatar Jun 25 '21 13:06 KZkici