-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v4.4.2
Feature type
New functionality
Proposed functionality
Add a new configuration option HIDE_API_LIST_FIELDS that allows NetBox administrators to exclude specific fields from list-view API responses on a per-model basis. This would follow a similar structure to the existing JSON-based Custom Validators configuration.
Example Configuration:
HIDE_API_LIST_FIELDS = {
"dcim.device": ["config_context", "config_template", "local_context_data"],
"dcim.site": ["asns"],
"dcim.rack": ["comments"],
}(Also allowed via the dynamic configuration feature in the web GUI).
Behavior
- If setting is not defined, default is the existing behavior
- Fields would only be excluded from list views (e.g., /api/dcim/devices/)
- Hidden fields would still be available in:
- Detail views (e.g., /api/dcim/devices/{id}/)
- Responses when explicitly included via the ?fields= query parameter
- This configuration would apply instance-wide, reducing payload sizes for all API consumers automatically
Use case
Certain model fields (particularly config_context, config_template, and local_context_data on devices) can add multiple megabytes to a single API list response page, even when using reduced page sizes and filters. While experienced API users can use the ?fields= (or ?exclude=config_context) query parameter to explicitly include only desired fields, this requires:
- Distributed effort to educate all API consumers
- Ongoing vigilance to ensure proper optimization
- Manual intervention for every integration
These large payloads also create infrastructure challenges. Reverse proxies like nginx often resort to temporary file caching when upstream responses exceed their buffer limits, adding disk I/O overhead and latency. While increasing proxy_buffers and proxy_buffer_size can mitigate this, it leads to ballooning memory usage on the web server, especially under concurrent load. This forces administrators to choose between poor performance or excessive resource consumption.
Benefits
- Improved Performance: Dramatically reduce API response sizes for list endpoints
- Lower Network Usage: Decrease bandwidth consumption for API integrations
- Better User Experience: Faster response times without requiring user optimization
- Centralized Control: Administrators can optimize once rather than coordinating across all API consumers
- Backward Compatibility: Users needing the hidden fields can still access them via detail endpoints or explicit field selection
Database changes
N/A
External dependencies
N/A