drf-recaptcha
Django rest framework recaptcha field serializer
What it is and what it does
drf-recaptcha is a field serializer for Django REST Framework that embeds Google's reCAPTCHA verification into your API request validation pipeline. It supports both reCAPTCHA v2 (checkbox) and v3 (invisible, score-based) flows, allowing you to reject bot traffic at the serializer level before your business logic runs.
The package wraps Google's verification API and exposes ReCaptchaV2Field and ReCaptchaV3Field as field types. You add them to your serializers, configure a secret key in Django settings, and the field automatically validates incoming tokens against Google's servers. For v3, you can set per-action score thresholds to tune sensitivity. It supports dynamic secret key injection via request context, useful for multi-tenant or platform-specific deployments.
Use it for:
- Protect user registration or password-reset endpoints from automated account-creation attacks using reCAPTCHA v2.
- Add invisible bot detection to feedback or contact forms by validating reCAPTCHA v3 scores without user friction.
- Enforce action-specific bot thresholds using v3 action scores configured in settings.
- Test bot-detection logic in CI/CD by toggling DRF_RECAPTCHA_TESTING mode to mock verification without calling Google.
- Override secret keys per request via serializer context for multi-platform deployments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds reCAPTCHA v2 and v3 field validation to Django REST Framework serializers, integrating Google's bot-detection service into API endpoints.
Yes, if you are running Django and djangorestframework and need reCAPTCHA integration. The package is stable, supports current Python versions (3.10, 3.11, 3.12, 3.13) and recent Django releases (4.2, 5.0, 5.1, 5.2), has low install friction, and carries no known vulnerabilities. The aging maintenance status is a minor concern for a mature, narrow-scope library; monitor the repository for security updates. Not necessary if you handle reCAPTCHA verification outside the serializer layer.
Install
drf-recaptcha on PyPI
pip
pip install drf-recaptchauv
uv add drf-recaptchapoetry
poetry add drf-recaptchaInstalling drf-recaptcha
Before you install
Low install friction with a pure-Python wheel. Maintenance status is aging—last release was 357 days ago—but the repository remains active with recent commits and the package is marked Production/Stable. Supports current Python versions and recent Django releases.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions. No notable licensing constraints for typical adoption.
Quickstart
pip install drf-recaptcha
# In Django settings:
INSTALLED_APPS = [..., "drf_recaptcha"]
DRF_RECAPTCHA_SECRET_KEY = "YOUR_GOOGLE_SECRET"
# In a serializer:
from drf_recaptcha.fields import ReCaptchaV2Field
class MySerializer:
recaptcha = ReCaptchaV2Field()
Requires a Google reCAPTCHA account and secret key. The request context must be passed to the serializer for verification to work.
Verify before relying
- Whether the package handles rate-limiting or request throttling when verifying with Google's API.
- Performance impact of network calls to Google's verification endpoint during serializer validation.
- Behavior and error handling when Google's reCAPTCHA service is temporarily unavailable.
- How django-ipware is used internally for client IP detection.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — django, django-ipware, djangorestframework |
| Maintenance | aging — 357 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 242,628/month — #8,849 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: drf_recaptcha-4.0.3-py3-none-any.whl
Keywords: django, drf, rest, django-rest-framework, reCAPTCHA, reCAPTCHA v2, reCAPTCHA v3
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
django-recaptchaIntegrates Google reCAPTCHA (V2 Checkbox, V2…
permissive · top 15,000 on PyPI
drf-pydanticBridges pydantic models and Django REST…
permissive · top 15,000 on PyPI
drf-jsonschema-serializerConverts Django REST Framework serializers to…
permissive · top 15,000 on PyPI
drf-dynamic-fieldsProvides a Django REST Framework mixin that…
permissive · top 15,000 on PyPI
drf-exceptions-hogStandardizes Django REST Framework exception…
permissive · top 5,000 on PyPI
djangorestframework-role-filtersAdds role-based access control to Django REST…
permissive · top 5,000 on PyPI
django-rest-framework-docsGenerates browsable documentation and an…
permissive · top 15,000 on PyPI
djangorestframework-simplejwtProvides JSON Web Token (JWT) authentication…
permissive · top 5,000 on PyPI
drf-orjson-rendererProvides a high-performance JSON renderer and…
permissive · top 15,000 on PyPI
django-localflavorProvides country-specific form fields,…
permissive · top 5,000 on PyPI