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

API_KEY

string

required

This is our API key.

This is a query parameter.

locationKey

integer

required

This is the location’s key.

This is a path parameter only for the specific location endpoint.

group

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.

language

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.

details

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.

Press + to interact
locationKey = 351409
group = 50
url1Day = '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

HasPrecipitation

boolean

This indicates whether there is any precipitation or not.

IsDayTime

boolean

This indicates whether it's daytime or not.

Temperature

object

This is the temperature in Fahrenheit.

RealFeelTemperature

object

This is the “feels like” temperature in Fahrenheit.

Wind

object

This contains wind speed and wind direction values.

RelativeHumidity

integer

This provides humidity value.

UVIndex

integer

This measure of the ultraviolet radiation from the sun.

This value may be NULL.

Visibility

object

This contains visibility information.

Link

string

This is the URL of AccuWeather's website for detailed forecast.

MobileLink

string

This is the URL of AccuWeather's mobile site for detailed forecast.

For top cities endpoint

Parameter

Type

Description

Key

string

This is the unique location key of the city.

LocalizedName

string

This is the name of the location in the requested language.

Its default language is “en-us.”

Country

object

This contains information regarding the city's country, including its code, and its localized and English names.

Timezone

object

This contains information regarding the city's designated timezone.

Geoposition

object

This contains information regarding the city's geographical position, including its coordinates.

IsDayTime

boolean

This indicates whether it’s daytime or not.

Temperature

object

This provides temperature values in Fahrenheit and degrees Celsius.

HasPrecipitation

boolean

This indicates whether there is any precipitation or not.

Link

string

This is the URL of AccuWeather's website for a detailed forecast.

MobileLink

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.