Maker API limit events by timestamp?

Is there a way I can get the list of events for a device but restrict the results by date? I've figured out that I can pass a length parameter:

http://hubitat/apps/api/251/devices/136/events?access_token=XXX&length=20

But ideally what I want is to poll events and get all new events since the last poll.

The maker API doesn't keep track of when you last polled it. So it would have no way of knowing which events to return and which ones not to. You have to parse that info yourself.

Imagine if you had multiple systems polling for events. If it only returned new ones each time, that would mean that not all events would go to both systems.

Sorry to be more clear I want to be able to pass a after query parameter to the events API can get all events after that specific date.

ex:
http://hubitat/apps/api/251/devices/136/events?access_token=XXX&after=2019-06-08T16:00:00+0000

My client logic can easily track the date of the most recently polled event and ask for all events after that point in time.

Yeah...that would be a feature request. A big one.

But if your client knows the date of the last event, why doesn't it just ignore events before that date/time when the results are returned?

That works too but then I may have to page back in time to get all the data. Not sure why it would be a big feature request to essentially do the events sql query with a "where date > ?". Ideally that would make the fetch a lot more efficient as well if date is indexed as it because a "top" query.

Because it would then have to parse the results to return rather than just dump the device history. It may not be huge but it's definitely not a quick 2 minute thing either. You can put in the request and see.

I'm just saying that since there's no way of knowing when that will happen, you can solve the problem today if you do it on the client side. That's all I'm saying. I have given up waiting for Hubitat to implement/release some improvements. Some come quickly and others that seem simple take forever.

Tagging @patrick as he seems to be the "Maker API" guy at Hubitat. Seems like a reasonable request assuming the date/time field in the database is an indexed field. If so, it should actually improve performance, as you mentioned.

An alternative to consider would be to connect to the event websocket and have your app take all events in real time, then it can do what it likes with them.

2 Likes

I'm a little late to the party, but in just trying this out, I don't think that length parameter does anything. "events" seems to always return 20 data points. Is length supposed to work or not?

This brings up a question: is there anywhere a complete list of the urls and parameters accepted by the api? The maker documentation seems to run through a handful of examples, but it feels like there might be some loose ends hidden here and there....

Does that length parameter actually work? I seems to have no effect; I always get 20 events