API call/path to extract Peer device IPs

Hi,
I need to extract peer device IPs to validate my firewall flows held in the Excel sheet/external DB.
Basically I need to find out which IPs are communicating with the particular device. In GUI I can see all the peer devices but when I run below python script it does not show the peer devices for all the devices. For some, I can get the IPs from the output and it matches the GUI.

Any idea?

body = {
    "cycle": "1hr",
    "from": "-1y",
    "until": "-1s",
    "metric_category": "net_detail",
    "metric_specs": [
        {
            "name": "bytes_in"
        }
    ],
    "object_ids": [
        xxxxxx
    ],
    "object_type": "device"
} 

def getMetrics(metric_filter):
    url = HOST + '/api/v1/metrics'
    headers = {'Authorization': 'ExtraHop apikey=%s' % APIKEY}
    r = requests.post(url, headers=headers, verify=False, data=json.dumps(metric_filter))
    return r.json()

dev_metric = getMetrics(body)
ip_addrs_list = []
for peer in dev_metric['stats']:
    for ips in peer['values'][0]:
        # print ips['key']['addr']  # peer['key']["device_oid"]
        ip_addrs_list.append(ips['key']['addr'])
print len(list(set(ip_addrs_list)))
print list(set(ip_addrs_list))

If you’re interest is in seeing the connections between devices, I’d suggest using POST /api/v1/activitymaps/query. You can then specify the devices whose peers you want to find, and use the from and to properties of the returned edges to find the device connections.

thank you. i will try this.
So ‘to’ i can say any device or it has to be specific IP/device?
Example: i need to find out all the peer devices connecting to Device A

The from and to in the response will always identify one device per edge, but the response can include multiple edges.

Here’s a query that would pull everything for the last week.

{
    "from": "-1w",
    "walks": [
        {
            "origins": [
                {
                    "object_id": 0,
                    "object_type": "all_devices"
                }
            ],
            "steps": [
                {}
            ]
        }
    ]
}

Thank you. I am able to get the required response now.
Also on protocol detail for non-standed ports, it says tcp/other is it possibe to know the exact port in reposne?

this is the protocol info i go :

protocols": [
          {
            "protocol": [
              "IPv4",
              "TCP",
              "OTHER"
            ],
            "weight": 7
          },
          {
            "protocol": [
              "IPv4",
              "TCP",
              "SSL"
            ],
            "weight": 2
          },
          {
            "protocol": [
              "IPv4",
              "TCP",
              "SSH"
            ],

Not from this API. For performance reasons, we don’t keep the port in the topology. You can use the /records/search, /packets/search, or /metrics endpoints to get that information for more specific pairs of devices.