API: Query IP Addresses by Interface #6489
-
When i try to get the IP of an interface like this: http://netbox/api/ipam/ip-addresses/?assigned_object_id=1533 I get back all the IPs in the System. What am i doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
If you give an unrecognised query parameter then it's ignored (without any error), which is why you get them all. I agree it's not well documented, but the defined set of filters for IPAddress objects is here. The ones you want are "interface_id" or "vminterface_id". That is: if 1533 is an interface on a device, then use |
Beta Was this translation helpful? Give feedback.
-
OK, i see...so i can't search for virtually just everything, but the allowed queries are hardcoded...OK, got that now. Thanks for pointing out! |
Beta Was this translation helpful? Give feedback.
-
That brings me to the point, why i can't search for description? That does work on interfaces, though, and i abuse that as foreign key for importing stuff from somewhere else |
Beta Was this translation helpful? Give feedback.
If you give an unrecognised query parameter then it's ignored (without any error), which is why you get them all.
I agree it's not well documented, but the defined set of filters for IPAddress objects is here.
The ones you want are "interface_id" or "vminterface_id". That is: if 1533 is an interface on a device, then use
http://netbox/api/ipam/ip-addresses/?interface_id=1533
. If it's on a VM, then usehttp://netbox/api/ipam/ip-addresses/?vminterface_id=1533