skillfed

django-ninja-jwt

Django Ninja JWT - JSON Web Token for Django-Ninja

django-ninja-jwt v5.4.5 237.4K downloads/30d#8,959 on PyPI237
Permissive license Active released

What it is and what it does

Django-Ninja-JWT is a JWT authentication plugin for Django-Ninja that provides token-based authentication without the Django REST Framework dependency. It is a fork of Simple JWT adapted to work with Django-Ninja's native API framework, offering three core endpoints: token pair generation (access and refresh tokens), token refresh, and token verification. The library handles the cryptographic signing and validation of JWTs using pyjwt, and integrates with Django's user authentication system.

You register a controller to your NinjaExtraAPI instance to expose these endpoints, then use the returned access tokens in Authorization headers to protect views. Refresh tokens allow clients to obtain new access tokens without re-authenticating. The package supports customization by subclassing its controller classes, and can be localized by adding it to INSTALLED_APPS. It maintains compatibility with modern Python versions and recent Django releases.

Use it for:

  • Build stateless REST APIs with Django-Ninja that issue short-lived access tokens and longer-lived refresh tokens for client authentication.
  • Protect Django-Ninja endpoints by requiring Bearer token validation without adding Django REST Framework to your project.
  • Implement token refresh workflows where clients exchange expired access tokens for new ones using a refresh token.
  • Customize token claims and validation logic by subclassing controller classes for domain-specific requirements.
  • Add JWT support to existing Django-Ninja projects that need standard token-based authentication.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides JWT authentication for Django-Ninja APIs, offering token generation, refresh, and verification endpoints without requiring Django REST Framework.

Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and fills a clear gap for Django-Ninja users who need JWT authentication without Django REST Framework. The permissive MIT license poses no restriction. Install if you are building a Django-Ninja API that requires token-based authentication.

Install

django-ninja-jwt on PyPI

pip

pip install django-ninja-jwt

uv

uv add django-ninja-jwt

poetry

poetry add django-ninja-jwt

Installing django-ninja-jwt

Before you install

Low install friction with a pure-Python wheel distribution. Actively maintained as of 24 days ago with recent commits and a stable dependency chain anchored on Django and pyjwt.

License in practice

MIT-licensed under permissive terms, allowing unrestricted use, modification, and distribution in commercial and private projects.

Quickstart

pip install django-ninja-jwt

from django_ninja_jwt.controller import NinjaJWTDefaultController
from django_ninja_extra import NinjaExtraAPI

api = NinjaExtraAPI()
api.register_controllers(NinjaJWTDefaultController)

Requires Django >= 2.1, Django-Ninja >= 0.16.1, and django-ninja-extra >= 0.14.2; must use NinjaExtraAPI rather than plain Django-Ninja Router for default controller registration.

Verify before relying

  • Whether token claims customization covers all common use cases (user roles, permissions, custom fields).
  • Performance characteristics under high token generation or validation load.
  • Compatibility with async Django views and whether refresh/verify endpoints support async handlers.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 4 — Django, pyjwt, pydantic-settings, django-ninja-extra
Maintenance actively maintained — 24 days since the last release
Last repo commit
First released
Downloads 237,436/month — #8,959 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_ninja_jwt-5.4.5-py3-none-any.whl

Environment :: Web EnvironmentFramework :: AsyncIOFramework :: DjangoFramework :: Django :: 3.1Framework :: Django :: 3.2Framework :: Django :: 4.0Framework :: Django :: 4.1Intended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: InternetTopic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: HTTP ServersTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Application FrameworksTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

jwt authentication django ninjadjango ninja token authjson web token djangojwt refresh token djangodjango api authenticationbearer token django ninjadjango ninja access control
jwt-authdjango-ninjarest-api

More Software Development packages