emmtte / list

Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coinmarketcap API change of endpoint URI + API Key

gonzague opened this issue · 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!

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 :).

commented

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