Introduction
An example use case for the OpenWeather REST API is:
You're creating a website to display today's weather.
This article explains how to view the JSON for the weather data, including:
- Description.
- Temperature.
View your API key
Note: After you create your API key, you will need to wait 1-3 hours for the key to activate.
- Go to: https://openweathermap.org
- Scroll down to the page's footer.
- Click on "Subscribe for free". Then complete the form.
- Open a new tab in your browser. Then open your email provider's app.
- Log into your account. Then open the email sent by OpenWeather.
-
Click the button: "Verify your email".
In your browser, you will see a new browser tab appear displaying the OpenWeather app.
- In your browser, close the previous browser tab displaying the OpenWeather app.
- (Optional) Log out of your email account. Then close the browser tab.
-
On the OpenWeather app, click the sub-heading: "API Keys".
You will see your API key displayed in a table.
Input your API key
- Go to: https://www.postman.com
- In the top-right corner, click: "Sign-up for free". Then complete the form.
- In the app's header, click "Workspaces" > "My workspace". Then click the "+" button in the subheader to open a new tab.
- In the OpenWeather app, click the "API" button in header.
- Under the heading, "Current Weather Data", click the button: "API doc".
-
Under the "API call" heading, highlight-then-copy the beginning section
of the URL.
https://api.openweathermap.org/data/2.5/weather
-
In the Postman app, paste the URL to the right of the "GET"
button.
Note: If the API key isn't activated yet, you will receive an error message in later steps.
-
In the OpenWeather app, look under the "Parameters" heading to view which
are required:
- lat, lon [geographic coordinates: latitude and longitude]
- appid [your API key]
Note: For this example, we use the approximate coordinates for Toronto: "45, -80".
- In the top-right corner of the page, click on your username > "My API keys".
- Highlight-then-copy the API key.
-
In the Postman app, you will see the subheading: "Parameters".
- In the first field on the first row, type-in: "lat". In the second field type-in: "45".
- In the first field on the second row, type-in: "lon". In the second field type-in: "-80".
- In the first field on the third row, type-in: "appid". In the second field, paste your API key.
View the JSON data
- Click the blue "Send" button.
-
In the field at the bottom of the page, you will see the results formatted
in JSON. For example:
{ "coord": { "lon": -80, "lat": 45 }, "weather": [ { "id": 804, "main": "Clouds", "description": "overcast clouds", "icon": "04d" } ], "base": "stations", "main": { "temp": 293.89, "feels_like": 293.95, "temp_min": 293.89, "temp_max": 293.89, "pressure": 1015, "humidity": 74, "sea_level": 1015, "grnd_level": 994 }, "visibility": 10000, "wind": { "speed": 4.21, "deg": 283, "gust": 4.81 }, "clouds": { "all": 91 }, "dt": 1657735238, "sys": { "country": "CA", "sunrise": 1657705540, "sunset": 1657760724 }, "timezone": -14400, "id": 6137276, "name": "Sahanatien", "cod": 200 }
-
In the data, you can see the:
- Description is: overcast clouds.
- Temperature is: 293.89 Kelvin.