💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
MIT License
^ Please read ^
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.
Key features:
Documentation: https://django-ninja.dev
pip install django-ninja
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:
/api/add
a
and b
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):