{"id":13625295,"url":"https://github.com/eadwinCode/django-ninja-extra","last_synced_at":"2025-04-16T06:32:24.995Z","repository":{"id":37046937,"uuid":"377783591","full_name":"eadwinCode/django-ninja-extra","owner":"eadwinCode","description":"Django Ninja Extra - Class-Based Utility and more for Django Ninja(Fast Django REST framework)","archived":false,"fork":false,"pushed_at":"2024-10-24T19:12:01.000Z","size":9439,"stargazers_count":386,"open_issues_count":15,"forks_count":31,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-26T05:32:43.314Z","etag":null,"topics":["django","django-ninja","django-rest-framework","django-schema","drf","python","python-inject"],"latest_commit_sha":null,"homepage":"https://eadwincode.github.io/django-ninja-extra/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eadwinCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.buymeacoffee.com/ninjaextra"]}},"created_at":"2021-06-17T09:58:17.000Z","updated_at":"2024-10-24T19:12:05.000Z","dependencies_parsed_at":"2023-12-15T01:32:21.817Z","dependency_job_id":"6c9ab8e0-6f72-4967-80f0-38d80bdbddca","html_url":"https://github.com/eadwinCode/django-ninja-extra","commit_stats":{"total_commits":341,"total_committers":8,"mean_commits":42.625,"dds":"0.055718475073313734","last_synced_commit":"388023df3e462e7dfce23a8abbd603e2d1d32cae"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eadwinCode%2Fdjango-ninja-extra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eadwinCode","download_url":"https://codeload.github.com/eadwinCode/django-ninja-extra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223700338,"owners_count":17188301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-ninja","django-rest-framework","django-schema","drf","python","python-inject"],"created_at":"2024-08-01T21:01:53.587Z","updated_at":"2024-11-08T14:30:55.046Z","avatar_url":"https://github.com/eadwinCode.png","language":"Python","funding_links":["https://www.buymeacoffee.com/ninjaextra"],"categories":["Python"],"sub_categories":[],"readme":"![Test](https://github.com/eadwinCode/django-ninja-extra/workflows/Test/badge.svg)\n[![PyPI version](https://badge.fury.io/py/django-ninja-extra.svg)](https://badge.fury.io/py/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/v/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/pyversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![PyPI version](https://img.shields.io/pypi/djversions/django-ninja-extra.svg)](https://pypi.python.org/pypi/django-ninja-extra)\n[![Codecov](https://img.shields.io/codecov/c/gh/eadwinCode/django-ninja-extra)](https://codecov.io/gh/eadwinCode/django-ninja-extra)\n[![Downloads](https://static.pepy.tech/badge/django-ninja-extra)](https://pepy.tech/project/django-ninja-extra)\n\n# Django Ninja Extra\n\n**Django Ninja Extra** package offers a **class-based** approach plus extra functionalities that will speed up your RESTful API development with [**Django Ninja**](https://django-ninja.rest-framework.com)\n\n**Key features:**\n\nAll **Django-Ninja** features :\n- **Easy**: Designed to be easy to use and intuitive.\n- **FAST execution**: Very high performance thanks to **\u003ca href=\"https://pydantic-docs.helpmanual.io\" target=\"_blank\"\u003ePydantic\u003c/a\u003e** and **\u003ca href=\"/async-support/\"\u003easync support\u003c/a\u003e**.\n- **Fast to code**: Type hints and automatic docs lets you focus only on business logic.\n- **Standards-based**: Based on the open standards for APIs: **OpenAPI** (previously known as Swagger) and **JSON Schema**.\n- **Django friendly**: (obviously) has good integration with the Django core and ORM.\n\nPlus **Extra**:\n- **Class Based**: Design your APIs in a class based fashion.\n- **Permissions**: Protect endpoint(s) at ease with defined permissions and authorizations at route level or controller level.\n- **Dependency Injection**: Controller classes supports dependency injection with python [**Injector** ](https://injector.readthedocs.io/en/latest/) or [**django_injector**](https://github.com/blubber/django_injector). Giving you the ability to inject API dependable services to APIController class and utilizing them where needed\n\n---\n\n### Requirements\n- Python \u003e= 3.6\n- django \u003e= 2.1 \n- pydantic \u003e= 1.6 \n- Django-Ninja \u003e= 0.16.1\n\nFull documentation, [visit](https://eadwincode.github.io/django-ninja-extra/).\n\n## Installation\n\n```\npip install django-ninja-extra\n```\nAfter installation, add `ninja_extra` to your `INSTALLED_APPS`\n\n```Python \nINSTALLED_APPS = [\n    ...,\n    'ninja_extra',\n]\n```\n\n## Usage\n\nIn your django project next to urls.py create new `api.py` file: \n\n```Python\nfrom ninja_extra import NinjaExtraAPI, api_controller, http_get\n\napi = NinjaExtraAPI()\n\n# function based definition\n@api.get(\"/add\", tags=['Math'])\ndef add(request, a: int, b: int):\n    return {\"result\": a + b}\n\n#class based definition\n@api_controller\nclass MathAPI:\n\n    @http_get('/subtract',)\n    def subtract(self, a: int, b: int):\n        \"\"\"Subtracts a from b\"\"\"\n        return {\"result\": a - b}\n\n    @http_get('/divide',)\n    def divide(self, a: int, b: int):\n        \"\"\"Divides a by b\"\"\"\n        return {\"result\": a / b}\n    \n    @http_get('/multiple',)\n    def multiple(self, a: int, b: int):\n        \"\"\"Multiples a with b\"\"\"\n        return {\"result\": a * b}\n    \napi.register_controllers(\n    MathAPI\n)\n```\n\nNow go to `urls.py` and add the following:\n\n```Python\n...\nfrom django.urls import path\nfrom .api import api\n\nurlpatterns = [\n    path(\"admin/\", admin.site.urls),\n    path(\"api/\", api.urls),  # \u003c---------- !\n]\n\n```\n\n### Interactive API docs\n\nNow go to \u003ca href=\"http://127.0.0.1:8000/api/docs\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/api/docs\u003c/a\u003e\n\nYou will see the automatic interactive API documentation (provided by \u003ca href=\"https://github.com/swagger-api/swagger-ui\" target=\"_blank\"\u003eSwagger UI\u003c/a\u003e):\n\n![Swagger UI](docs/images/ui_swagger_preview_readme.gif)\n\n## Tutorials\n- [django-ninja - Permissions, Controllers \u0026 Throttling with django-ninja-extra!](https://www.youtube.com/watch?v=yQqig-c2dd4) - Learn how to use permissions, controllers and throttling with django-ninja-extra\n- [BookStore API](https://github.com/eadwinCode/bookstoreapi) - A sample project that demonstrates how to use django-ninja-extra with ninja schema and ninja-jwt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FeadwinCode%2Fdjango-ninja-extra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FeadwinCode%2Fdjango-ninja-extra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FeadwinCode%2Fdjango-ninja-extra/lists"}