Skip to main content

python-anticaptcha

Build Status PyPI Chat Python compatibility

Client library for solving captchas with Anticaptcha.com support. The library requires Python >= 3.9.

The library is cyclically and automatically tested for proper operation. We are constantly making the best efforts for its effective operation.

In case of any problems with integration - read the documentation, create an issue, use Gitter or contact privately.

Getting Started

Install as standard Python package using:

pip install python-anticaptcha

For async support (FastAPI, aiohttp, Starlette, etc.):

pip install python-anticaptcha[async]

Usage

To use this library you need Anticaptcha.com API key.

You can pass the key explicitly or set the ANTICAPTCHA_API_KEY environment variable:

# Explicit key
client = AnticaptchaClient("my-api-key")

# Or set ANTICAPTCHA_API_KEY environment variable
client = AnticaptchaClient()

The client can be used as a context manager to ensure the underlying session is closed:

with AnticaptchaClient(api_key) as client:
    job = client.create_task(task)
    job.join()

Async Usage

For async frameworks, use AsyncAnticaptchaClient — the API mirrors the sync client but all methods are awaitable:

from python_anticaptcha import AsyncAnticaptchaClient, NoCaptchaTaskProxylessTask

api_key = '174faff8fbc769e94a5862391ecfd010'
site_key = '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-'
url = 'https://www.google.com/recaptcha/api2/demo'

async with AsyncAnticaptchaClient(api_key) as client:
    task = NoCaptchaTaskProxylessTask(url, site_key)
    job = await client.create_task(task)
    await job.join()
    print(job.get_solution_response())

The full integration example is available in file examples/async_recaptcha_request.py.

Sync Usage

Solve recaptcha

Example snippet for Recaptcha:

from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask

api_key = '174faff8fbc769e94a5862391ecfd010'
site_key = '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-'  # grab from site
url = 'https://www.google.com/recaptcha/api2/demo'

client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(url, site_key)
job = client.create_task(task)
job.join()
print(job.get_solution_response())

The full integration example is available in file examples/sync_recaptcha_request.py.

If you process the same page many times, to increase reliability you can specify whether the captcha is visible or not. This parameter is not required, as the system detects invisible sitekeys automatically. To provide that, pass is_invisible parameter to NoCaptchaTaskProxylessTask or NoCaptchaTask eg.:

from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask

api_key = '174faff8fbc769e94a5862391ecfd010'
site_key = '6Lc-0DYUAAAAAOPM3RGobCfKjIE5STmzvZfHbbNx'  # grab from site
url = 'https://losangeles.craigslist.org/lac/kid/d/housekeeper-sitting-pet-care/6720136191.html'

client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(url, site_key, is_invisible=True)
job = client.create_task(task)
job.join()
print(job.get_solution_response())

Solve text captcha

Example snippet for text captcha:

from python_anticaptcha import AnticaptchaClient, ImageToTextTask

api_key = '174faff8fbc769e94a5862391ecfd010'
client = AnticaptchaClient(api_key)

# From a file path:
task = ImageToTextTask('examples/captcha_ms.jpeg')

# Or from raw bytes:
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb').read())

# Or from a file object:
# task = ImageToTextTask(open('examples/captcha_ms.jpeg', 'rb'))

job = client.create_task(task)
job.join()
print(job.get_captcha_text())

Solve funcaptcha

Example snippet for funcaptcha:

from python_anticaptcha import AnticaptchaClient, FunCaptchaTask, Proxy
UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 ' \
     '(KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'

api_key = '174faff8fbc769e94a5862391ecfd010'
site_key = 'DE0B0BB7-1EE4-4D70-1853-31B835D4506B'  # grab from site
url = 'https://www.google.com/recaptcha/api2/demo'
proxy = Proxy.parse_url("socks5://login:password@123.123.123.123:1080")

client = AnticaptchaClient(api_key)
task = FunCaptchaTask(url, site_key, user_agent=UA, **proxy.to_kwargs())
job = client.create_task(task)
job.join()
print(job.get_token_response())

Monitor solve progress

You can pass an on_check callback to job.join() to monitor progress:

def progress(elapsed, status):
    print(f"Elapsed: {elapsed}s, status: {status}")

job = client.create_task(task)
job.join(on_check=progress)

Report incorrect image

Example snippet for reporting an incorrect image task:

from python_anticaptcha import AnticaptchaClient, ImageToTextTask

api_key = '174faff8fbc769e94a5862391ecfd010'
captcha_fp = open('examples/captcha_ms.jpeg', 'rb')
client = AnticaptchaClient(api_key)
task = ImageToTextTask(captcha_fp)
job = client.create_task(task)
job.join()
print(job.get_captcha_text())
job.report_incorrect_image()

Setup proxy

The library is not responsible for managing the proxy server. However, we point to the possibility of simply launching such a server by:

pip install mitmproxy
mitmweb -p 9190 -b 0.0.0.0 --ignore '.' --socks

Then in your application use something like:

proxy = Proxy.parse_url("socks5://123.123.123.123:9190")

We recommend entering IP-based access control for incoming addresses to proxy. IP address required by Anticaptcha.com is:

69.65.41.21
209.212.146.168

Error handling

In the event of an application error, the AnticaptchaException exception is thrown. To handle the exception, do the following:

from python_anticaptcha import AnticaptchaException, ImageToTextTask

try:
    # any actions
except AnticaptchaException as e:
    if e.error_code == 'ERROR_ZERO_BALANCE':
        notify_about_no_funds(e.error_id, e.error_code, e.error_description)
    else:
        raise

Note: The legacy misspelled AnticatpchaException alias is still available for backward compatibility.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Adam Dobrawy - Initial work - ad-m

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Metadata

Release files for python-anticaptcha 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-anticaptcha 2.0.0
File Size Uploaded
python_anticaptcha-2.0.0.tar.gz 54.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-anticaptcha 2.0.0
File Interpreter ABI Platform
python_anticaptcha-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 75.4 kB

Release files / python_anticaptcha-2.0.0.tar.gz

Download URL python_anticaptcha-2.0.0.tar.gz
Size 54.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4a5c4c1068cf5a24af2e91deda5615066b8399df544f103e60045de554b95fed
BLAKE2b-256 checksum
How to use checksums
d5813584e7cefde3a83130f885760049735dcb598a2fdc17ddc8f8e82751eb95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 9, 2026.

Transparency log

Release files / python_anticaptcha-2.0.0-py3-none-any.whl

Download URL python_anticaptcha-2.0.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b27481a54b73526f78752c57c3029585895ac3f7bcedbc5269bcd82c635dd66
BLAKE2b-256 checksum
How to use checksums
001fb0ec0f22985e5d1cf8e822ccf4eb708a4346608d54bf0e70950bdae9f491
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.1.1

3 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page