Used ip filter for a prefix via the API #1756

Closed
opened 2025-12-29 16:35:02 +01:00 by adam · 1 comment
Owner

Originally created by @funzoneq on GitHub (May 30, 2018).

Issue type

[X] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.2
  • NetBox version: v2.3.3

Description

In netbox we have the view of which IP addresses are used in a specific prefix: https://netbox.example.com/ipam/prefixes/4/ip-addresses/ . It uses the PrefixIPAddressesView and prefix.get_child_ips() function. However there isn't a similar function for the API.

I would like to get a filter on the /ipam/ip-addresses/ resource to be able to filter on the parent prefix ID.

Originally created by @funzoneq on GitHub (May 30, 2018). ### Issue type [X] Feature request <!-- An enhancement of existing functionality --> [ ] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) If you are submitting a bug report and have made any changes to the code base, please first validate that your bug can be recreated while running an official release. --> ### Environment * Python version: 3.5.2 * NetBox version: v2.3.3 <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description In netbox we have the view of which IP addresses are used in a specific prefix: https://netbox.example.com/ipam/prefixes/4/ip-addresses/ . It uses the PrefixIPAddressesView and prefix.get_child_ips() function. However there isn't a similar function for the API. I would like to get a filter on the /ipam/ip-addresses/ resource to be able to filter on the parent prefix ID.
adam closed this issue 2025-12-29 16:35:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 6, 2018):

In the interest of consistency and to avoid redundancy, all API endpoints abide by the same index/filter strategy, which doesn't always mirror the web UI. To retrieve these IPs via the API, you'll need to call the IP addresses endpoint with the parent and vrf or vrf_id filters. For example:

GET https://netbox/api/ipam/ip-addresses/?parent=192.0.2.0/24&vrf_id=10
@jeremystretch commented on GitHub (Jun 6, 2018): In the interest of consistency and to avoid redundancy, all API endpoints abide by the same index/filter strategy, which doesn't always mirror the web UI. To retrieve these IPs via the API, you'll need to call the IP addresses endpoint with the `parent` and `vrf` or `vrf_id` filters. For example: GET https://netbox/api/ipam/ip-addresses/?parent=192.0.2.0/24&vrf_id=10
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1756