If you’re a digital currency investor, you’re probably always on the lookout for new ways to track your investments. Google Sheets is a great way to keep track of your portfolio, and with a little bit of coding, you can even get the current price of Ethereum right in your spreadsheet.
In this article, we’ll show you how to use the Google Sheets API to get the current price of Ethereum, and then we’ll walk you through an example of how to use this information in a real-world scenario.
First, let’s take a look at how to get the current price of Ethereum using the Google Sheets API. To do this, we’ll need to use a script that calls the CoinMarketCap API.
This API provides us with the latest prices for all digital currencies, including Ethereum.
To get started, create a new Google Sheet and then click on Tools > Script Editor. This will open up the script editor for your sheet. Paste the following code into the script editor:
function getETHPrice() {
var response = UrlFetchApp.fetch(“https://api.coinmarketcap.
com/v1/ticker/ethereum/”);
var json = response.getContentText();
var data = JSON.parse(json);
return data[0].price_usd;
}.
This code uses the CoinMarketCap API to fetch the latest price of Ethereum in USD. The price is returned as a string, so if we want to use it in our spreadsheet, we need to convert it into a number. We can do this by adding the following line of code:
return Number(getETHPrice());
Now that we have our script set up, let’s take a look at how we can use it in our spreadsheet. In this example, we’ll use our script to track the value of 1 ETH over time.
To do this, we’ll set up two columns in our spreadsheet: one for dates and one for prices. We’ll then use our script to populate the prices column with the current price of Ethereum for each date.
First, enter all of the dates that you want to track into the first column of your spreadsheet. Then, in the second column, enter the following formula: =getETHPrice().
This will call our script and return the current price of Ethereum for each date that you entered.
You can then format your columns as currency or any other way that you like. You can also add additional columns to track your total investment value or profits over time.
That’s all there is to it! With just a few lines of code, you can easily track the value of Ethereum (or any other digital currency) in Google Sheets.