Current Weather Conditions
Learn how to get current weather conditions data.
Overview
The Current Conditions API allows us to get the current weather conditions data for a specific location. It provides detailed information, including the current temperature, wind speed, precipitation summary, information on cloud cover, and atmospheric pressure.
Endpoints for current conditions
In this lesson, we learn how to retrieve the current weather conditions data for a specific location and for the top cities around the globe.
Current conditions for a specific location
We make a GET
request to the following URL to get the present conditions data for a location of our choice:
http://dataservice.accuweather.com/currentconditions/v1/{locationKey}
Current conditions for top cities
We make a GET
request to the following URL to get the present conditions data for the specified number of top cities around the world:
http://dataservice.accuweather.com/currentconditions/v1/topcities/{group}
Note: The ranking of the cities is based on a number of factors, including, but not limited to, the population of the city, its political importance, and its geographic size. We can retrieve information for the top 50, 100, or 150 cities, worldwide using this endpoint.
Input parameters
Parameter | Type | Category | Description |
| string | required | This is our API key. This is a query parameter. |
| integer | required | This is the location’s key. This is a path parameter only for the specific location endpoint. |
| integer | required | This is the number of cities. The allowable values are 50, 100, and 150. This is a path parameter only for the top cities endpoint. |
| string | optional | This is the language in which we have to return the results. Its default value is “en-us.” This is a query parameter. |
| boolean | optional | This is set to "True" to include full details in the response, otherwise it is set to "False." Its default value is "False." This is a query parameter only for the specific location endpoint. |
Sample code
In the code below, we enter 351409
, which is the location key for Seattle, United States, for the parameter locationKey
on line 1 and 50
for the parameter group
on line 2.
Note: Please refer to the appendix for a list of some well known cities along with their location keys.
You can try adding the optional parameters, language
and details
, to the URLs on lines 4–5 and 7–8, where applicable, for fine-tuning the results relating to a given city and for top cities, respectively.
Click the "Run" button to see the output.
locationKey = 351409group = 50url1Day = 'http://dataservice.accuweather.com/currentconditions/v1/' \+ str(locationKey) + '?apikey={{API_KEY}}'url5Day = 'http://dataservice.accuweather.com/currentconditions/v1/topcities/' \+ str(group) + '?apikey={{API_KEY}}'res1Day = requests.get(url1Day)res5Day = requests.get(url5Day)printResponse(res1Day)printResponse(res5Day)
The above code displays the current conditions data for the specified location and for the specified number of top cities around the globe. Some of the important response parameters are given in the tables below. In case of failure, an appropriate error message is displayed.
Response parameters
For a specific location endpoint
Parameter | Type | Description |
| boolean | This indicates whether there is any precipitation or not. |
| boolean | This indicates whether it's daytime or not. |
| object | This is the temperature in Fahrenheit. |
| object | This is the “feels like” temperature in Fahrenheit. |
| object | This contains wind speed and wind direction values. |
| integer | This provides humidity value. |
| integer | This measure of the ultraviolet radiation from the sun. This value may be NULL. |
| object | This contains visibility information. |
| string | This is the URL of AccuWeather's website for detailed forecast. |
| string | This is the URL of AccuWeather's mobile site for detailed forecast. |
For top cities endpoint
Parameter | Type | Description |
| string | This is the unique location key of the city. |
| string | This is the name of the location in the requested language. Its default language is “en-us.” |
| object | This contains information regarding the city's country, including its code, and its localized and English names. |
| object | This contains information regarding the city's designated timezone. |
| object | This contains information regarding the city's geographical position, including its coordinates. |
| boolean | This indicates whether it’s daytime or not. |
| object | This provides temperature values in Fahrenheit and degrees Celsius. |
| boolean | This indicates whether there is any precipitation or not. |
| string | This is the URL of AccuWeather's website for a detailed forecast. |
| string | This is the URL of AccuWeather's mobile site for a detailed forecast. |
Note: The lists of response parameters above are not exhaustive. Please refer to the appendix for details of the two responses.