The browsable API interface in Django REST Framework provides an HTML form that lets users interact with the API directly from the browser. This includes forms for GET, POST, PUT, and DELETE requests, making it easy to test and explore the API.
The browsable API interface is enabled by including BrowsableAPIRenderer in the DEFAULT_RENDERER_CLASSES setting. JSONRenderer is usually included alongside it to support JSON responses.
The browsable API renderer is selected based on the request's Accept header. If the header prefers JSON, the JSONRenderer is used, showing raw JSON. Browsers usually send Accept headers that include 'text/html', but if a tool or browser extension changes this, the browsable API won't appear.
REST_FRAMEWORK = { 'DEFAULT_RENDERER_CLASSES': ['rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.BrowsableAPIRenderer'] }
Django REST Framework uses content negotiation to select the renderer based on the request's Accept header. Browsers prefer 'text/html;q=1.0', which matches BrowsableAPIRenderer (media_type='text/html'), so the browsable API interface is shown regardless of the order in DEFAULT_RENDERER_CLASSES.
The browsable API interface can reveal detailed API structure and data formats, which might help attackers. Disabling it in production reduces the risk of exposing sensitive information.