In this tutorial, you will learn how to connect the OpenWeather REST API to Google Sheets in 5 steps:

  1. Install the Apipheny Add-on
  2. Obtain an API Key
  3. Obtain an Endpoint URL
  4. Enter OpenWeather API into Apipheny
  5. Run the OpenWeather API request

Step 1.) Install and open the Apipheny Add-on for Google Sheets

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

Apipheny is an API integrator for Google Sheets. You can use it to make unlimited API requests and connect to unlimited API data sources. Plus you can save your API requests and more. Click here for more information about Apipheny. There’s a 30-day free trial included, then it’s $19-$29/month.

1. Install Apipheny by opening the following link in on desktop and then clicking the Install button on the next page: https://gsuite.google.com/marketplace/app/apipheny/966163326746

Install Apipheny
Install Apipheny

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons 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.

Open Apipheny
Open Apipheny

Step 2.) Get your OpenWeather API Key

After you’ve signed up for an OpenWeather account and verified your email, a confirmation email with your API key and technical instructions will be sent to your email address:

Email from OpenWeather with API key
Email from OpenWeather with API key

Please note that it could take up to 2 hours to activate your API key.

Step 3.) Get your OpenWeather Endpoint URL

In this section, we’ll show you how to browse the OpenWeather API documentation to find the API URL that will retrieve the weather information that you need. If you already know your URL, or you want to use the same example URL as us, just skip to Step 4.

First, open the OpenWeather API documentation page: https://openweathermap.org/api

This page contains a structured view of the available APIs, each with an accompanying description:

OpenWeather API documentation
OpenWeather API documentation

Below the list of available APIs, there’s a section containing links to each API and to each of the API’s corresponding endpoints:

OpenWeather APIs and endpoints
OpenWeather APIs and endpoints

Clicking on an API opens a dedicated page for that API, containing the list of associated endpoints. A menu on the right side of the page presents a grouped view of this list. For instance, the page for Weather Alerts lists its 15 available endpoints: Create trigger, Create alerts by trigger, all the way to History alerts:

Weather Alerts API documentation
Weather Alerts API documentation

All API calls to OpenWeather should be made to the https://api.openweathermap.org/data/3.0/ base domain.

OpenWeather API root/base URL:

https://api.openweathermap.org/data/3.0/

An example endpoint is Get triggers, so here’s what the URL would look like for this endpoint:

http://api.openweathermap.org/data/3.0/triggers

The documentation for each endpoint contains the HTTP method used (eg. GET), the link you should append to the root API URL for querying this endpoint (eg. /triggers), a short description of the endpoint’s purpose, and a response example:

OpenWeather Endpoint Documentation
OpenWeather Endpoint Documentation

The description of the available parameters and of the returned data structure is provided as a link to a separate page, for example, https://openweathermap.org/triggers-struct:

OpenWeather API endpoint documentation
OpenWeather API endpoint documentation
OpenWeather API endpoint parameters
OpenWeather API endpoint parameters

Step 4.) Enter the OpenWeather API URL Into Apipheny

Go back to your Google Sheet and make sure that the Apipheny add-on is open to 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) required by your API endpoint. For this example, we are using the GET method.

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

For this example, we will obtain the current weather for a specific city, and this is the API URL we will use:

https://api.openweathermap.org/data/2.5/weather?q=<city_name>&appid=<your_api_key>

Where <city_name> represents the name of the city you want the current weather for, and <your_api_key> is the key emailed to you in Step 2.

In this example we chose Chicago as the city_name.

 Headers aren’t required for this API request.

OpenWeather API request entered in Apipheny
OpenWeather API request entered in Apipheny

Step 5.) Run the OpenWeather API Request

Click the Run button at the bottom of the Apipheny add-on and then wait for the OpenWeather API data to be added to your Google Sheet:

Weather API data in Google Sheets
Weather API data in Google Sheets

After making a successful request to the OpenWeather API, try querying a different endpoint, or try using one of the more advanced features in the Apipheny add-on to supercharge your spreadsheet.

If you want to learn how to connect more APIs to Google Sheets, check out these related articles:

Related Posts

Leave a Comment