# How to get an inventory field from all devices (via API?)

**URL:** <https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326>\
**Category:** General Discussions\
**Created:** [November 23, 2021, 7:15am UTC](https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326 "2021-11-23T07:15:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bender](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bender/32/847_2.png) [@bender](https://hub.mender.io/u/bender)\
**Post date:** [November 23, 2021, 7:15am UTC](https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326/1 "2021-11-23T07:15:37Z")

</div>

Hi,  
I am looking for a way to get the external IP of all my accepted devices.  
I see that the device inventory API is only for writing and not reading fields:  
[https://docs.mender.io/api/development/#management-api-device-inventory](https://docs.mender.io/api/development/#management-api-device-inventory)

Is there a way to do it programmatically?

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [November 23, 2021, 8:20am UTC](https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326/2 "2021-11-23T08:20:08Z")

</div>

I’m not sure I’m following:

```auto
curl -X GET https://hosted.mender.io/api/management/v1/inventory/devices \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer ${JWT}" | jq '.[] | .attributes | .[] | select(.name == "ipv4_eth0")'

```

Works just fine

---

<div class="post-metadata">

**Author:** ![bender](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bender/32/847_2.png) [@bender](https://hub.mender.io/u/bender)\
**Post date:** [November 23, 2021, 9:56am UTC](https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326/3 "2021-11-23T09:56:02Z")

</div>

Apologies for the confusion… under Device API ([Mender API docs](https://docs.mender.io/api/#device-api-device-inventory)) there are only only PUT/PATCH verbs which is what I was looking into.  
Before posting the question, I searched again to paste the link to the API and got the link to the management section without reading it…  
Thank you for this, although this brings only the first result. Is this just a matter of parsing with `jq` ?

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [November 23, 2021, 12:12pm UTC](https://hub.mender.io/t/how-to-get-an-inventory-field-from-all-devices-via-api/4326/4 "2021-11-23T12:12:47Z")

</div>

I apologize, I figured it was a typo from your end.

But you want to use the device-side API to query the inventory for the server?  
Why not just use the management API? It is still available.

And, the request should be able to give you every device, I would be more suspicious of the `jq` filter I wrote up tbh.

You can also filter directly using the parameters listed here:  
[https://docs.mender.io/api/development/#management-api-device-inventory-list-device-inventories](https://docs.mender.io/api/development/#management-api-device-inventory-list-device-inventories)

I hope this is the question you’re really asking, if not feel free to correct me again.
