skillfed

drf-recaptcha

Django rest framework recaptcha field serializer

drf-recaptcha v4.0.3 242.6K downloads/30d#8,849 on PyPI93
Permissive license MIT AGING released

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-recaptcha

uv

uv add drf-recaptcha

poetry

poetry add drf-recaptcha

Installing 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

Development Status :: 5 - Production/StableEnvironment :: PluginsEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: SecurityTopic :: Software Development :: Libraries

Tags

django rest framework recaptchadrf recaptcha field serializergoogle recaptcha v2 v3 djangobot detection django rest apirecaptcha validation drfdjango api spam protectionrecaptcha score validation
bot-detectionapi-securityform-validation

More Libraries packages

urllib3

urllib3 is an HTTP client library that provides…

permissive · top 100 on PyPI

requests

Requests is a Python HTTP library that…

permissive · top 100 on PyPI

pluggy

Pluggy provides a plugin system that lets you…

permissive · top 100 on PyPI

python-dateutil

Provides parsing, arithmetic, and recurrence…

permissive · top 100 on PyPI

six

Six provides utility functions to write Python…

permissive · top 100 on PyPI

pytest

pytest is a testing framework that lets you…

permissive · top 100 on PyPI

django-recaptcha

Integrates Google reCAPTCHA (V2 Checkbox, V2…

permissive · top 15,000 on PyPI

drf-pydantic

Bridges pydantic models and Django REST…

permissive · top 15,000 on PyPI

drf-jsonschema-serializer

Converts Django REST Framework serializers to…

permissive · top 15,000 on PyPI

drf-dynamic-fields

Provides a Django REST Framework mixin that…

permissive · top 15,000 on PyPI

drf-exceptions-hog

Standardizes Django REST Framework exception…

permissive · top 5,000 on PyPI

djangorestframework-role-filters

Adds role-based access control to Django REST…

permissive · top 5,000 on PyPI

django-rest-framework-docs

Generates browsable documentation and an…

permissive · top 15,000 on PyPI

djangorestframework-simplejwt

Provides JSON Web Token (JWT) authentication…

permissive · top 5,000 on PyPI

drf-orjson-renderer

Provides a high-performance JSON renderer and…

permissive · top 15,000 on PyPI

django-localflavor

Provides country-specific form fields,…

permissive · top 5,000 on PyPI