Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Python module for reCAPTCHA service.

Project description

reCAPTCHA is a free CAPTCHA service that protects your site against spam, malicious registrations and other forms of attacks where computers try to disguise themselves as a human.

python-reCAPTCHA is a Python 3.x module, that provides an easy way to interact with the reCAPTCHA API.


$ pip install python-reCAPTCHA


$ git clone
$ cd python-reCAPTCHA
$ python install
$ cd .. && rm -rf python-reCAPTCHA


To use reCAPTCHA, you need to sign up for API keys for your site.

Once you’ve signed up for API keys, adding reCAPTCHA to your site consists of two steps.

1. Displaying the reCAPTCHA Widget

Generate the widget HTML by calling the generate_html function.

>>> from recaptcha.captcha import generate_html
>>> public_key = "your_public_key"
>>> recaptcha_html = generate_html(public_key)
>>> print(recaptcha_html)
<script type="text/javascript" src=""></script><noscript><iframe src=""height="300" width="500" frameborder="0"></iframe><br><textarea name="recaptcha_challenge_field"rows="3" cols="40"></textarea><input type="hidden" name="recaptcha_response_field"value="manual_challenge"></noscript>

Place the generated HTML inside your form. If you are working with Django por example, your form will looks like this:

<form action="">
    {% autoscape on %}recaptcha_html{% endautoescape %}
    <input type="submit" value="Submit">

2. Verifying user’s anwser

After the user submit the anwser, you should get the required paramenters and call the verify function. Again, a Django’s example.

>>> from recaptcha.captcha import verify
>>> private_key = "your_private_key"
>>> remote_ip = request.META['REMOTE_ADDR']
>>> challenge = request.POST.get('recaptcha_challenge_field', '')
>>> response = request.POST.get('recaptcha_response_field', '')
>>> result = verify(private_key, remote_ip, challenge, response)
>>> print(result)
{'success': False, 'error': 'incorrect-captcha-sol'}


Documentation will be available soon.

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-reCAPTCHA, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size python-reCAPTCHA-0.1.0.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page