How to get the current price of a cryptocurrency on google sheets from coinmarketcap

0 votes

On a google sheets cell I want to get only the current cryptocurrency price with this formula:

=ValueCrypto(A1)

I tried this function for coinmarketcap:

function ValueCrypto(crypto) { var url = "https://api.coinmarketcap.com/v1/ticker/" + crypto + "/?convert=EUR"; var response = UrlFetchApp.fetch(url); var data = JSON.parse(response.getContentText()); return data[0].price_eur; }


the function gives me the error "We no longer serving this endpoint here"

I also tried to change the endpoint and I added my API key into the function:

function ValueCrypto(crypto) { var url = "pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=" + crypto var requestOptions = { method: 'GET', uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest', qs: { start: 1, limit: 5000, convert: 'EUR' }, headers: { 'X-CMC_PRO_API_KEY': 'myapikey' }, json: true, gzip: true }; var response = UrlFetchApp.fetch(url); var data = JSON.parse(response.getContentText()); return data[0].price_eur; }

and the errors now are Exception: Request failed for http://pro-api.coinmarketcap.com returned code 401. Truncated server response:

{ "status": { "timestamp": "2021-01-02T11:31:39.880Z", "error_code": 1002, "error_message": "API key missing.", ... 

Apr 6 in Blockchain by Rahul
• 8,980 points
66 views

1 answer to this question.

0 votes

Your code does not appear to use requestOptions which is where the API key is defined. Try passing it to UrlFetchApp like this:

var response = UrlFetchApp.fetch(url, requestOptions);

answered Apr 12 by Soham
• 8,730 points

Related Questions In Blockchain

0 votes
1 answer

How to get the current state of a smart contract?

Hey, you gotta provide the contract code, and ...READ MORE

answered Aug 1, 2018 in Blockchain by Perry
• 17,100 points
466 views
0 votes
1 answer

How to get data from Google Finance to Google sheets?

You need to have a from and ...READ MORE

answered Aug 21, 2018 in Blockchain by slayer
• 29,310 points
737 views
0 votes
0 answers
0 votes
1 answer

How to get a list of Coinbase CryptoCurrency Coins

The following code: import requests ...READ MORE

answered Apr 8 in Blockchain by Rahul
• 8,980 points
39 views
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,440 points
606 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
918 views
0 votes
1 answer
0 votes
1 answer

How To Get BTC Price on Binance from Binance API

In the Script environment for Apps, the ...READ MORE

answered Feb 28 in Blockchain by Soham
• 8,730 points
99 views
0 votes
1 answer

How can merkle trees help validate the content of a block in a blockchain

As long as they are centralized entities ...READ MORE

answered Feb 28 in Blockchain by Soham
• 8,730 points
69 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP