---
title: Get the list of devices
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Network Device Monitoring
---

# Get the list of devices{% #get-the-list-of-devices %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                         |
| ----------------- | ---------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/ndm/devices |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/ndm/devices |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/ndm/devices      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/ndm/devices      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/ndm/devices  |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/ndm/devices     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/ndm/devices |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/ndm/devices |

### Overview

Get the list of devices.

### Arguments

#### Query Strings

| Name         | Type    | Description                                                              |
| ------------ | ------- | ------------------------------------------------------------------------ |
| page[size]   | integer | Size for a given page. The maximum allowed value is 500. Defaults to 50. |
| page[number] | integer | Specific page number to return. Defaults to 0.                           |
| sort         | string  | The field to sort the devices by. Defaults to `name`.                    |
| filter[tag]  | string  | Filter devices by tag.                                                   |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
List devices response.

| Parent field       | Field                | Type     | Description                                                  |
| ------------------ | -------------------- | -------- | ------------------------------------------------------------ |
|                    | data                 | [object] | The list devices response data.                              |
| data               | attributes           | object   | The device attributes                                        |
| attributes         | description          | string   | The device description                                       |
| attributes         | device_type          | string   | The device type                                              |
| attributes         | integration          | string   | The device integration                                       |
| attributes         | interface_statuses   | object   | Count of the device interfaces by status                     |
| interface_statuses | down                 | int64    | The number of interfaces that are down                       |
| interface_statuses | off                  | int64    | The number of interfaces that are off                        |
| interface_statuses | up                   | int64    | The number of interfaces that are up                         |
| interface_statuses | warning              | int64    | The number of interfaces that are in a warning state         |
| attributes         | ip_address           | string   | The device IP address                                        |
| attributes         | location             | string   | The device location                                          |
| attributes         | model                | string   | The device model                                             |
| attributes         | name                 | string   | The device name                                              |
| attributes         | os_hostname          | string   | The device OS hostname                                       |
| attributes         | os_name              | string   | The device OS name                                           |
| attributes         | os_version           | string   | The device OS version                                        |
| attributes         | ping_status          | string   | The device ping status                                       |
| attributes         | product_name         | string   | The device product name                                      |
| attributes         | serial_number        | string   | The device serial number                                     |
| attributes         | status               | string   | The device SNMP status                                       |
| attributes         | subnet               | string   | The device subnet                                            |
| attributes         | sys_object_id        | string   | The device `sys_object_id`                                   |
| attributes         | tags                 | [string] | The list of device tags                                      |
| attributes         | vendor               | string   | The device vendor                                            |
| attributes         | version              | string   | The device version                                           |
| data               | id                   | string   | The device ID                                                |
| data               | type                 | string   | The type of the resource. The value should always be device. |
|                    | meta                 | object   | Object describing meta attributes of response.               |
| meta               | page                 | object   | Pagination object.                                           |
| page               | total_filtered_count | int64    | Total count of devices matched by the filter.                |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "attributes": {
        "description": "a device monitored with NDM",
        "device_type": "other",
        "integration": "snmp",
        "interface_statuses": {
          "down": "integer",
          "off": "integer",
          "up": "integer",
          "warning": "integer"
        },
        "ip_address": "1.2.3.4",
        "location": "paris",
        "model": "xx-123",
        "name": "example device",
        "os_hostname": "string",
        "os_name": "example OS",
        "os_version": "1.0.2",
        "ping_status": "unmonitored",
        "product_name": "example device",
        "serial_number": "X12345",
        "status": "ok",
        "subnet": "1.2.3.4/24",
        "sys_object_id": "1.3.6.1.4.1.99999",
        "tags": [
          "device_ip:1.2.3.4",
          "device_id:example:1.2.3.4"
        ],
        "vendor": "example vendor",
        "version": "1.2.3"
      },
      "id": "example:1.2.3.4",
      "type": "string"
    }
  ],
  "meta": {
    "page": {
      "total_filtered_count": 1
    }
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Curl command curl -X GET "https://api.datadoghq.com/api/v2/ndm/devices" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" 
                
##### 

```python
"""
Get the list of devices returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.network_device_monitoring_api import NetworkDeviceMonitoringApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = NetworkDeviceMonitoringApi(api_client)
    response = api_instance.list_devices(
        page_size=1,
        page_number=0,
        filter_tag="device_namespace:default",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Get the list of devices returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.new
opts = {
  page_size: 1,
  page_number: 0,
  filter_tag: "device_namespace:default",
}
p api_instance.list_devices(opts)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Get the list of devices returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewNetworkDeviceMonitoringApi(apiClient)
	resp, r, err := api.ListDevices(ctx, *datadogV2.NewListDevicesOptionalParameters().WithPageSize(1).WithPageNumber(0).WithFilterTag("device_namespace:default"))

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `NetworkDeviceMonitoringApi.ListDevices`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `NetworkDeviceMonitoringApi.ListDevices`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Get the list of devices returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;
import com.datadog.api.client.v2.api.NetworkDeviceMonitoringApi.ListDevicesOptionalParameters;
import com.datadog.api.client.v2.model.ListDevicesResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    NetworkDeviceMonitoringApi apiInstance = new NetworkDeviceMonitoringApi(defaultClient);

    try {
      ListDevicesResponse result =
          apiInstance.listDevices(
              new ListDevicesOptionalParameters()
                  .pageSize(1L)
                  .pageNumber(0L)
                  .filterTag("device_namespace:default"));
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling NetworkDeviceMonitoringApi#listDevices");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Get the list of devices returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_network_device_monitoring::ListDevicesOptionalParams;
use datadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;

#[tokio::main]
async fn main() {
    let configuration = datadog::Configuration::new();
    let api = NetworkDeviceMonitoringAPI::with_config(configuration);
    let resp = api
        .list_devices(
            ListDevicesOptionalParams::default()
                .page_size(1)
                .page_number(0)
                .filter_tag("device_namespace:default".to_string()),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Get the list of devices returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.NetworkDeviceMonitoringApi(configuration);

const params: v2.NetworkDeviceMonitoringApiListDevicesRequest = {
  pageSize: 1,
  pageNumber: 0,
  filterTag: "device_namespace:default",
};

apiInstance
  .listDevices(params)
  .then((data: v2.ListDevicesResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}
