Skip to main content

anycaptcha

Telegram channel PyPI version info PyPI supported Python versions PyPI downloads per month

pip install anycaptcha

anycaptcha is a unified Python API for CAPTCHA solving services.

Special thanks to unicaps lib

Key Features

  • A unified Python interface that is independent of the service used
  • Uses native service protocol/endpoints (eg, no needs in patching hosts file)
  • Modern asynchronous client
  • Supports 10 types of CAPTCHAs
  • Written Pythonic way and is intended for humans
  • Supports proxies in any format thanks to better-proxy

Supports 9 CAPTCHA solving services:

Example

from pathlib import Path
from anycaptcha import Solver, Service

API_KEY = '<PLACE_YOUR_API_KEY_HERE>'


async def main():
    async with Solver(Service.TWOCAPTCHA, API_KEY) as solver:
        solved = await solver.solve_image_captcha(
            Path("captcha.jpg"),
            is_phrase=False,
            is_case_sensitive=True
        )
        print(f'CAPTCHA text: {solved.solution.text}')
        await solved.report_good()

Supported CAPTCHAs / Services

Service Image Text reCAPTCHA v2 reCAPTCHA v3 FunCaptcha KeyCAPTCHA Geetest Geetest v4 hCaptcha Capy
2captcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
rucaptcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
anti-captcha.com ✅ ❌ ✅ ✅ ✅ ❌ ✅ ✅ ✅ ❌
azcaptcha.com ✅ ❌ ✅ ✅ ✅ ❌ ❌ ❌ ✅ ❌
cap.guru ✅ ❌ ✅ ✅ ❌ ❌ ✅ ❌ ✅ ❌
deathbycaptcha.com ✅ ❌ ✅ ✅ ✅ ❌ ❌ ❌ ✅ ❌

Image CAPTCHA

Service Regular Case Sensitive Phrase Numbers only Letters only Math Length Language Comment for worker
2captcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅ Cyrillic/Latin ✅
rucaptcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅ Cyrillic/Latin ✅
anti-captcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅ Latin ✅
azcaptcha.com ✅ ❌ ❌ ❌ ❌ ❌ ❌ Latin ✅
cap.guru ✅ ❌ ❌ ❌ ❌ ❌ ❌ Latin ✅
deathbycaptcha.com ✅ ❌ ❌ ❌ ❌ ❌ ❌ Latin ❌

Text CAPTCHA

Text Captcha is a type of captcha that is represented as text and doesn't contain images. Usually you have to answer a question to pass the verification. For example: "If tomorrow is Saturday, what day is today?".

Service Language
2captcha.com English, Russian
rucaptcha.com English, Russian
anti-captcha.com ❌
azcaptcha.com ❌
cap.guru ❌
deathbycaptcha.com ❌

reCAPTCHA v2

Service Regular Invisible Enterprise Google service1 Proxy2 Cookies3 User-Agent4
2captcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅
rucaptcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅
anti-captcha.com ✅ ✅ ✅ ✅ ✅ ✅ ✅
azcaptcha.com ✅ ✅ ❌ ✅ ✅ ✅ ✅
cap.guru ✅ ✅ ❌ ✅ ✅ ✅ ✅
deathbycaptcha.com ✅ ✅ ❌ ✅ ✅ ❌ ❌

1 Support of solving reCAPTCHA on Google services (e.g. Google Search)
2 Support of solving via proxy server
3 Support of passing custom cookies
4 Support of passing custom User-Agent header

reCAPTCHA v3

Service Regular Enterprise Proxy Cookies User-Agent
2captcha.com ✅ ✅ ❌ ❌ ❌
rucaptcha.com ✅ ✅ ❌ ❌ ❌
anti-captcha.com ✅ ✅ ❌ ❌ ❌
azcaptcha.com ✅ ❌ ✅ ❌ ❌
cap.guru ✅ ❌ ✅ ✅ ✅
deathbycaptcha.com ✅ ❌ ✅ ❌ ❌

FunCaptcha (Arkose Labs)

Service Regular Data (BLOB) Proxy Cookies User-Agent
2captcha.com ✅ ✅ ✅ ❌ ✅
rucaptcha.com ✅ ✅ ✅ ❌ ✅
anti-captcha.com ✅ ✅ ✅ ❌ ✅
azcaptcha.com ✅ ✅ ✅ ❌ ✅
cap.guru ❌ ❌ ❌ ❌ ❌
deathbycaptcha.com ✅ ❌ ✅ ❌ ❌

KeyCAPTCHA

Service Regular Proxy Cookies User-Agent
2captcha.com ✅ ❌ ❌ ❌
rucaptcha.com ✅ ❌ ❌ ❌
anti-captcha.com ❌ ❌ ❌ ❌
azcaptcha.com ❌ ❌ ❌ ❌
cap.guru ❌ ❌ ❌ ❌
deathbycaptcha.com ❌ ❌ ❌ ❌

Geetest

Service Regular API server GetLib Proxy Cookies User-Agent
2captcha.com ✅ ✅ ❌ ✅ ❌ ✅
rucaptcha.com ✅ ✅ ❌ ✅ ❌ ✅
anti-captcha.com ✅ ✅ ✅ ✅ ❌ ✅
azcaptcha.com ❌ ❌ ❌ ❌ ❌ ❌
cap.guru ✅ ❌ ❌ ✅ ❌ ❌
deathbycaptcha.com ❌ ❌ ❌ ❌ ❌ ❌

Geetest v4

Service Regular Proxy Cookies User-Agent
2captcha.com ✅ ✅ ❌ ✅
rucaptcha.com ✅ ✅ ❌ ✅
anti-captcha.com ✅ ✅ ❌ ✅
azcaptcha.com ❌ ❌ ❌ ❌
cap.guru ❌ ❌ ❌ ❌
deathbycaptcha.com ❌ ❌ ❌ ❌

hCaptcha

Service Regular Invisible Custom Data Proxy Cookies User-Agent
2captcha.com ✅ ✅ ✅ ✅ ❌ ✅
rucaptcha.com ✅ ✅ ✅ ✅ ❌ ✅
anti-captcha.com ✅ ✅ ❌ ✅ ❌ ✅
azcaptcha.com ✅ ❌ ❌ ✅ ❌ ❌
cap.guru ✅ ❌ ❌ ✅ ❌ ❌
deathbycaptcha.com ✅ ❌ ❌ ✅ ❌ ❌

Capy Puzzle

Service Regular API server Proxy Cookies User-Agent
2captcha.com ✅ ✅ ✅ ❌ ❌
rucaptcha.com ✅ ✅ ✅ ❌ ❌
anti-captcha.com ❌ ❌ ❌ ❌ ❌
azcaptcha.com ❌ ❌ ❌ ❌ ❌
cap.guru ❌ ❌ ❌ ❌ ❌
deathbycaptcha.com ❌ ❌ ❌ ❌ ❌

Supported Proxy types

Service HTTP HTTPS SOCKS 4 SOCKS 5
2captcha.com ✅ ✅ ✅ ✅
rucaptcha.com ✅ ✅ ✅ ✅
anti-captcha.com ✅ ✅ ✅ ✅
azcaptcha.com ✅ ✅ ✅ ✅
cap.guru ✅ ✅ ✅ ✅
deathbycaptcha.com ✅ ❌ ❌ ❌

How to...

Common

Get balance
from anycaptcha import Solver, Service


async def main():
    async with Solver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        balance = await solver.get_balance()
        ...
Get service status (is the service is up?)
from anycaptcha import Solver, Service


async def main():
    with Solver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # get status of the service (True - everything is Okay, False - probably the service is down)
        status = await solver.get_status()
        ...
Get technical details after solving
from anycaptcha import Solver, Service


async def main():
    # init captcha solver and solve the captcha
    with Solver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        solved = await solver.solve_...(...)

        # get cost of the solving
        cost = solved.cost

        # get cookies (if any)
        cookies = solved.cookies

        # report good captcha
        await solved.report_good()

        # report bad captcha
        await solved.report_bad()

        # get solving start time
        start_time = solved.start_time

        # get solving end time
        end_time = solved.end_time

CAPTCHAs

Solve Image CAPTCHA
from pathlib import Path

from anycaptcha import Solver, Service
from anycaptcha import CaptchaAlphabet
from anycaptcha import CaptchaCharType


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_image_captcha(
            image=Path('captcha.jpg'),  # it can be a Path, file-object or bytes.
            char_type=CaptchaCharType.ALPHA,  # optional
            is_phrase=False,  # optional
            is_case_sensitive=True,  # optional
            is_math=False,  # optional
            min_len=4,  # optional
            max_len=6,  # optional
            alphabet=CaptchaAlphabet.LATIN,  # optional
            comment='Type RED letters only'  # optional
        )
        # get CAPTCHA text
        token = solved.solution.text
Solve reCAPTCHA v2
from anycaptcha import Solver, Service

# get page URL and site_key from your page
page_url = ...
site_key = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v2(
            site_key=site_key,
            page_url=page_url,
            data_s='<data-s value>',  # optional
            api_domain='<"google.com" or "recaptcha.net">'  # optional
        )
        # get response token
        token = solved.solution.token
Solve reCAPTCHA v2 Invisible
from anycaptcha import Solver, Service

# get page url and site_key from your page
page_url = ...
site_key = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v2(
            site_key=site_key,
            page_url=page_url,
            is_invisible=True,
            data_s='<data-s value>',  # optional
            api_domain='<"google.com" or "recaptcha.net">'  # optional
        )
        # get response token
        token = solved.solution.token
Solve reCAPTCHA v2 Enterprise
from anycaptcha import Solver, Service

# get page URL, site_key and data_s from your page
page_url = ...
site_key = ...
data_s = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v2(
            site_key=site_key,
            page_url=page_url,
            is_enterprise=True,
            data_s=data_s,  # optional
            api_domain='<"google.com" or "recaptcha.net">'  # optional
        )
        # get response token
        token = solved.solution.token
Solve reCAPTCHA v3
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
site_key = ...
action = ...
min_score = 0.7


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v3(
            site_key=site_key,
            page_url=page_url,
            action=action,  # optional
            min_score=min_score,  # optional
            api_domain='<"google.com" or "recaptcha.net">'  # optional
        )
        # get response token
        token = solved.solution.token
Solve reCAPTCHA v3 Enterprise
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
site_key = ...
action = ...
min_score = 0.7


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v3(
            site_key=site_key,
            page_url=page_url,
            is_enterprise=True,
            action=action,  # optional
            min_score=min_score,  # optional
            api_domain='<"google.com" or "recaptcha.net">'  # optional
        )
        # get response token
        token = solved.solution.token
Solve hCaptcha
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
site_key = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_hcaptcha(
            site_key=site_key,
            page_url=page_url,
            api_domain='< "hcaptcha.com" or "js.hcaptcha.com" >'  # optional
        )
        # get response token
        token = solved.solution.token
Solve hCaptcha Invisible
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
site_key = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_hcaptcha(
            site_key=site_key,
            page_url=page_url,
            is_invisible=True,
            api_domain='< "hcaptcha.com" or "js.hcaptcha.com" >'  # optional
        )
        # get response token
        token = solved.solution.token
Solve FunCaptcha
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
public_key = ...
page_url = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_funcaptcha(
            public_key=public_key,
            page_url=page_url,
            service_url='<value of surl parameter>',  # optional
            blob='<value of data[blob] parameter>'  # optional
        )
        # get response token
        token = solved.solution.token
Solve KeyCaptcha
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
user_id = ...
session_id = ...
ws_sign = ...
ws_sign2 = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_keycaptcha(
            page_url=page_url,
            user_id=user_id,
            session_id=session_id,
            ws_sign=ws_sign,
            ws_sign2=ws_sign2
        )
        # get response token
        token = solved.solution.token
Solve Geetest
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
gt_key = ...
challenge = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_geetest(
            page_url=page_url,
            gt_key=gt_key,
            challenge=challenge,
            api_server='<value of api_server parameter>'  # optional
        )
        # get response token
        token = solved.solution.token
Solve Geetest v4
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
page_url = ...
captcha_id = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_geetest_v4(
            page_url=page_url,
            captcha_id=captcha_id
        )

        # get solution data
        lot_number = solved.solution.lot_number
        pass_token = solved.solution.pass_token
        gen_time = solved.solution.gen_time
        captcha_output = solved.solution.captcha_output
Solve Capy Puzzle
from anycaptcha import Solver, Service

# get CAPTCHA params from the target page/site
site_key = ...
page_url = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_capy_puzzle(
            site_key=site_key,
            page_url=page_url,
            api_server='<for example "https://api.capy.me">',  # optional
            challenge_type='<"puzzle" or "avatar">'  # optional
        )

        # get solution data
        captchakey = solved.solution.captchakey
        challengekey = solved.solution.challengekey
        answer = solved.solution.answer
Solve a text CAPTCHA
from anycaptcha import Solver, Service
from anycaptcha import CaptchaAlphabet
from anycaptcha import WorkerLanguage


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_text_captcha(
            text='Si mañana es domingo, ¿qué día es hoy?',
            alphabet=CaptchaAlphabet.LATIN,  # optional
            language=WorkerLanguage.SPANISH  # optional
        )

        # get answer
        answer = solved.solution.text  # Sábado

Error handling

Catch exceptions
import anycaptcha
from anycaptcha import Solver, Service


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        try:
            solved = solver.solve_recaptcha_v2(
                site_key=site_key,
                page_url=page_url,
            )
        except anycaptcha.AccessDeniedError:  # wrong API key or the current IP is banned
            pass
        except anycaptcha.LowBalanceError:  # low balance
            pass
        except anycaptcha.ServiceTooBusy:  # no available slots to solve CAPTCHA
            pass
        except anycaptcha.SolutionWaitTimeout:  # haven't received a solution within N minutes
            pass
        except anycaptcha.TooManyRequestsError:  # request limit exceeded
            pass
        except anycaptcha.BadInputDataError:  # bad CAPTCHA data (bad image, wrong URL, etc.)
            pass
        except anycaptcha.UnableToSolveError:  # CAPTCHA unsolvable
            pass
        except anycaptcha.ProxyError:  # bad proxy
            pass
        else:
            # get response token
            token = solved.solution.token

Misc

Create a task and wait for the result
from anycaptcha import Solver, Service
from anycaptcha.captcha import RecaptchaV2

# get page URL and site_key from your page
page_url = ...
site_key = ...


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # create a task
        task = solver.create_task(
            RecaptchaV2(site_key, page_url)
        )

        # print task ID
        print(task.task_id)

        # wait for task to be completed
        solved = task.wait()

        # get response token
        token = solved.solution.token
Add proxy, cookies and User-Agent
from anycaptcha import Solver, Service

# get page URL and site_key from your page
page_url = ...
site_key = ...
proxy = 'http://user:password@domain.com:8080'  # any format
user_agent = '<USER AGENT STRING>'
cookies = {'name': 'value', ...}


async def main():
    with Solver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") as solver:
        # solve CAPTCHA
        solved = solver.solve_recaptcha_v2(
            site_key=site_key,
            page_url=page_url,
            proxy=proxy,
            user_agent=user_agent,
            cookies=cookies
        )
        # get response token
        token = solved.solution.token

Metadata

Release files for anycaptcha 1.5.4

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

Source distribution (sdist)

Source distribution for anycaptcha 1.5.4
File Size Uploaded Provenance Actions
anycaptcha-1.5.4.tar.gz 34.5 kB Without provenance Details for anycaptcha-1.5.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for anycaptcha 1.5.4
File Interpreter ABI Platform Actions
anycaptcha-1.5.4-py3-none-any.whl Python 3 none any Details for anycaptcha-1.5.4-py3-none-any.whl

Total release size: 83.2 kB

Release files / anycaptcha-1.5.4.tar.gz

Download URL anycaptcha-1.5.4.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3218dfe8a7b326fb2f157772df59fcbcc7d458d2ecb2d310b3b21fbd509afac3
BLAKE2b-256 checksum
How to use checksums
4c5aab39557435e17b42a478edaac0059d6ab507a5faa516a0343f24345c77db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Windows/11

Release files / anycaptcha-1.5.4-py3-none-any.whl

Download URL anycaptcha-1.5.4-py3-none-any.whl
Size 48.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3aec074676c19674e20a9b970904d062007eee99ad80a38c94e064245faaa6a
BLAKE2b-256 checksum
How to use checksums
c5faaa9a79848a5e7b3b4e072e545ba9f5039eaf9895d2d244dc01cf79c0bf09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Windows/11

Security for anycaptcha 1.5.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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