anticaptcha/php-sdk-provider

Modern PHP SDK for the AntiCaptcha API with provider-agnostic contracts

Maintainers

Package info

github.com/HectorDev15/anticaptcha-php-sdk

pkg:composer/anticaptcha/php-sdk-provider

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

V1.0.0 2026-07-15 18:03 UTC

This package is auto-updated.

Last update: 2026-07-15 20:00:27 UTC


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-curl
  • ext-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): TaskCreationResult
  • getTaskResult(int $taskId): TaskResult
  • solve(TaskInterface $task): TaskResult — create + poll until ready
  • getBalance(): float
  • reportIncorrectRecaptcha(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_EXISTAuthenticationException
  • ERROR_ZERO_BALANCEInsufficientBalanceException
  • 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.