API Reference¶
Public imports¶
from django_ninja_jsonapi import ApplicationBuilder, QueryStringManager, HTTPException, BadRequest, ViewBaseGeneric
ApplicationBuilder¶
Location: django_ninja_jsonapi.api.application_builder.ApplicationBuilder
Constructor¶
ApplicationBuilder(
api: NinjaAPI,
base_router: Router | None = None,
exception_handler: Callable | None = None,
**base_router_include_kwargs,
)
add_resource(...)¶
Registers one JSON:API resource.
Parameters:
path: strtags: Iterable[str]resource_type: strview: typemodel: typeschema: type[BaseModel]router: Router | None = Noneschema_in_post: type[BaseModel] | None = Noneschema_in_patch: type[BaseModel] | None = Nonepagination_default_size: int | None = 20pagination_default_number: int | None = 1pagination_default_offset: int | None = Nonepagination_default_limit: int | None = Noneoperations: Iterable[Operation] = ()ending_slash: bool = Truemodel_id_field_name: str = "id"include_router_kwargs: dict | None = None
initialize()¶
Builds and registers routes on the NinjaAPI instance.
Generated endpoints include:
- resource list/detail CRUD endpoints
- relationship list/detail GET endpoints (when relationship metadata is available)
- atomic endpoint:
POST /operations
Response shape notes¶
- List/detail responses include top-level
links. - Resource objects include
links.self. - Relationship objects include
links.selfandlinks.related.
Django ORM optimizations¶
- Include paths are split automatically between
select_related(to-one chains) andprefetch_related(to-many chains). - Filter parsing supports logical trees (
and,or,not) in JSONfilterpayloads. - Cursor pagination is available via
page[cursor]+page[size].
Query parameter validation¶
- Allowed top-level query params:
filter,sort,include,fields[...],page[...]. - Unknown params return
400. - Repeating non-filter params returns
400.
Operation enum¶
Location: django_ninja_jsonapi.views.enums.Operation
Values:
ALLCREATEDELETEDELETE_LISTGETGET_LISTUPDATE
Use Operation.ALL to auto-expand to default concrete operations (CREATE, DELETE, GET, GET_LIST, UPDATE).
DELETE_LIST is not included in that expansion and must be added explicitly.