Modify REST API to allow selecting which fields to return in lieu of brief API #8856

Closed
opened 2025-12-29 20:42:13 +01:00 by adam · 2 comments
Owner

Originally created by @arthanson on GitHub (Nov 20, 2023).

NetBox version

v3.6.5

Feature type

Change to existing functionality

Proposed functionality

It recently came up in discussion for another ticket the limitation of the brief APIs which are provided to return limited data from the full API for performance reasons for such things as selections when you don't need all the data. In the case under discussion the brief API didn't provide the fields needed and a potential suggestion was to convert those to GraphQL. This is open for discussion of a potential alternative where there are several libraries that allow specifying a ?fields=a,b,c to REST API call to limit which fields are returned (similar to GraphQL) which would replace the need for the brief APIs and also make them much more flexible.

Current libraries are listed below. Some of these are probably more complicated then our use cases (allowing specifying exclude as well as include fields and down to related models (a.b.c) Just allowing selecting fields is fairly small amount of code and could be just included without using a third-party library.

Use case

Replace the need for the brief APIs and allow them to be more flexible and optimized for each use-case.

Database changes

None

External dependencies

Potentially an external library or not as we could just pull in a small amount of code for this functionality.

Originally created by @arthanson on GitHub (Nov 20, 2023). ### NetBox version v3.6.5 ### Feature type Change to existing functionality ### Proposed functionality It recently came up in discussion for another ticket the limitation of the brief APIs which are provided to return limited data from the full API for performance reasons for such things as selections when you don't need all the data. In the case under discussion the brief API didn't provide the fields needed and a potential suggestion was to convert those to GraphQL. This is open for discussion of a potential alternative where there are several libraries that allow specifying a `?fields=a,b,c` to REST API call to limit which fields are returned (similar to GraphQL) which would replace the need for the brief APIs and also make them much more flexible. Current libraries are listed below. Some of these are probably more complicated then our use cases (allowing specifying exclude as well as include fields and down to related models (a.b.c) Just allowing selecting fields is fairly small amount of code and could be just included without using a third-party library. * https://github.com/rsinger86/drf-flex-fields * https://github.com/ernestofgonzalez/django-dynamic-rest * https://gist.github.com/dgreisen-cfpb/10023365 * https://github.com/AltSchool/dynamic-rest * https://github.com/wimglenn/djangorestframework-queryfields * https://github.com/dbrgn/drf-dynamic-fields ### Use case Replace the need for the brief APIs and allow them to be more flexible and optimized for each use-case. ### Database changes None ### External dependencies Potentially an external library or not as we could just pull in a small amount of code for this functionality.
adam added the type: featurestatus: duplicatepending closure labels 2025-12-29 20:42:13 +01:00
adam closed this issue 2025-12-29 20:42:13 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 19, 2024):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Feb 19, 2024): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Feb 20, 2024):

I believe this is the FR we suspected already existed but for some reason could not find before opening #15087. This work has already been completed and will be included in the upcoming v4.0 release.

@jeremystretch commented on GitHub (Feb 20, 2024): I believe this is the FR we suspected already existed but for some reason could not find before opening #15087. This work has already been completed and will be included in the upcoming v4.0 release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8856