# Query by TAG through API

**URL:** <https://forum.genieacs.com/t/query-by-tag-through-api/2302>\
**Category:** Uncategorized\
**Created:** [January 4, 2022, 5:42pm UTC](https://forum.genieacs.com/t/query-by-tag-through-api/2302 "2022-01-04T17:42:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ewertonhm](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/ewertonhm/32/760_2.png) [@ewertonhm](https://forum.genieacs.com/u/ewertonhm)\
**Post date:** [January 4, 2022, 5:42pm UTC](https://forum.genieacs.com/t/query-by-tag-through-api/2302/1 "2022-01-04T17:42:15Z")

</div>

Hi there,

Is there a way to get all device with a specific tag using the API?

Tryied  
`GET http://acs.server:7557/devices/?query={"Tags.sometag":"true"}`,  
It returns 200 OK with an empty array.

---

<div class="post-metadata">

**Author:** ![ewertonhm](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/ewertonhm/32/760_2.png) [@ewertonhm](https://forum.genieacs.com/u/ewertonhm)\
**Post date:** [January 4, 2022, 6:21pm UTC](https://forum.genieacs.com/t/query-by-tag-through-api/2302/2 "2022-01-04T18:21:30Z")

</div>

Figured it out…  
query={"\_tags":“sometag”}

---

<div class="post-metadata">

**Author:** ![leonardopc1991](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/leonardopc1991/32/22_2.png) [@leonardopc1991](https://forum.genieacs.com/u/leonardopc1991)\
**Post date:** [June 27, 2022, 2:55pm UTC](https://forum.genieacs.com/t/query-by-tag-through-api/2302/3 "2022-06-27T14:55:18Z")

</div>

Hi, how did you make the connection string?

---

<div class="post-metadata">

**Author:** ![ewertonhm](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/ewertonhm/32/760_2.png) [@ewertonhm](https://forum.genieacs.com/u/ewertonhm)\
**Post date:** [June 27, 2022, 8:32pm UTC](https://forum.genieacs.com/t/query-by-tag-through-api/2302/4 "2022-06-27T20:32:50Z")

</div>

heres an example:  
[http://youracsserver.com:7557/devices/?query={“\_tags”:“sometag”}&projection=\_id](http://youracsserver.com:7557/devices/?query=%7B%22_tags%22:%22sometag%22%7D&projection=_id)

7557 is the default port of the NBI, depending on your setup it may be another port.

the projection=\_id makes it return just the \_id to be fast, otherwise it will return all the data from the devices, depending on how many you get, it may take a while
