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:
- Install the Amigo Data add-on
- Get the Air Quality API key
- Choose the data endpoint
- Import 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.
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
Once you’re logged in, go to the Air Quality API documentation page in RapidAPI
Choose a subscription plan from the Pricing menu. Choose the Basic option.
Click on the endpoints and scroll down a bit and you will find your API key
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.
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 (latitude) and lon (longitude) details of New York.
Click the Test Endpoint to run the query
The success message indicates that the endpoints are functioning correctly.
On the right side under code snippets, select shell-> cURL from the dropdown menu
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.
Step 4: Import the Air Quality data to Google Sheets
Go back to Google Sheets and launch the Amigo Data extension.
Select Custom API from the list of sources
Paste the endpoint in the API URI bar
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.
Then click the PREVIEW button
Flatten the data points and then click IMPORT.
A snippet of the imported data.
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.
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
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/