Created
August 16, 2021 22:48
-
-
Save gadelkareem/252f679d48365f5b9b2f04a55322e328 to your computer and use it in GitHub Desktop.
Crypto coin prices on Google Sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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