Using the time period parameter to specify dynamic dates for Weather API requests

Sometimes when requesting historical weather data via the weather API we wish to request data for a fixed period based on the current data. For example, request the data for yesterday or today.

The time period parameter of the weather API allows you to easily request data for dynamic time periods.

We have recently added our Timeline Weather API that also includes support for time periods. See the Timeline API documentation for more information.

Example request

Here is an example of using the period parameter in a request: 

The period parameter is a replacement for the startDateTime and endDateTime parameters – the system calculates the values for those parameters for you. When a period is specified, it is not possible to specify the startDateTime and endDateTime in the same query.

The period is applicable to any request aggregation level including daily, hourly and sub-hourly requests. Note that the time period names are case sensitive and must be specified in lower case.

Just as with the startDateTime and endDateTime parameters, the dynamic start and end date times are used based on the local time of the locations being queried.

Available time periods

The API currently supports the following time periods.

today – from midnight to the current time at the requested location.

yesterday – from midnight to midnight on yesterday’s date.

yeartodate – from midnight of January 1st of the current year until the current date time.

monthtodate– from midnight on the 1st of the current month until the current date time.

last7days – the seven day period ending on yesterday’s date.

last30days – the 30 day period ending on yesterday’s date.

lastyear– the one year period ending on yesterday’s date.

last24hours – the 24 hour period ending at the current time (rounded to the currenthour).

Need more dynamic periods?

Please contact us to request additional dynamic date time periods.

2 Replies to “Using the time period parameter to specify dynamic dates for Weather API requests”

Comments are closed.