---
title: List an app's host IDs and instance IDs
source: https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/list-apps-host-ids-instance-ids
---

Here are examples of how to use the New Relic REST API (v2) to get the list of [instance IDs](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_instance_id) and [host IDs](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_host_id) for an application. The list shows any that have reported for approximately the last hour.

> #### ⚠️ IMPORTANT
>
> While the examples utilize New Relic's REST API v2, we recommend using [NRQL functions](https://docs.newrelic.com/docs/nrql/get-started/introduction-nrql-new-relics-query-language/) for executing metric timeslice queries. Each API value can be mapped to an equivalent NRQL function. To learn how to create NRQL queries based on these API examples, refer to our [documentation](https://docs.newrelic.com/docs/apis/rest-api-v2/migrate-to-nrql/).

## List current IDs by application name [#list_current_ids]

You can also use the [REST API Explorer's **Applications > List**](https://docs.newrelic.com/docs/apis/using-the-api-explorer) to list the ID details. Enter the correct application name.

To list all the [instance](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_instance_id) and [host](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_host_id) IDs reporting in the last hour with an application name containing `${APP_NAME}`, use the following command. This provides the current [Summary data](https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/summary-data-examples-v2#app) followed by the ID lists for instances and hosts for the applications with `${APP_NAME}` in their name, in the account associated with the `${API_KEY}`.

```bash
curl -X GET 'https://api.newrelic.com/v2/applications.json' \
     -H "X-Api-Key:${API_KEY}" -i  \
     -d "filter[name]=${APP_NAME}"
```

## List current IDs by application ID [#ids_app_id_list]

You can also use the [REST API Explorer's **Applications > List**](https://docs.newrelic.com/docs/apis/using-the-api-explorer) or **Applications > List** to list the ID details. Enter the correct application name.

To list all the IDs reporting in the last hour when you know the [application's `${APP_ID}`](https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/listing-your-app-id-metric-data-v2), use this command:

```bash
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}.json" \
     -H "X-Api-Key:${API_KEY}" -i
```

You can also use `filter[id]`:

```bash
curl -X GET "https://api.newrelic.com/v2/applications.json" \
     -H "X-Api-Key:${API_KEY}" -i  \
     -d "filter[id]=${APP_ID}"
```

## List current IDs for all applications [#ids_all_apps]

You can also use the [REST API Explorer's **Applications > List**](https://docs.newrelic.com/docs/apis/using-the-api-explorer) or **Applications > List** to list the ID details. Enter the correct application name.

For all the applications, list all the [instance IDs](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_instance_id) and [host IDs](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/listing-host-instance-application-server-ids#locating_host_id) reporting in the last hour by using the following command. This provides the current [summary data](https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/summary-data-examples-v2#app) followed by the ID lists for instances and hosts for all the applications in the account associated with the `${API_KEY}`.

```bash
curl -X GET "https://api.newrelic.com/v2/applications.json" \
     -H "X-Api-Key:${API_KEY}" -i
```

## Example host ID and instance ID lists [#example_id_list]

Here is an example of how the lists of IDs appear in JSON format:

```json
...
{  
  "links": {
    "application_instances": [    <---<<<< {INSTANCE_ID} list
      21790,
      24810,
      27948,
      35120,
      35121,
      35122,
      186288,
      247253,
      247254,
      247255,
      247256
    ],
    "application_hosts": [    <---<<<< {HOST_ID} list
      21788,
      24808,
      34966,
      186283,
      247245,
      286551
    ]
  }
}
...
```
