API 101: Using Weather APIs in Postman (5)

— Juliet Edjere

In this module, we’ll explore some weather APIs in the context of different use cases to get more familiar with how REST APIs work.

One common API usage example is weather data.

It is understandable why we come across it on a daily basis on all platforms, from Google weather Search to Apple’s Weather app.

Many brands like Uber,  Ford, and Google Cloud use Weather APIs within their applications to integrate weather-related Insights and take account of disruptive weather events like heavy rain, snow, extreme temperatures, strong winds, and air pollution.

It's easy to get real-time data on the weather in your city today and put a weather forecast on your site. If you search “weather in London” on Google, you’ll see the current weather conditions and forecast.

There are many weather APIs that add weather data to your app. We'll compare some web’s best weather APIs. You’ll learn about API documentation by using a simple weather API.

By looking at these different weather APIs, we'll evaluate some differences in the way information is called and returned.

Make OpenWeatherMap API requests with Postman

OpenWeatherMap API is one of the popular choices for accessing high volumes of free weather data. It allows access to current weather data for any location in over 200,000 cities, forecasts, and weather maps, particularly useful if you are looking to build map-based interfaces.

OpenWeatherMap collects and processes weather data from different sources such as global and local weather models, satellites, radars and a vast network of weather stations. The data is available in JSON, XML, or HTML format.

Now let's make a request using OpenWeatherMap’s current weather data API endpoint.

Since we used Postman in the previous exercise with Spotify, we'll skip the basics of setting up Postman. If you need a refresher, you can revisit the previous module.

  1. Insert the following endpoint into the box next to GET: https://api.openweathermap.org/data/2.5/weather
  2. Next, edit the Query Params tab by passing the following three parameters in the key and value rows:
  3. key: q / value: London
  4. key: units / value: standard
  5. key: appid/ value: <insert your unique API key>

This call is made by city name for one location. You can call by city name, city ID, geographic coordinates, ZIP code.

Your endpoint should look like this:

https://api.openweathermap.org/data/2.5/weather?q=London&units=standard&appid=[{API key}](<https://home.openweathermap.org/api_keys>)

As detailed in the previous module, we need to get the unique API key to make requests to the weather API.

To get an API key for the OpenWeatherMap API, create an account at openweathermap.org. After you sign up, your API key is sent to the email address you provide. You can always find it on your account page under the "API key" tab.

  1. Click Send. The response appears in the lower pane.

Your Postman UI should look like this:

Did you notice the 200 - OK response?

You can make another API request, changing the way you specify the location. Instead of specifying the location by city name, specify the location using zip code in the format https://api.openweathermap.org/data/2.5/weather?zip={zip code},{country code}&appid=[{API key}](<https://home.openweathermap.org/api_keys>).

You can also replace the current weather endpoint with an endpoint for a 5-day forecast request.

You Save the Request and add it to your Postman collection. With this, you can automatically import the Postman collections to pull in similar requests.

Weather API 7-day Forecast

Now let’s switch APIs a bit.

WeatherAPI is a free geolocation and weather information provider with lots of different APIs ranging from real-time weather, weather forecast, IP lookup, sports, astronomy, historical weather, geolocation, and time zone.

WeatherAPI.com provides access to weather and geo data via a JSON/XML restful API.

Request to WeatherAPI.com API consists of base URL and API method. You can use either HTTP or HTTPS to request the API.

Base URL: http://api.weatherapi.com/v1

As always, API access to the data is protected by an API key. Authentication to the WeatherAPI.com API is provided by passing your API key as a request parameter. You need to signup to find your API key under your account.

Instead of getting the current weather as we did for OpenWeatherMap, let’s use another endpoint for WeatherAPI.com to get the forecast.

The forecast weather API method returns up to the next 10-day weather forecast and weather alert as JSON. The data is returned as a Forecast Object.

An endpoint to get 7-day weather forecast, which specifies a location for US Zipcode 07112, looks like this:

JSON: http://api.weatherapi.com/v1/forecast.json?key=<YOUR_API_KEY>&q=07112&days=7

Add in the query parameters for the API key and units. Include a valid API key with every request in order to access the API.

Enter details into Postman for the 7-day forecast request.

You can adjust the days and other parameters as detailed in the Weather API Documentation. In Postman, click the arrow next to Save and choose Save As. Then choose your collection and request a name.

WeatherAPI.com interactive API explorer allows you to test the APIs and methods. It returns response headers, response code and response body.

Enter several requests for the Aeris Weather API into Postman

Now let’s see some weather information from the Aeris Weather API.

With Aeris Weather API, there are many queries, filters, and other parameters you can use to configure the endpoint so it is a bit more complicated.

Let's make some requests to configure for Aeris.

Base URL Pathhttps://api.aerisapi.com/conditions/

Every request you make to the API must include the assigned client ID and secret key and may also include custom options with the request:

https://api.aerisapi.com/[:endpoint]/[:action]?client_id=[ID]&client_secret=[SECRET]

  1. You'll need an active AerisWeather API subscription to receive the access ID and secret key. Insert your own values for the CLIENTID and CLIENTSECRET.
  2. Get global current, forecast, and past conditions for a specific date/time or in hourly intervals using the conditions endpoint

Review Aeris API endpoints for a complete look at the types of weather data and options. The /[:endpoint]/[:action]? portion within the query template can be exchanged with any of the examples.

After you sign up for an account, click Account —> Apps —> New Application

You can paste the requests directly into the URL request box in Postman, and the parameters will auto-populate in the parameter fields.

Request URL https://api.aerisapi.com/conditions/minneapolis,mn?format=json&plimit=1&filter=1min&client_id=[CLIENT_ID]&client_secret=[CLIENT_SECRET]

200 - OK Response

Minutely precipitation forecasts are available in one-minute intervals for the next 60 minutes for locations globally by utilizing filter=minutelyprecip.

Now, get the weather forecast for your area or weather from a city using the observations endpoint:

http://api.aerisapi.com/observations/search?query=country:us&client_id=CLIENTID&client_secret=CLIENTSECRET&limit=1&sort=temp:-1

Find out the geographical information for a given location, including elevation, population, region, country, continent, etc. using the places endpoint:

http://api.aerisapi.com/places/closest?p=43.567,-100.895&limit=5&client_id=CLIENTID&client_secret=CLIENTSECRET

Find the global index for a variety of health and outdoor activities with the current and forecast indices endpoint. For the migraine index based on the latest observation, and for the next 5 days:

https://api.aerisapi.com/indices/migraine/55403?to=+5days&client_id=CLIENTID&client_secret=CLIENTSECRET

Alongside Postman, you can also make these requests by simply going to the URL in your address bar using the JSON Formatter extension for Chrome to automatically format the JSON response in the browser view.

Import Collections with Postman

Postman has an import feature that will automatically import collections into your own instance of Postman.

To use this, click the import link address below to automatically import the WeatherAPI, Aeris and OpenWeatherMap collections into Postman. Click Import in the upper-left corner. Then click the Import From Link tab, paste in the address and click Import.

OpenWeatherMap API collection

Copy this import link.

Weather API 7 day Forecast API collection

Copy this import link.

Aeris Weather API

Copy this import link.

You can embed a Run in Postman button in your website or README so developers can run the collection in Postman more easily. Alternatively, you can generate a shareable JSON public link to a static snapshot of your collection.

One thing to note is that while the way these weather APIs process information might be different, they have endpoints that you can configure with parameters.

Fundamentally, these weather APIs key and value are passed directly in the request URL as part of the query string, rather than using the Header field to pass the API keys like Bannerbear and Spotify. To process an API request, Bannerbear expects the API key to be included in a header to allow access to generate Images and Videos from templates.

Make a request for Tomorrow.io Weather

Let's consider another Weather API.

Tomorrow.io Weather API returns hyper-local weather data for weather types, moon phases, air quality and pollen indexes, and fire risks, with unique sensing technologies, including cell towers. Tomorrow.io provides recipes to build your own weather app.

The Tomorrow.io API is organized in a RESTful, stable endpoint structure, administered over HTTPS response codes and authentication. Uber uses Tomorrow.io.

Predefined locations can be queried in any of the data endpoints (/timeline, /route), however, they are mainly used by Monitors.

Retrieve a Location with https://api.tomorrow.io/v4/locations/locationId. The locationId is the string representing the unique identifier of a location that was created in the Locations API from the geometry attribute of a GeoJSON object according to RFC 7946.

Like other APIs, access to the Tomorrow.io API requires a valid access key with the right permissions, allowing it to be used to make requests to specific endpoints. A default, "private" access token is available on your Dashboard and allows access to all of your resources via the various endpoints.

In the above code, replace APIKEY with your own API key. Try it on Postman or Tomorrow.io

IBM’s The Weather Company

Here's another weather API to try.

IBM operates The Weather Company, including weather data APIs with current and historical weather data, basic location services, as well as hourly, daily, and intra-daily forecasts are available.

Google sources latest weather information from The Weather Company by their API, which sends them the in a way that’s easy for them to reformat.

📎 PREVIOUS MODULE - Make API Calls: Introduction to Restful APIs

📎 NEXT MODULE - Get started with Google Maps API


ABOUT ME

I'm Juliet Edjere, a no-code expert focused on design, product development, and building scalable solutions with minimal coding knowledge.

I document all things product stories, MVP validation, and how designs, data, and market trends connect.

Visit my website → built with Carrd and designed in Figma

Powered By Swish