Skip to content

Add config options to globally show/hide API fields in list views #20480

@tyler-8

Description

@tyler-8

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:

  1. Distributed effort to educate all API consumers
  2. Ongoing vigilance to ensure proper optimization
  3. 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

  1. Improved Performance: Dramatically reduce API response sizes for list endpoints
  2. Lower Network Usage: Decrease bandwidth consumption for API integrations
  3. Better User Experience: Faster response times without requiring user optimization
  4. Centralized Control: Administrators can optimize once rather than coordinating across all API consumers
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    netboxstatus: under reviewFurther discussion is needed to determine this issue's scope and/or implementationtype: featureIntroduction of new functionality to the application

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions