django-ninja
Django Ninja - Fast Django REST framework
What it is and what it does
Django Ninja is a REST API framework that layers on top of Django, using Python type hints to define request/response schemas and validation. Instead of writing separate schema definitions, you declare function parameters with type annotations, and Pydantic automatically validates incoming data and generates OpenAPI documentation. It supports both synchronous and asynchronous request handlers, integrates with Django's ORM, and produces interactive API docs at a standard endpoint.
The framework is designed to reduce boilerplate: type hints serve double duty as both documentation and validation rules, so you write less code to define the same API surface. It's built on Django and Pydantic, both mature and widely used, and is marked as production-ready with active maintenance and real-world adoption.
Use it for:
- Build a REST API on top of an existing Django project without rewriting the core application.
- Generate OpenAPI documentation automatically from type-hinted endpoint definitions.
- Validate JSON request bodies and query parameters using Pydantic schemas defined inline.
- Create async endpoints in Django to handle high-concurrency workloads.
- Prototype and iterate on API designs quickly by writing minimal endpoint code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Django Ninja builds type-hint-based REST APIs on top of Django, using Pydantic for validation and async support to generate OpenAPI documentation automatically.
Yes. Django Ninja is actively maintained, has no known vulnerabilities, uses permissive MIT licensing, and integrates cleanly with Django and Pydantic. It reduces boilerplate by using type hints for both validation and documentation. Install it if you're building a REST API in Django and want automatic schema generation and validation without extra configuration overhead.
Install
django-ninja on PyPI
pip
pip install django-ninjauv
uv add django-ninjapoetry
poetry add django-ninjaInstalling django-ninja
Before you install
Low install friction with a pure-Python wheel. Actively maintained with recent commits and a large repository presence (9164 stars). Supports Django 3.1 through 6.0 and Python 3.7–3.14.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install django-ninja
from ninja import NinjaAPI
api = NinjaAPI()
@api.get("/add")
def add(request, a: int, b: int):
return {"result": a + b}
Requires Django and Python 3.7 or later; must be integrated into an existing Django project.
Verify before relying
- Whether async support requires additional configuration or specific application server setup.
- Performance characteristics compared to other Django REST frameworks under production loads.
- Maturity and adoption rate of async features specifically.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Django, pydantic |
| Maintenance | actively maintained — 149 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,134,182/month — #2,735 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_ninja-1.6.2-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
django-ninja-extraDjango Ninja Extra extends Django Ninja with…
permissive · top 15,000 on PyPI
flask-openapi3Builds REST APIs on Flask with automatic…
permissive · top 15,000 on PyPI
django-ninja-jwtProvides JWT authentication for Django-Ninja…
permissive · top 15,000 on PyPI
drf-yasgGenerates Swagger/OpenAPI 2.0 specifications…
permissive · top 5,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
django-rest-swaggerGenerates Swagger UI documentation and OpenAPI…
permissive · top 15,000 on PyPI
aiopenapi3Parses and validates OpenAPI 3 specifications…
permissive · top 15,000 on PyPI
drf-spectacularGenerates OpenAPI 3.0.3, 3.1, and 3.2 schemas…
permissive · top 5,000 on PyPI
openapi-pydanticProvides Pydantic-based classes that implement…
permissive · top 1,000 on PyPI