REST API: GET a cable by providing termination ids and termination types #5442

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

Originally created by @rmammadli on GitHub (Sep 29, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.0.0

Feature type

Data model extension

Proposed functionality

There are currently ~ 2500 cables within our netbox instance and it is going to grow rapidly in near future.

Current version of Netbox API does not offer possibility to get / filter cable(s) using termination values (id, type).

To create / update a cable, we firstly need check if there is already cable exsiting with given data below:

  • termination_a_id
  • termination_a_type
  • termination_b_id
  • termination_b_type

For that we need execute GET request to obtain all cables from Netbox API and then execute search in obtained data additionally.

Benchmarks:

with default values for limit and offset to GET cables:

curl -s -X GET -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" https://my_netbox_instance/api/dcim/cables/?limit=50&offset50

real 0m2,236s
user 0m0,000s
sys 0m0,062s

GET all cables, limit=0:

curl -s -X GET -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" https://my_netbox_instance/api/dcim/cables/?limit=0

real 0m47,855s
user 0m0,015s
sys 0m0,046s

Use case

Netbox users will be able to search for certain cable with using parameters below:

  • termination_a_id
  • termination_a_type
  • termination_b_id
  • termination_b_type

GET request in Netbox API with these parameters should be faster in comparison with GET all cables.

Database changes

No response

External dependencies

No response

Originally created by @rmammadli on GitHub (Sep 29, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.0.0 ### Feature type Data model extension ### Proposed functionality There are currently ~ 2500 cables within our netbox instance and it is going to grow rapidly in near future. Current version of Netbox API does not offer possibility to get / filter cable(s) using termination values (id, type). To create / update a cable, we firstly need check if there is already cable exsiting with given data below: - termination_a_id - termination_a_type - termination_b_id - termination_b_type For that we need execute GET request to obtain all cables from Netbox API and then execute search in obtained data additionally. Benchmarks: with default values for limit and offset to GET cables: `curl -s -X GET -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" https://my_netbox_instance/api/dcim/cables/?limit=50&offset50 ` real 0m2,236s user 0m0,000s sys 0m0,062s GET all cables, limit=0: `curl -s -X GET -H "Authorization: Token $TOKEN" -H "Content-Type: application/json" https://my_netbox_instance/api/dcim/cables/?limit=0 ` real 0m47,855s user 0m0,015s sys 0m0,046s ### Use case Netbox users will be able to search for certain cable with using parameters below: - termination_a_id - termination_a_type - termination_b_id - termination_b_type GET request in Netbox API with these parameters should be faster in comparison with GET all cables. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:28:02 +01:00
adam closed this issue 2025-12-29 19:28:02 +01:00
Author
Owner

@rmammadli commented on GitHub (Oct 7, 2021):

Thank you very much @jeremystretch!

@rmammadli commented on GitHub (Oct 7, 2021): Thank you very much @jeremystretch!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5442