# Use rest API to query for host by discoveredName?

**URL:** <https://community.dynatrace.com/t/use-rest-api-to-query-for-host-by-discoveredname/22602>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [November 22, 2019, 12:53pm UTC](https://community.dynatrace.com/t/use-rest-api-to-query-for-host-by-discoveredname/22602 "2019-11-22T12:53:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_johnson](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@scott\_johnson](https://community.dynatrace.com/u/scott_johnson)\
**Post date:** [November 22, 2019, 12:53pm UTC](https://community.dynatrace.com/t/use-rest-api-to-query-for-host-by-discoveredname/22602/1 "2019-11-22T12:53:27Z")

</div>

I need a way to query for a host by discoveredName, in order to retrieve the EntityID. Upon examining the api/v1/entity/infrastructure/hosts endpoint documentation, I don’t see a way to specify discoveredName as a filter criteria. I’m pretty new to this API, so I may be missing something.

If this is the incorrect forum, please direct me to a proper destination.

Thank you for any assistance!

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [November 23, 2019, 6:53am UTC](https://community.dynatrace.com/t/use-rest-api-to-query-for-host-by-discoveredname/22602/2 "2019-11-23T06:53:31Z")

</div>

You have to options in my opinion. First would be downloading full list of hosts, and look through whole list. In such case you can create local cache of pairs hostName : hostID in system that is fetching data from API.

Second option you can consider is creating tag rule, that will assign to all hosts tag with DetectedHostName as value.

> **[Define and apply tags](https://docs.dynatrace.com/docs/manage/tags-and-metadata/setup/how-to-define-tags)**
>
> Define and apply tags manually or automatically to organize Dynatrace entities, using rule conditions based on entity properties and regular expressions.

Than you will be able to filter list of hosts by tag:

> **[Hosts API - GET all hosts](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/topology-and-smartscape/hosts-api/get-all)**
>
> List all monitored hosts via Dynatrace API.

Sebastian
