Automate Air Quality Data Imports To Google Sheets

Reading Time: 5 minutes

This article covers how to automate air quality data imports to Google Sheets. With the Air Quality API, you can import real-time as well as historical data to Google Sheets in a go.  

Importing data manually can be a tedious task. However, it need not remain so. Using Amigo Data, you can easily connect to the data source and import the data into Google Sheets and get them updated automatically.

We’ll use Amigo Data, a Google Sheets extension to help fetch and update data directly from Air Quality API without needing any code.

Steps to import Air Quality data to Google Sheets:

How to automate Air Quality data imports to Google Sheets

Here’s the step-by-step guide to import Air Quality data to Google Sheets

Step 1: Install the Amigo Data add-on

Install the Amigo Data Google Sheets add-on from the Google Workspace Marketplace.

Amigo Data in Google Workspace Marketplace

Click here to install.

Alternatively, you can get it from Google Sheets.

  • Open a new sheet
  • Go to Extensions→Add-ons→Get add-ons
  • Search for Amigo Data and install

Step 2: Generate the API key

In order to access the Air Quality API data, we’ll need a key called the API key. It is a code used to identify and authenticate access.

Follow the steps below to get an API key from RapidAPI. RapidAPI is an API marketplace. 

Sign up for  RapidAPI

RapidAPI page to sign up

Once you’re logged in, go to the Air Quality API documentation page in RapidAPI 

Air Quality API documentation page to study how to automate air quality data imports to Google Sheets

Choose a subscription plan from the Pricing menu. Choose the Basic option. 

Choose for basic plan

Click on the endpoints and scroll down a bit and you will find your API key

API key is generated

Step 3: Choose an endpoint

For this tutorial, we will import the air quality forecast data. It provides us with a 3-day (72 hours) forecast for any location in the world given a latitude and longitude. So, select the AirQualityForecast option.

Select the Air Quality Forecast option

The header parameter consists of the API key and API host. In the required parameters section we have to input the lat (latitude) and lon (longitude) values. You can refer to this link to find latitude and longitude coordinates for any place. By default the number of hours is set to 72, you can also specify the number of hours (optional parameter). For this tutorial, we will import the air quality data for New York. 

Enter the lat and lon values

Enter the lat (latitude) and lon (longitude) details of New York. 

Enter the lat and lon values

Click the Test Endpoint to run the query 

Test endpoints

The success message indicates that the endpoints are functioning correctly. 

Success

On the right side under code snippets, select shell-> cURL from the dropdown menu

Select the cURL from Shell

Copy the URL excluding the apostrophes and also note down the headers. This is the endpoint URL for the data to import to Google Sheets.

Copy the URL excluding the quotations and also note down the headers

Step 4: Import the Air Quality data to Google Sheets

Go back to Google Sheets and launch the Amigo Data extension.

Launching Amigo Data in Google Sheets

Select Custom API from the list of sources

Selecting the source in Amigo Data

Paste the endpoint in the API URI bar

Pasting the endpoint

Then expand the Details tab and enter the following as headers:

Name: X-RapidAPI-Host, Value: air-quality.p.rapidapi.com

Name: X-RapidAPI-Key, Value: your_key

Replace your_key with your RapidAPI key.

Add the headers and their respective values

Then click the PREVIEW button

Flatten the data points and then click IMPORT.

Click preview then flatten and then import the data

A snippet of the imported data.

Snippet of the data imported from the Air Quality API to Google Sheets

You can likewise import other types of data from the Air Quality API. Following are some other examples.

Current Air Quality

This endpoint can be found below the Air Quality Forecast endpoint. You can import current air quality data by simply entering the lat (latitude) and lon (longitude) details. 

Select the Current Air Quality endpoint

Air Quality history

This endpoint can be found below the Current Air Quality endpoint. It returns the past 24 hours of air quality observations for any point in the world given a latitude and longitude

Select the air quality history endpoint

You can go through the documentation page, you can explore more endpoints, and try them out. 

After importing the data, you can also set a refresh schedule so that the data are updated automatically at regular intervals. To learn how to set a refresh schedule, follow this link.

There are several other types of data that you can import into Google Sheets using Amigo Data such as AccuWeather data,  NASA data, Nasdaq data, and many more. 

Some related articles you may be interested in:

https://blog.tryamigo.com/import-accuweather-data-to-google-sheets/

https://blog.tryamigo.com/how-to-import-nasa-data-to-google-sheets/

https://blog.tryamigo.com/import-data-from-nasdaq-to-google-sheets/