MCPcopy Index your code
hub / github.com/vitalik/django-ninja

github.com/vitalik/django-ninja @v1.6.2 sqlite

repository ↗ · DeepWiki ↗ · release v1.6.2 ↗ · + Follow
7,619 symbols 24,092 edges 185 files 294 documented · 4% 2 cross-repo links
README

SCR-20230123-m1t

^ Please read ^

<em>Fast to learn, fast to code, fast to run</em>

Test Coverage PyPI version Downloads

Django Ninja - Fast Django REST Framework

Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

Key features:

  • Easy: Designed to be easy to use and intuitive.
  • FAST execution: Very high performance thanks to Pydantic and async support.
  • Fast to code: Type hints and automatic docs lets you focus only on business logic.
  • Standards-based: Based on the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
  • Django friendly: (obviously) has good integration with the Django core and ORM.
  • Production ready: Used by multiple companies on live projects (If you use django-ninja and would like to publish your feedback, please email ppr.vitaly@gmail.com).

Django Ninja REST Framework

Documentation: https://django-ninja.dev


Installation

pip install django-ninja

Usage

In your django project next to urls.py create new api.py file:

from ninja import NinjaAPI

api = NinjaAPI()


@api.get("/add")
def add(request, a: int, b: int):
    return {"result": a + b}

Now go to urls.py and add the following:

...
from .api import api

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", api.urls),  # <---------- !
]

That's it !

Now you've just created an API that:

  • receives an HTTP GET request at /api/add
  • takes, validates and type-casts GET parameters a and b
  • decodes the result to JSON
  • generates an OpenAPI schema for defined operation

Interactive API docs

Now go to http://127.0.0.1:8000/api/docs

You will see the automatic interactive API documentation (provided by Swagger UI or Redoc):

Swagger UI

Sponsors

sendcloud-logo

Become a sponsor

What next?

  • Read the full documentation here - https://django-ninja.dev
  • To support this project, please give star it on Github. github star
  • Share it via Twitter
  • If you already using django-ninja, please share your feedback to ppr.vitaly@gmail.com

Core symbols most depended-on inside this repo

i
called by 1391
ninja/static/ninja/swagger-ui-bundle.js
push
called by 1027
ninja/static/ninja/swagger-ui-bundle.js
get
called by 959
ninja/static/ninja/swagger-ui-bundle.js
n
called by 589
ninja/static/ninja/redoc.standalone.js
set
called by 535
ninja/static/ninja/swagger-ui-bundle.js
replace
called by 534
ninja/static/ninja/redoc.standalone.js
concat
called by 453
ninja/static/ninja/swagger-ui-bundle.js
s
called by 443
ninja/static/ninja/redoc.standalone.js

Shape

Function 3,583
Method 2,099
Class 1,552
Route 385

Languages

TypeScript72%
Python28%

Modules by API surface

ninja/static/ninja/swagger-ui-bundle.js4,350 symbols
ninja/static/ninja/redoc.standalone.js1,146 symbols
tests/main.py109 symbols
tests/test_openapi_schema.py96 symbols
tests/test_router_reuse.py81 symbols
tests/test_pagination.py75 symbols
tests/test_status.py65 symbols
tests/test_pagination_cursor.py65 symbols
tests/test_streaming.py55 symbols
tests/test_orm_schemas.py53 symbols
ninja/pagination.py47 symbols
tests/test_orm_metaclass.py42 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

griffe0.47.0 · 1×
markdown-include0.8.1 · 1×
mkdocs1.5.3 · 1×
mkdocs-autorefs1.0.1 · 1×
mkdocs-material9.5.4 · 1×
mkdocs-material-extensions1.3.1 · 1×

For agents

$ claude mcp add django-ninja \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact