skillfed

djangorestframework-api-key

API key permissions for the Django REST Framework

djangorestframework-api-key v3.1.0 2.1M downloads/30d#3,282 on PyPI742
Permissive license MIT AGING released

What it is and what it does

This library adds API key-based authentication to Django REST Framework APIs, allowing you to issue, manage, and validate API keys for server-side clients—typically third-party services or internal backends—that need to access your API without user accounts. Keys are hashed before storage and can be created, viewed, and revoked through Django's admin interface or programmatically.

The package is designed specifically for machine-to-machine access and blocking anonymous traffic, not for identifying individual users. It includes permission classes that integrate with DRF's permission system, support for optional expiry dates, and customizable models and admin panels. The library emphasizes security by treating API keys with the same care as passwords and recommends serving your API over HTTPS.

Use it for:

  • Blocking anonymous traffic to your API while allowing authenticated service-to-service requests.
  • Implementing API key-based throttling to rate-limit requests from specific clients or services.
  • Authorizing internal services, such as communication between your API server and an internal frontend application.
  • Logging and identifying usage patterns by associating requests with specific API keys.
  • Managing access for third-party backend services that need to interact with your API without user credentials.

Worth the install?

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

Provides API key authentication and permission control for Django REST Framework, allowing server-side clients and services to securely access your API without user accounts.

Yes, with conditions. Install this if you need simple, secure API key authentication for server-to-server or service-to-API access in a Django REST Framework project. The library has no known vulnerabilities and supports current Python and Django versions. However, maintenance is aging (last release 497 days ago), so verify the feature set meets your needs before committing. Do not use this for user authentication.

Install

djangorestframework-api-key on PyPI

pip

pip install djangorestframework-api-key

uv

uv add djangorestframework-api-key

poetry

poetry add djangorestframework-api-key

Installing djangorestframework-api-key

Before you install

Low install friction with a single runtime dependency (packaging). Maintenance status is aging—last release was 497 days ago—but the repository is active and not archived with recent commits.

License in practice

MIT license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute freely as long as you include the license notice.

Quickstart

pip install "djangorestframework-api-key==3.*"

# In settings.py
INSTALLED_APPS = [
    "rest_framework",
    "rest_framework_api_key",
]

# Run migrations
python manage.py migrate

Requires Django and Django REST Framework to be installed and configured; Python 3.8 or later.

Verify before relying

  • Whether the SHA512-based key hasher is suitable for your security requirements.
  • Performance impact of API key validation in your specific deployment context.
  • Whether API keys alone meet your authorization needs or if OAuth would be more appropriate.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — packaging
Maintenance aging — 497 days since the last release
Last repo commit
First released
Downloads 2,118,359/month — #3,282 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: djangorestframework_api_key-3.1.0-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 2.2Framework :: Django :: 3.2Framework :: Django :: 4.2Framework :: Django :: 5.2Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

api key permissions djangoserver-to-server api authenticationdjango api key managementmachine client api access controlapi key throttling djangodjango rest framework authenticationapi key validation
api-authenticationkey-management

More Python Modules packages