anticaptcha / php-sdk-provider
Modern PHP SDK for the AntiCaptcha API with provider-agnostic contracts
V1.0.0
2026-07-15 18:03 UTC
Requires
- php: >=7.1.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^7.5|^8.5
README
Modern PHP SDK for the AntiCaptcha API. Built with provider-agnostic contracts so additional captcha providers can be added without changing consumer code.
Requirements
- PHP
>=7.1.2 ext-curlext-json
No third-party runtime dependencies.
Installation
composer require anticaptcha/sdk
Quick start
<?php declare(strict_types=1); use AntiCaptcha\Sdk\AntiCaptcha\AntiCaptchaClient; use AntiCaptcha\Sdk\AntiCaptcha\AntiCaptchaConfig; use AntiCaptcha\Sdk\Http\CurlHttpClient; use AntiCaptcha\Sdk\Support\TaskPoller; use AntiCaptcha\Sdk\Task\RecaptchaV2ProxylessTask; $config = new AntiCaptchaConfig('YOUR_API_KEY'); $client = new AntiCaptchaClient($config, new CurlHttpClient(), new TaskPoller()); $task = new RecaptchaV2ProxylessTask('https://example.com', 'SITE_KEY'); $result = $client->solve($task); echo $result->getGRecaptchaResponse();
Supported task types (v1)
| Class | API type | Solution accessor |
|---|---|---|
ImageToTextTask |
ImageToTextTask |
getText() |
RecaptchaV2ProxylessTask |
RecaptchaV2TaskProxyless |
getGRecaptchaResponse() |
RecaptchaV3ProxylessTask |
RecaptchaV3TaskProxyless |
getGRecaptchaResponse() |
HCaptchaProxylessTask |
HCaptchaTaskProxyless |
getGRecaptchaResponse() / getToken() |
TurnstileProxylessTask |
TurnstileTaskProxyless |
getToken() |
API methods
The AntiCaptchaClient implements CaptchaClientInterface:
createTask(TaskInterface $task): TaskCreationResultgetTaskResult(int $taskId): TaskResultsolve(TaskInterface $task): TaskResult— create + poll until readygetBalance(): floatreportIncorrectRecaptcha(int $taskId): void
Configuration
AntiCaptchaConfig accepts:
| Option | Default | Description |
|---|---|---|
apiKey |
required | Your AntiCaptcha API key |
softId |
null |
Developer center application ID |
callbackUrl |
null |
Async callback URL |
initialPollingDelay |
5 |
Seconds before first result check |
pollingInterval |
2 |
Seconds between polls |
pollingTimeout |
120 |
Max seconds to wait for a solution |
baseUrl |
https://api.anti-captcha.com |
API base URL |
Error handling
API errors (errorId > 0) are mapped to typed exceptions:
ERROR_KEY_DOES_NOT_EXIST→AuthenticationExceptionERROR_ZERO_BALANCE→InsufficientBalanceException- Other codes →
ApiException - Network/cURL failures →
NetworkException - Polling timeout →
TimeoutException
Architecture
Contracts (provider-agnostic)
├── CaptchaClientInterface
├── TaskInterface
└── HttpClientInterface
AntiCaptcha provider
├── AntiCaptchaClient
├── AntiCaptchaApi
└── Task value objects
Infrastructure
├── CurlHttpClient
├── TaskPoller
└── ResponseParser
Inject a custom HttpClientInterface implementation for testing or alternative transports.
Development
composer install vendor/bin/phpunit
License
MIT — see LICENSE.