API get interfaces filtered by various device_id

28 views
Skip to first unread message

Rodrigo da Rosa Cesconeto

unread,
Mar 22, 2019, 6:33:35 PM3/22/19
to NetBox
I'm using the REST API to generate a custom report. This report needs to show the cid and type of each circuit connected to a router in our organization.

To get this info I took these steps:
  1. GET all devices with role id of "router";
  2. Iterate the router list;
  3. GET all interfaces for each router device_id;
  4. Iterate the interface list;
  5. If that interface is connected to a circuit, GET the circuit info.
Depending on the number of routers and interfaces, I'll be bombarding the server with hundreds of requests.

I tried to reduce the number of requests in step 2/3 above by filtering the interface request passing various device_id:


According to the docs, using repeating filter parameters should work (https://netbox.readthedocs.io/en/stable/api/overview/#filtering), however the above request only returns the interfaces from the last device_id passed (1200).

I tested some requests with repeated filter parameters, and it seems to work for some parameters, but not for others.

Is this a bug? Or is there some restriction of which parameters can be passed multiple times to filter a request?

I'm running netbox v2.5.8

Thanks for any help.

Rodrigo da Rosa Cesconeto

unread,
Mar 26, 2019, 8:51:06 AM3/26/19
to NetBox
I just found a workaround of sorts.

I still didn't find a way of requesting for interfaces of multiple devices at once, but at least I can get several circuits at once using this request:


This way I only need 3 requests per router. Still not ideal, but better then a request per circuit.
Reply all
Reply to author
Forward
0 new messages