djangorestframework-api-key
API key permissions for the Django REST Framework
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-keyuv
uv add djangorestframework-api-keypoetry
poetry add djangorestframework-api-keyInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-oauth-toolkitAdds OAuth2 authorization server capabilities…
permissive · top 5,000 on PyPI
djangorestframework-simplejwtProvides JSON Web Token (JWT) authentication…
permissive · top 5,000 on PyPI
djangorestframeworkBuilds web APIs on top of Django with…
permissive · top 1,000 on PyPI
authzedPython client library for SpiceDB that enables…
permissive · top 5,000 on PyPI
dry-rest-permissionsDefines rules-based permissions for Django REST…
permissive · top 15,000 on PyPI
zope.securityProvides a generic security framework for…
unclear · top 15,000 on PyPI
drf-api-loggerCaptures and logs Django REST Framework API…
permissive · top 15,000 on PyPI
djangorestframework-guardianIntegrates django-guardian's object-level…
permissive · top 15,000 on PyPI
djangorestframework-typesProvides type stubs for Django Rest Framework,…
permissive · top 15,000 on PyPI
django-guardiandjango-guardian adds per-object permission…
permissive · top 5,000 on PyPI