# Device REST API

**URL:** <https://forums.losant.com/t/device-rest-api/1398>\
**Category:** Help\
**Tags:** rest-api\
**Created:** [January 3, 2019, 2:41pm UTC](https://forums.losant.com/t/device-rest-api/1398 "2019-01-03T14:41:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 3, 2019, 2:41pm UTC](https://forums.losant.com/t/device-rest-api/1398/1 "2019-01-03T14:41:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [January 3, 2019, 2:49pm UTC](https://forums.losant.com/t/device-rest-api/1398/2 "2019-01-03T14:49:47Z")

</div>

Hi Lars,

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

> **[Device: Get Node](https://docs.losant.com/workflows/data/get-device/)**
>
> Learn more about the Losant Device: Get Node.

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

![59%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/1X/8a6676e312617215405e0a76eea87b9383068ef3.png)

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:

> **[Device Actions](https://docs.losant.com/rest-api/device/#get)**
>
> A detailed look at the various REST actions supported by the Device resource of the Losant API. Learn more.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [January 3, 2019, 3:15pm UTC](https://forums.losant.com/t/device-rest-api/1398/3 "2019-01-03T15:15:39Z")

</div>

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](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](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 🙂

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [January 3, 2019, 3:28pm UTC](https://forums.losant.com/t/device-rest-api/1398/4 "2019-01-03T15:28:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [January 3, 2019, 3:29pm UTC](https://forums.losant.com/t/device-rest-api/1398/5 "2019-01-03T15:29:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [January 3, 2019, 6:47pm UTC](https://forums.losant.com/t/device-rest-api/1398/6 "2019-01-03T18:47:58Z")

</div>

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.
