How to connect the Weatherstack API to Google Sheets

Weatherstack is a weather API from the API provider Apilayer. The Weatherstack API is designed to provide weather updates for anyone who needs them. We can use the Weatherstack API to display current, past, and predicted weather data in Google Sheets. In this tutorial, we’ll show you how to connect the Weatherstack REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose a Weatherstack API Endpoint
  4. Enter the Weatherstack API request into Apipheny
  5. Run the Weatherstack API Request in your Google Sheet

Step 1.) Install and open the Apipheny add-on in Google Sheets

To pull data from the Weatherstack API into Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. 

1. Install Apipheny by clicking here on desktop and then clicking the Install button on the next page

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets:

Opening the Apipheny add-on in Google Sheets
Opening the Apipheny add-on in Google Sheets

Step 2.) Obtain an API key

After signing up for the Weatherstack API, a page containing your API Access Key will be displayed:

Weatherstack dashboard
Weatherstack dashboard

Copy and paste your API Access Key in a safe location because you’ll need it in the next steps.

Step 3.) Choose a Weatherstack API endpoint

In this section, we’ll show you how to browse the Weatherstack API documentation to find an API endpoint that retrieves the specific information you need from the Weatherstack API. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the Weatherstack API documentation page: https://weatherstack.com/documentation

The menu on the left contains general information about the Weatherstack API and a list of API endpoints:

Weatherstack documentation page
Weatherstack documentation page

In this example, we will describe the Historical Weather endpoint, that is used to look up historical weather data all the way back to 2008. The whole URL for this endpoint is:

http://api.weatherstack.com/historical?access_key=YOUR_ACCESS_KEY&query=CITY&historical_date=DATE&hourly=1

The documentation for this endpoint contains a short description of the endpoint’s purpose, the accepted path parameters and the responses it can return:

Historical Weather endpoint documentation
Historical Weather endpoint documentation

All API calls to the Weatherstack API should be made to the http://api.weatherstack.com/ base domain. All endpoints and parameters should be appended to this base domain.

Step 4.) Enter the Weatherstack API request into Apipheny

Okay, we’re in the home stretch. Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab. With the Import Tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your Weatherstack API endpoint. For this example, we are using the GET method.

API URL: In Step 3, we explained how you can find the Weatherstack API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the Current weather endpoint that returns the current weather for a specific city. The corresponding URL for this endpoint is:

http://api.weatherstack.com/current?access_key=ACCESS_KEY&query=CITY

If you use this same URL, don’t forget to replace ACCESS_KEY with the value you previously obtained in Step 2, and replace CITY with a real city name.

Headers are not required for this API request, so you can leave this section blank in Apipheny.

Here’s what our request looked like when entered into Apipheny.

Weatherstack API request entered into Apipheny
Weatherstack API request entered into Apipheny

Step 5.) Run the Weatherstack API request in your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your Weatherstack data will be imported into your Google Sheet, like so:

Weatherstack data imported into Google Sheets
Weatherstack data imported into Google Sheets

After making a successful request to the Weatherstack API, try querying a different Weatherstack API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

Related Posts