Skip to main content

Integrating Google Sheets

Updated over 3 weeks ago

Routescan provides a suite of APIs that let you query real-time onchain data and integrate it directly into your tools, dashboards, or workflows. This guide will walk you through the process of connecting the Routescan API calls to a Google Sheet, enabling you to pull and analyze blockchain data directly in a familiar spreadsheet environment. This is a perfect solution for creating custom dashboards for token balances, transaction histories, and more, without needing a dedicated developer.

You will need a Google Account for this tutorial. A Routescan API key is not required if you are within the free tier.


Setting up Your Google Sheet

First, you need to prepare your Google Sheet to handle API calls. We will be using a custom script that can parse JSON data returned by the Routescan API.

  1. Open a new Google Sheet.

  2. From the menu bar, go to Extensions > Apps Script. A new browser tab will open with the script editor.

ImportJSON script on GitHub

Adding the ImportJSON Script

To easily handle the JSON data from our API requests, we will add a script to our project. You can find this script on GitHub developed by @bradjasper and @tommyvernieri. It's an open-source solution for parsing JSON in Google Sheets.

  1. In the Apps Script editor, delete any existing code and copy-paste the ImportJSON script.

  2. Save the script by clicking the save icon or pressing Ctrl + S.

ImportJSON script on GitHub

Making Your First API Request

Now that the script is in place, you can make an API call directly from any cell in your Google Sheet using a formula.

The basic structure of a Routescan API call: https://api.routescan.io/v2/network/[network]/evm/[chain-id]/[module]?[action]&apikey=[your_api_key]

The basic structure of a Routescan Etherscan-like API call:

https://api.routescan.io/v2/network/[network]/evm/[chain-id]/etherscan/api?[module]/&[action]&apikey=[your_api_key]

  • Replace [network] with mainnet or testnet.

  • Replace [chain-id] with the ID of the network.

  • Replace [module] and [action] depending on the specific API endpoint you want to use (e.g., "addresses" or "blocks").

  • Replace [your_api_key] with any placeholder or remove the query parameter completely, if you are within the free tier.

In the following example, we are extracting API call data directly into our Google Sheets document that gives us information about Ethereum addresses with a 25 addresses limit. We can specifically indicate which API response data we want to include in our final parsing by utilizing the query parameters after our endpoint.

=ImportJSON("<https://api.routescan.io/v2/network/mainnet/evm/1/addresses?limit=25>", "/items/chainId,/items/address,/items/balance,/items/balanceValueUsd", "allHeaders")

To precisely control how data is imported, you can use additional options in the third argument of the ImportJSON function, such as:

  • noInherit – Don’t copy parent values into child rows

  • noTruncate – Show full text (not cut after 256 characters)

  • rawHeaders – Keep original JSON paths as headers

  • noHeaders – Remove the header row (show only data)

  • allHeaders – Show all headers from your query, even if empty

  • debugLocation – Add row/column info in each cell (for debugging)

  1. In your Google Sheet, enter a formula in a cell, replacing the placeholders with your data.

  2. Press Enter. The cell will populate with the requested data from the Routescan API.

Final result of the importJSON script

💡Hint: You can build upon the existing script to add an Auto Refresh feature.

By utilizing Google Sheets and the Routescan API, you can easily build custom tools for tracking and analyzing onchain data. This approach puts a block explorer key data right into your spreadsheet, enabling a wide range of use cases for both developers and analysts.

Did this answer your question?