Sometimes when requesting 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, today or the next seven days.
The time period parameter of the weather API allows you to easily request data for dynamic time periods.
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.
next<value>days – the period including and after today’s date with a length on the number of days specified. For example next7days or next21days.
last<value>days – the period before today’s date with a length on the number of days specified. For example last7days or last21days.
lastyear– the one year period ending on yesterday’s date.
last24hours – the 24 hour period ending at the current time (rounded to the currenthour).
next<weekday> – the next occurrence of the named day of week after today’s day. For example nextsaturday
last<weekday> – the last occurrence of the named day of week before today’s day. For example lastsaturday
nextweekend – the next occurrence of the weekend after today’s day. Weekend is defined as Saturday and Sunday. Please let us know if you would like additional weekend definitions added.
lastweekend – the last occurrence of the weekend before today’s day. Weekend is defined as Saturday and Sunday. Please let us know if you would like additional weekend definitions added.
Need more dynamic periods?
Please contact us to request additional dynamic date time periods.
Questions or need help?
If you have a question or need help, please post on our actively monitored forum for the fastest replies. You can also contact us via our support site or drop us an email at firstname.lastname@example.org.