# How To Export Tower Inventory Host & Group List

**URL:** <https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502>\
**Category:** AWX Project\
**Created:** [July 27, 2020, 2:31pm UTC](https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502 "2020-07-27T14:31:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus\_Hayhurst](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@Marcus\_Hayhurst](https://forum.ansible.com/u/Marcus_Hayhurst)\
**Post date:** [July 27, 2020, 2:31pm UTC](https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502/1 "2020-07-27T14:31:43Z")

</div>

Hello everyone,

Is there a way to export my Tower (3.7.0) Inventory? I need to get a list of every host and it’s corresponding group in a CSV (if possible). I see this [documentation](https://docs.ansible.com/ansible-tower/3.2.5/html/towerapi/inventory_list.html#inventory-list-api-endpoint) but I do not see how I can get the information I need using the API calls.

---

<div class="post-metadata">

**Author:** ![ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ahmed](https://forum.ansible.com/u/ahmed)\
**Post date:** [July 28, 2020, 2:08pm UTC](https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502/2 "2020-07-28T14:08:06Z")

</div>

Hello,

This endpoint should help you : [https://docs.ansible.com/ansible-tower/latest/html/towerapi/api\_ref.html#/Inventories/Inventories\_inventories\_script\_read](https://docs.ansible.com/ansible-tower/latest/html/towerapi/api_ref.html#/Inventories/Inventories_inventories_script_read)

Regards.

---

<div class="post-metadata">

**Author:** ![Marcus\_Hayhurst](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@Marcus\_Hayhurst](https://forum.ansible.com/u/Marcus_Hayhurst)\
**Post date:** [August 10, 2020, 4:34pm UTC](https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502/3 "2020-08-10T16:34:03Z")

</div>

Thank you. How would I make a GET request for only the **“name”** field which lists the hostnames in the API? This works for my specific inventory: _[https://hostname/api/v2/inventories/4/hosts/?order\_by=name](https://hostname/api/v2/inventories/4/hosts/?order_by=name)_ but returns all the fields.

---

<div class="post-metadata">

**Author:** ![Hrvoje\_Gaspar](https://avatars.discourse-cdn.com/v4/letter/h/3ab097/32.png) [@Hrvoje\_Gaspar](https://forum.ansible.com/u/Hrvoje_Gaspar)\
**Post date:** [August 11, 2020, 6:49am UTC](https://forum.ansible.com/t/how-to-export-tower-inventory-host-group-list/33502/4 "2020-08-11T06:49:19Z")

</div>

Hey there m.hay

If you’re using bash, you can use curl to submit an api request to tower, and then pipe it to jq in order to parse the response. Try something like this:

curl -k --user user:pass [https://hostname/api/v2/inventories/4/hosts/](https://hostname/api/v2/inventories/4/hosts/) | jq ‘.results | .name, .summary\_fields.groups.results.name’

Just make sure to use your own username and password. Or, even better, set a bearer token if you know how to use one.

Dana ponedjeljak, 10. kolovoza 2020. u 18:34:03 UTC+2 korisnik [m.hay...@apogee-innovations.com](mailto:m.hay...@apogee-innovations.com) napisao je:
