# Array of Device states from API

**URL:** <https://forums.losant.com/t/array-of-device-states-from-api/1574>\
**Category:** Help\
**Tags:** losant-api\
**Created:** [March 1, 2019, 1:04am UTC](https://forums.losant.com/t/array-of-device-states-from-api/1574 "2019-03-01T01:04:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [March 1, 2019, 4:50pm UTC](https://forums.losant.com/t/array-of-device-states-from-api/1574/2 "2019-03-01T16:50:54Z")

</div>

Hi Paul,

I built out a workflow to do this, you can find the walkthrough below. Based on your use case, I believed this to be the easiest way to accomplish this goal.

I still have the same workflow as [this post](https://forums.losant.com/t/export-device-state-to-csv-ftp/1559/11), and have added a Device: Get node, a Function node, and a Loop. I first use the Device: Get to query the Device Tags, return the multiple devices that match, and those devices are placed on the payload.

 ![18%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/eaac46d8cdc049f9f6fbb33f39782bfa14aaadcb.png)

Within my function node, I loop through and pull out the device IDs.

 ![29%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cb2dc0d7a0bc004273bc6d22a5a037821db321ac.png)  
 ![18%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/eaeae5f4c8ae47327facaa598da370a3f761e52c.png)

Then I use a loop node, and set the source path to the deviceId array I just created.

 ![44%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/9/98575ce9b9ce288067b5b23b6795f73bc8af28f8.png)

Then from within my loop I include the nodes I built out [in this example](https://forums.losant.com/t/export-device-state-to-csv-ftp/1559/11) to get each device’s last state data onto the payload.

 ![57%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/c107c0f0f6bc69638d90a9ee813112a83abcceb0.png)  
 ![08%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/7a837de420ba226e250fd94b15feb8bcdbfcd6a8.png)

Then I can see the every device’s last state for the tag I selected.  
 ![33%20AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/f/f860145ae127dd6c9ea583b7422709f6ca3d186a.png)

Hopefully this helps,  
Julia

---

_[View the full topic](https://forums.losant.com/t/array-of-device-states-from-api/1574)._
