Integrating Google Sheets
A valid Etherscan API key and a Google Account is required to follow along this tutorial.
1. Integrating Google Apps Script
In a new Google Sheets document, head over to Extensions
> Apps Script
.
We'll be utilizing an open source script called ImportJSON developed by @bradjasper and @tommyvernieri to help parse JSON responses returned by the API endpoints.
Paste the source code into the script editor, optionally you can rename the file to ImportJSON.gs
.
2. Setting up auto refresh
Add a new Sheet from the small "+" icon at the bottom left and name it AutoRefresh
.
Back to Google Apps Script, create a new file and name it AutoRefresh.gs
. Paste in this following code.
The idea of this script is to generate a random number to the AutoRefresh sheet, which is then appended to the end of the ImportJSON request.
Google Sheets only performs a new request if it detects that a formula has changed.
Select the function as AutoRefresh
, event source as Time Driven
, time based trigger to Minutes Timer
and minute interval to Every Minute
.
3. Making an API request
Once you have added both scripts, go back to Sheet1 and start making API endpoint calls with the following syntax in cell A1.
Extending and Building a Dashboard
While the above was a straightforward method to call an API endpoint and output the response into a Google Sheet, it could use further optimizing and data formatting.
Last updated