Historical API end_timestamp incorrect

start_timestamp and end_timestamp are NOT related to the period of record for the sensor. They represent bounds of the submitted query, nothing more.

As per the API docs for the get-sensor-history call and this post, the valid values for end_timestamp depend on the requested average time and the maximum amount of data returned per call. The returned end_timestamp was the one used in the call. For a 1 hour average you can request up to 180 days of data. The data are returned unordered. end_timestamp defaults to start_timestamp + the maximum time limit for average.

Best not to rely on defaults and provide a start_timestamp and end_timestamp in your call so you get the data you are expecting.

Along that line, there does not appear to be an API query that provides the period of record for a given sensor. date_created should be a safe lower bound – no data could possibly exist before then – but if a sensor has gone offline there is no way to know when the last observation was without fetching the entire history up until current. There doesn’t seem to be a field for indicating when a sensor was archived, if that happened, either.

2 Likes