Create an account
To get started with the Current Weather Data API, you need to create a personal account.
- Go to https://home.openweathermap.org/users/sign_up.
- Fill in the form with the required info.
- Click Create account.
- In the confirmation email, click Verify your email.
Without a verified email address, you won’t be able to use the Current Weather Data API.
Get an API key
When your account is created, an API key is generated. You need this API key to call the Current Weather Data API.
- 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
Now that you have your API key, you are ready to make your first call to the Current Weather Data API.The following example shows how to get the current weather in Paris, France, using cURL in a terminal.Let’s look at the response:
- Open your terminal.
-
Copy and paste the following code snippet.
ReplaceAPI_KEYwith your API key from Step 2.The URLhttps://api.openweathermap.org/data/2.5/weatheris the endpoint for the Current Weather Data API.
Thelatandlonparameters specify the geographic coordinates for the location you want to retrieve weather data for. In this example, we’re using the coordinates for Paris, France.
Theappidparameter is where you need to provide your API key. OpenWeather recommends using the Geocoding API to convert city names or ZIP codes into coordinates, and notes that the built-in geocoder is deprecated.
- The
coordobject includes the longitude (lon) and latitude (lat) of the location. The returned coordinates may reflect the nearest weather station rather than the exact input. - The
weatherarray includes:id: Weather condition identifier. For more information, see the Weather condition codes.main: Group of weather parameters.description: Weather condition description.icon: Related weather icon. For more information, see Weather conditions and icons.
- The
mainobject includes:temp: Current temperature in Kelvin.feels_like: Perceived temperature.temp_minandtemp_max: Optional min and max temperatures observed at the current moment within a large city or urban area. These can differ fromtempdue to variations across the area. At the time of the API call,289.28is the Kelvin temperature (main.temp).
- The
windobject includes:speed: Wind speed in meters/second.deg: Wind direction in degrees.gust: Wind gust (optional and only present when available).
- The
cloudsobject shows the cloudiness percentage (all). rainandsnowobjects are optional and only present when there is precipitation.- The
sysobject includes:country: The location’s country code.sunrise: Sunrise time in Unix time (seconds since Jan 1, 1970, UTC).sunset: Sunset time in Unix time (seconds since Jan 1, 1970, UTC).
Troubleshooting
- 401 Unauthorized: Your API key is missing or invalid. Make sure the
appidvalue matches an active key. - 400 Bad Request: You’re missing required query parameters (for example,
latorlon). - 429 Too Many Requests: You’ve exceeded the rate limit. Wait at least a minute before retrying.