Historical Weather Conditions

Learn how to get historical current conditions data for a specific location.

Overview

Historical weather conditions data provides us valuable insights into the weather patterns for a particular location. It also helps us predict what the weather may be like given a certain weather pattern that has existed over the last few hours.

Historical current conditions endpoints

In this lesson, we learn how to retrieve the historical current conditions data for a specific location for the past 6 hours and the past 24 hours.

Past 6 hour conditions

We make a GET request to the following URL to get the historical weather conditions data for the past six hours for a location of our choice:

http://dataservice.accuweather.com/currentconditions/v1/{locationKey}/historical

Past 24 hour conditions

Similarly, we make a GET request to the following URL to get the historical weather conditions data for the past 24 hours for a location of our choice:

http://dataservice.accuweather.com/currentconditions/v1/{locationKey}/historical/24

Input parameters

The table below shows the list of input parameters for both endpoints.

Parameter

Type

Category

Description

API_KEY

string

required

This is our API key.

This is a query parameter.

locationKey

integer

required

This is the key of the location.

This is a path parameter.

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.

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.

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 3–4 and 6–7 to fine-tune your results for the past 6 hours and the past 24 hours, respectively.

Click the "Run" button to see the output.

Press + to interact
locationKey = 351409
url6Hour = 'http://dataservice.accuweather.com/currentconditions/v1/' \
+ str(locationKey) + '/historical?apikey={{API_KEY}}'
url24Hour = 'http://dataservice.accuweather.com/currentconditions/v1/' \
+ str(locationKey) + '/historical/24?apikey={{API_KEY}}'
res6Hour = requests.get(url6Hour)
res24Hour = requests.get(url24Hour)
printResponse(res6Hour)
printResponse(res24Hour)

The above code displays the historical weather conditions data for the specified location for the past 6 hours and for the past 24 hours, including some of the important response parameters given in the table below. In case of failure, an appropriate error message is displayed.

Response parameters

Parameter

Type

Description

HasPrecipitation

boolean

This indicates whether there is any precipitation or not.

IsDaylight

boolean

This indicates whether it's daytime or not.

Temperature

object

This provides the temperature information.

RealFeelTemperature

object

This provides the “feels like” temperature information.

Wind

object

This contains wind speed and wind direction values.

RelativeHumidity

integer

This provides the humidity value.

UVIndex

integer

This is the 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 a detailed forecast.

MobileLink

string

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

Note: The list of response parameters above is not exhaustive. Please refer to the appendix for details of the response.