Index Values
Learn how to get index data for a single day by a specific location.
Overview
The Indices API allows us to retrieve index values for a particular location. It provides detailed information, including the name of the index, its time, its value, and its category.
Endpoints for getting index values
In this lesson, we learn how to retrieve the index data of a particular location for a single day and for a period of 5 days. These endpoints provide the index data for all indices for the specified location.
Note: The availability of index values varies by location.
Index values for a single day
To get the index values for a single day for a location of our choice, we make a GET
request to the following URL:
http://dataservice.accuweather.com/indices/v1/daily/1day/{locationKey}
Index values for 5 days
Similarly, we make a GET
request to the following URL to get the index data for a period of 5 days for a particular location:
http://dataservice.accuweather.com/indices/v1/daily/5day/{locationKey}
Input parameters
The table below shows the list of input parameters for the aforementioned endpoints.
Parameter | Type | Category | Description |
| string | required | This is our API key. This is a query parameter. |
| integer | required | This is the key of the location. This is a path parameter. |
| 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 indices object in the response, and is set to "False" to include a curtailed one. 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 index values for a single day and for 5 days, respectively.
Click the "Run" button to see the output.
locationKey = 351409url1All = 'http://dataservice.accuweather.com/indices/v1/daily/1day/' \+ str(locationKey) + '?apikey={{API_KEY}}'url5All = 'http://dataservice.accuweather.com/indices/v1/daily/5day/' \+ str(locationKey) + '?apikey={{API_KEY}}'res1All = requests.get(url1All)res5All = requests.get(url5All)printResponse(res1All)printResponse(res5All)
The code above displays the index data for all indices, by the specified location for a single day and for a period of 5 days. The detailed response parameters are given in the table below. In case of failure, an appropriate error message is displayed.
Response parameters
Parameter | Type | Description |
| string | This is the name of the index. |
| integer | This is the ID of the index. This value may be NULL. |
| boolean | This is the order of the index values. If this is set to "True," the best value is 10 and the poorest value is 0. If “False,” then the best value is 0 and the poorest value is 10. |
| string | This is the date and time of the index. |
| integer | This is the number of seconds that have elapsed since January 1, 1970. |
| decimal | This is the value of the index. The range is 0.0–10.0. This value may be NULL. |
| string | This is the level of the index value. |
| integer | This is the integer that indicates the level of the index value. Its range is 1–5. It should be used in conjunction with the |
| string | This is the description of the index value and category. |
| string | This is the URL of AccuWeather's mobile site to indices for the specified location. |
| string | This is the URL of AccuWeather's website to indices for the specified location. |