In this guide, you’ll make your first successful request to the Current Weather API and learn how to handle the response and common errors. Before you start, you need:Documentation Index
Fetch the complete documentation index at: https://arnaud.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- 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.
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.
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
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.
Troubleshoot request errors
If your request fails, check the response status and error message.
| Status | Likely cause | Fix |
|---|---|---|
400 Bad Request | A required query parameter is missing or invalid. | Confirm that lat is between -90 and 90, lon is between -180 and 180, and both parameters are present. |
401 Unauthorized | The API key is missing, inactive, or invalid. | Confirm that appid uses an active key from My API keys. |
429 Too Many Requests | The API key exceeded its rate limit. | Wait at least one minute before retrying, or reduce request frequency in your app. |
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