Device REST API

How would I use the API to find out the last time a device reported any data?

Hi Lars,

If you’re in a workflow, you can grab this information using the device get node:

The result will contain a property called connectionInfo . Like so:

59%20AM

The time is the last time Losant saw a connection from the device.

If you’re not within a workflow and you would still like to use the Losant API. The Device Get API will return the same info above. More info:

Sorry, totally misread your question! The above is to get the last known connection status.

To get the last time the device reported state:

https://docs.losant.com/rest-api/device/#get-composite-state

This is also doable with the Device: Get Node. But, the composite will contain all attributes, the last value reported, and time reported.

Or:

https://docs.losant.com/rest-api/data/#last-value-query

With this endpoint, you can query via attribute and grab multiple devices.

So, you have options :slight_smile:

So to clarify, I’m not in a Losant workflow, and just want to know the last time the devices successfully posted any sensor data.

Yup! The two API calls in my last response should get you exactly what you need.

If you just want to visually see it, the Debug Tab on the device page will show you “Recent Device States”. This includes the most recently received states with their timestamps.