GithubHelp home page GithubHelp logo

shijl0925 / django-ninja Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vitalik/django-ninja

0.0 1.0 0.0 6.22 MB

๐Ÿ’จ Fast, Async-ready, Openapi, type hints based framework for building APIs

Home Page: https://django-ninja.rest-framework.com

License: MIT License

Shell 0.12% Python 98.19% Makefile 0.19% HTML 0.83% Dockerfile 0.36% JavaScript 0.31%

django-ninja's Introduction

SCR-20230123-m1t

^ Please read ^

Fast to learn, fast to code, fast to run

Test Coverage PyPI version Downloads

Django Ninja - Fast Django REST Framework

v1.0 What's new

Read more details here - https://django-ninja.dev/whatsnew_v1/

Or Watch here:

SCR-20231116-qmoj

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 [email protected]).

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

What next?

django-ninja's People

Contributors

aasiffaizal avatar aliereno avatar antonrh avatar areski avatar barseghyanartur avatar baseplate-admin avatar c4ffein avatar chenatlas avatar chris-mcdo avatar dependabot[bot] avatar flaeppe avatar fojetin avatar gtbebbo avatar hbutau avatar hiaselhans avatar hyoungsooo avatar ivoire avatar jairhenrique avatar jkeyes avatar jlucas91 avatar jonklo avatar marksweb avatar nofalx avatar otherbarry avatar pawelngei avatar smileychris avatar stephane avatar stephenrauch avatar vitalik avatar wimolivier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.