Skip to content

Instantly share code, notes, and snippets.

@gadelkareem
Created August 16, 2021 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadelkareem/252f679d48365f5b9b2f04a55322e328 to your computer and use it in GitHub Desktop.
Save gadelkareem/252f679d48365f5b9b2f04a55322e328 to your computer and use it in GitHub Desktop.
Crypto coin prices on Google Sheets
/*
* use =coinMarketCap('ETH') in your sheet
*/
function coinMarketCap(symbol) {
const url = `https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=${symbol}&convert=EUR`
const headers = {
"X-CMC_PRO_API_KEY": 'API_KEY from https://pro.coinmarketcap.com/account'
};
const options = {
"method" : "get",
"headers" : headers
};
const response = UrlFetchApp.fetch(url, options);
return JSON.parse(response.getContentText()).data[symbol].quote.EUR.price;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment