PHPackages                             trongloikt192/2captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. trongloikt192/2captcha

ActiveLibrary[API Development](/categories/api)

trongloikt192/2captcha
======================

PHP package for easy integration with 2captcha API

028PHP

Since Nov 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/trongloikt192/2captcha)[ Packagist](https://packagist.org/packages/trongloikt192/2captcha)[ RSS](/packages/trongloikt192-2captcha/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Module for 2Captcha API
===========================

[](#php-module-for-2captcha-api)

The easiest way to quickly integrate [2Captcha](https://2captcha.com/) captcha solving service into your code to automate solving of any types of captcha.

- [Installation](#installation)
    - [Composer](#composer)
    - [Manual](#manual)
- [Configuration](#configuration)
- [Solve captcha](#solve-captcha)
    - [Normal Captcha](#normal-captcha)
    - [Text](#text-captcha)
    - [ReCaptcha v2](#recaptcha-v2)
    - [ReCaptcha v3](#recaptcha-v3)
    - [FunCaptcha](#funcaptcha)
    - [GeeTest](#geetest)
    - [hCaptcha](#hcaptcha)
    - [KeyCaptcha](#keycaptcha)
    - [Capy](#capy)
    - [Grid (ReCaptcha V2 Old Method)](#grid)
    - [Canvas](#canvas)
    - [ClickCaptcha](#clickcaptcha)
    - [Rotate](#rotate)
- [Other methods](#other-methods)
    - [send / getResult](#send--getresult)
    - [balance](#balance)
    - [report](#report)
- [Error handling](#error-handling)

Installation
------------

[](#installation)

This package can be installed via composer or manually

### Composer

[](#composer)

```
composer require trongloikt192/2captcha

```

### Manual

[](#manual)

Copy `src` directory to your project and then `require` autoloader (`src/autoloader.php`) where needed:

```
require 'path/to/autoloader.php';
```

Configuration
-------------

[](#configuration)

`TwoCaptcha` instance can be created like this:

```
$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
```

Also there are few options that can be configured:

```
$solver = new \TwoCaptcha\TwoCaptcha([
    'server'           => 'http://rucaptcha.com',
    'apiKey'           => 'YOUR_API_KEY',
    'softId'           => 123,
    'callback'         => 'https://your.site/result-receiver',
    'defaultTimeout'   => 120,
    'recaptchaTimeout' => 600,
    'pollingInterval'  => 10,
]);
```

### TwoCaptcha instance options

[](#twocaptcha-instance-options)

OptionDefault valueDescriptionsoftId-your software ID obtained after publishing in [2captcha sofware catalog](https://2captcha.com/software)callback-URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings](https://2captcha.com/setting/pingback) of your accountdefaultTimeout120Polling timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer from `res.php` API endpointrecaptchaTimeout600Polling timeout for ReCaptcha in seconds. Defines how long the module tries to get the answer from `res.php` API endpointpollingInterval10Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended> **IMPORTANT:** once `callback` is defined for `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL. To get the answer manually use [getResult method](#send--getresult)

Solve captcha
-------------

[](#solve-captcha)

When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly.

### Captcha options

[](#captcha-options)

OptionDefault ValueDescriptionnumeric0Defines if captcha contains numeric or other symbols [see more info in the API docs](https://2captcha.com/2captcha-api#normal_post)minLength0minimal answer lenghtmaxLength0maximum answer lengthphrase0defines if the answer contains multiple words or notcaseSensitive0defines if the answer is case sensitivecalc0defines captcha requires calculationlang-defines the captcha language, see the [list of supported languages](https://2captcha.com/2captcha-api#language)hintImg-an image with hint shown to workers with the captchahintText-hint or task text shown to workers with the captchaBelow you can find basic examples for every captcha type. Check out [examples directory](/examples) to find more examples with all available options.

### Normal Captcha

[](#normal-captcha)

To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image.

```
$result = $solver->normal('path/to/captcha.jpg');
```

### Text Captcha

[](#text-captcha)

This method can be used to bypass a captcha that requires to answer a question provided in clear text.

```
$result = $solver->text('If tomorrow is Saturday, what day is today?');
```

### ReCaptcha v2

[](#recaptcha-v2)

Use this method to solve ReCaptcha V2 and obtain a token to bypass the protection.

```
$result = $solver->recaptcha([
    'sitekey' => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
    'url'     => 'https://mysite.com/page/with/recaptcha',
]);
```

### ReCaptcha v3

[](#recaptcha-v3)

This method provides ReCaptcha V3 solver and returns a token.

```
$result = $solver->recaptcha([
    'sitekey' => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
    'url'     => 'https://mysite.com/page/with/recaptcha',
    'version' => 'v3',
]);
```

### FunCaptcha

[](#funcaptcha)

FunCaptcha (Arkoselabs) solving method. Returns a token.

```
$result = $solver->funcaptcha([
    'sitekey' => '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
    'url'     => 'https://mysite.com/page/with/funcaptcha',
]);
```

### GeeTest

[](#geetest)

Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.

```
$result = $solver->geetest([
    'gt'        => 'f1ab2cdefa3456789012345b6c78d90e',
    'challenge' => '12345678abc90123d45678ef90123a456b',
    'url'       => 'https://www.site.com/page/',
]);
```

### hCaptcha

[](#hcaptcha)

Use this method to solve hCaptcha challenge. Returns a token to bypass captcha.

```
$result = $solver->hcaptcha([
    'sitekey'   => '10000000-ffff-ffff-ffff-000000000001',
    'url'       => 'https://www.site.com/page/',
]);
```

### KeyCaptcha

[](#keycaptcha)

Token-based method to solve KeyCaptcha.

```
$result = $solver->keycaptcha([
    's_s_c_user_id'          => 10,
    's_s_c_session_id'       => '493e52c37c10c2bcdf4a00cbc9ccd1e8',
    's_s_c_web_server_sign'  => '9006dc725760858e4c0715b835472f22-pz-',
    's_s_c_web_server_sign2' => '2ca3abe86d90c6142d5571db98af6714',
    'url'                    => 'https://www.keycaptcha.ru/demo-magnetic/',
]);
```

### Capy

[](#capy)

Token-based method to bypass Capy puzzle captcha.

```
$result = $solver->capy([
    'sitekey' => 'PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v',
    'url'     => 'http://mysite.com/',
    'api_server' => 'https://jp.api.capy.me/',
]);
```

### Grid

[](#grid)

Grid method is originally called Old ReCaptcha V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes.

```
$result = $solver->grid('path/to/captcha.jpg');
```

### Canvas

[](#canvas)

Canvas method can be used when you need to draw a line around an object on image. Returns a set of points' coordinates to draw a polygon.

```
$result = $solver->canvas('path/to/captcha.jpg');
```

### ClickCaptcha

[](#clickcaptcha)

ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.

```
$result = $solver->coordinates('path/to/captcha.jpg');
```

### Rotate

[](#rotate)

This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle.

```
$result = $solver->rotate('path/to/captcha.jpg');
```

Other methods
-------------

[](#other-methods)

### send / getResult

[](#send--getresult)

These methods can be used for manual captcha submission and answer polling.

```
$id = $solver->send(['file' => 'path/to/captcha.jpg', ...]);

sleep(20);

$code = $solver->getResult($id);
```

### balance

[](#balance)

Use this method to get your account's balance

```
$balance = $solver->balance();
```

### report

[](#report)

Use this method to report good or bad captcha answer.

```
$solver->report($id, true); // captcha solved correctly
$solver->report($id, false); // captcha solved incorrectly
```

Error handling
--------------

[](#error-handling)

If case of an error captch solver throws an exception. It's important to properly handle these cases. We recommend to use `try catch` to handle exceptions.

```
try {
    $result = $solver->text('If tomorrow is Saturday, what day is today?');
} catch (\TwoCaptcha\Exception\ValidationException $e) {
    // invalid parameters passed
} catch (\TwoCaptcha\Exception\NetworkException $e) {
    // network error occurred
} catch (\TwoCaptcha\Exception\ApiException $e) {
    // api respond with error
} catch (\TwoCaptcha\Exception\TimeoutException $e) {
    // captcha is not solved so far
}
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b1adcb1a9621db7a8d4990dce83178b64ac1fc939b132732a49cafc0732de7e?d=identicon)[trongloikt192](/maintainers/trongloikt192)

---

Top Contributors

[![trongloikt192](https://avatars.githubusercontent.com/u/4520919?v=4)](https://github.com/trongloikt192 "trongloikt192 (2 commits)")[![loiabvn](https://avatars.githubusercontent.com/u/99628079?v=4)](https://github.com/loiabvn "loiabvn (1 commits)")

### Embed Badge

![Health badge](/badges/trongloikt192-2captcha/health.svg)

```
[![Health](https://phpackages.com/badges/trongloikt192-2captcha/health.svg)](https://phpackages.com/packages/trongloikt192-2captcha)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
