# AWX Api question or request for enhancement

**URL:** <https://forum.ansible.com/t/awx-api-question-or-request-for-enhancement/36391>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [March 2, 2022, 11:07am UTC](https://forum.ansible.com/t/awx-api-question-or-request-for-enhancement/36391 "2022-03-02T11:07:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Coussens](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/stefan_coussens/32/8432_2.png) [@Stefan\_Coussens](https://forum.ansible.com/u/Stefan_Coussens)\
**Post date:** [March 2, 2022, 11:07am UTC](https://forum.ansible.com/t/awx-api-question-or-request-for-enhancement/36391/1 "2022-03-02T11:07:16Z")

</div>

Hi,

I am currently using the api to see what playbooks are scheduled .  
From this api call I get an inventory and if it is defined a limit. I tought given these 2 parameters it would be easy to get a list of hosts (via the api) that shows the hosts that match the limit and the inventory.

This seems quite hard. The only way (in theory) I think I could get this to launch a playbook with something like

- name: show all the hosts matching the pattern, i.e. all but the group www  
when: ansible\_limit is defined debug: msg: “{{ item }}” with\_inventory\_hostnames: - {{ansible\_limit }}

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/inventory\_hostnames\_lookup.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/inventory_hostnames_lookup.html)

This would be the scenario  
Query schedules  
for every schedule get the inventory and limit  
for every inventory and limit launch a template with inventory and limit that prints the hostnames using the with\_inventory\_hostnames module.

This is quit inefficient so I hope there is a better way to filter out the hosts of a template when the limit is set.

So am I on the right (but painfully tedious) way or have I missed a crucial part in the api documentation?

In short: How do I get a filtered inventory given an ansible limit parameter via the API

kind regards,
