- An active OpenWeather account. If you don’t have an OpenWeather account, create one at https://home.openweathermap.org/users/sign_up.
- An active API key
- A terminal with curl
- Latitude and longitude for the location you want to query
OpenWeather recommends using coordinates for weather requests. Convert city names, ZIP codes, or addresses with the
Geocoding API before calling this endpoint.
1
Get an API key
OpenWeather generates an API key when you create an account.
- Sign in to your account.
- In the top menu, click your name > My API keys.
Make sure the status of your API key is Active. If the status is Inactive, click the toggle icon to
activate your API key.
2
Make your first call
Store your API key in an environment variable so you don’t paste secrets into shell history or source files.This request uses:
latandlonto identify Paris by coordinatesunits=metricso temperatures are returned in Celsiusappidto authenticate the request with your API key
3
Inspect the JSON response
If the request succeeds, the API returns a Key fields to handle in your application:
200 status and a JSON object like this:main.tempandmain.feels_likeuse the unit system requested withunits. In this tutorial, they are Celsius because the request usesunits=metric.weather[0].idis the stable weather condition code. Use it for application logic, and useweather[0].descriptionfor display text.weather[0].iconmaps to OpenWeather’s icon assets. For more info, see Weather conditions and icons.rain,snow, andwind.gustare optional. Check whether they exist before reading nested values.dt,sys.sunrise, andsys.sunsetare Unix timestamps in UTC.timezoneis the location’s shift from UTC in seconds. Use it when rendering local times.
4
Troubleshoot request errors
If your request fails, check the response status and error message.
5
Next steps
You can now:
- Review the full API reference
- Try
units=imperialor removeunitsto compare default Kelvin values - Request
mode=xmlormode=htmlif your integration needs another response format