Solve hCaptcha in PHP.
NoneCap is a captcha solver service that focuses on hCaptcha. From
PHP it is two HTTP calls: send the sitekey and page URL, get back a real
P1_ token. Below is a small client built on cURL, then the token going
into a page with Symfony Panther, and into a plain form POST with Guzzle.
What a PHP script needs
Two endpoints: POST /v1/solves to create a solve and
GET /v1/solves/{id} to read it, with your API key as a Bearer
token and JSON both ways. You send the sitekey and the page URL, and the response
carries the token as a string. Your script only places it in the form.
The client needs PHP 8.1 or later with the cURL extension, and no Composer packages.
Put your key in NONECAP_KEY; the code reads it from the environment, so
it never sits in source control.
The client in three small files
An exception that carries the API’s error code:
<?php
final class NoneCapException extends RuntimeException
{
// $error is the API's {code, message, param}, or null when the body is not its JSON.
public function __construct(public readonly int $status, public readonly ?array $error)
{
$detail = $error ? ": {$error['code']} {$error['message']}" : '';
parent::__construct("NoneCap HTTP $status$detail");
}
} The HTTP call, with the key on every request:
<?php
abstract class NoneCapHttp
{
public function __construct(private string $apiKey) {}
protected function call(string $path, ?array $body = null): array
{
$ch = curl_init("https://api.nonecap.com/v1/$path");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$this->apiKey}", 'Content-Type: application/json',
]]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$raw = curl_exec($ch);
if ($raw === false) throw new RuntimeException('NoneCap: ' . curl_error($ch));
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$data = json_decode($raw, true);
if ($status >= 300) throw new NoneCapException($status, $data['error'] ?? null);
return $data;
}
} And the client your code calls, which returns when the solve is finished:
<?php
final class NoneCap extends NoneCapHttp
{
// Returns once the solve is finished: status solved, failed, expired or cancelled.
public function solve(array $request): array
{
$solve = $this->call('solves?wait=90', $request);
while (in_array($solve['status'], ['pending', 'solving'], true)) {
$solve = $this->call("solves/{$solve['id']}?wait=90");
}
return $solve;
}
public function solveHCaptcha(string $sitekey, string $url): string
{
$solve = $this->solve(['type' => 'hcaptcha', 'sitekey' => $sitekey, 'url' => $url]);
return $solve['token'] ?? throw new RuntimeException("solve {$solve['status']}");
}
} Calling it:
<?php
foreach (['NoneCapException', 'NoneCapHttp', 'NoneCap'] as $f) require_once __DIR__ . "/$f.php";
$nonecap = new NoneCap(getenv('NONECAP_KEY'));
$token = $nonecap->solveHCaptcha(
'f5ab1c2d-7e8f-4a9b-b1c2-d3e4f5a6b7c8',
'https://target.example/login',
);
echo $token, PHP_EOL; // P1_eyJ0eXAi... ?wait=90 asks the server to hold the request until the solve is
finished, so the token usually comes back on the first response and there is no
polling loop to write. If the solve is still running after 90 seconds, the API
answers 202 with status pending or solving, and the loop
asks again with GET ?wait=90. cURL sets no overall timeout by default,
so the held request is never cut short on your side.
A non-2xx response becomes a NoneCapException with the API’s error
code, such as unauthorized, insufficient_credits
or concurrency_limit_exceeded; the error
reference lists them all. A solve that ends failed or
expired is not charged, so a retry costs time, not credits.
If you would rather not hold connections open (a web request behind a proxy with a
60-second read timeout, for one), drop ?wait: the POST returns at once
with status pending, and you read
GET /v1/solves/{id} every couple of seconds until the status
changes.
Symfony Panther
Symfony Panther
(composer require symfony/panther) drives a real Chrome through
ChromeDriver. It needs a chromedriver that matches your Chrome, in
drivers/ or on your PATH;
composer require dbrekelmans/bdi then
vendor/bin/bdi detect drivers downloads it. The script that puts the token
into the page goes in its own file:
<?php
// Fills the response textareas and calls the page's data-callback, if it has one.
return <<<'JS'
const token = arguments[0];
for (const name of ['h-captcha-response', 'g-recaptcha-response']) {
const el = document.querySelector(`textarea[name="${name}"]`);
if (el) el.value = token;
}
const cb = document.querySelector('[data-callback]')?.getAttribute('data-callback');
if (cb && typeof window[cb] === 'function') window[cb](token);
JS;
The h-captcha-response textarea is in the top document, not inside the
widget’s iframe, so the script reaches it with no frame switch. It also fills
g-recaptcha-response, which some backends read instead, and calls the
page’s data-callback function: invisible widgets submit from that
callback, not from a field change. Then the flow is: read the sitekey off the page,
get a token, run the script, submit.
<?php
require __DIR__ . '/vendor/autoload.php';
foreach (['NoneCapException', 'NoneCapHttp', 'NoneCap'] as $f) require_once __DIR__ . "/$f.php";
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverExpectedCondition;
use Symfony\Component\Panther\Client;
$nonecap = new NoneCap(getenv('NONECAP_KEY'));
$client = Client::createChromeClient();
$client->request('GET', 'https://target.example/login');
$widget = $client->findElement(WebDriverBy::cssSelector('[data-sitekey]'));
$sitekey = $widget->getAttribute('data-sitekey');
$token = $nonecap->solveHCaptcha($sitekey, $client->getCurrentURL());
$client->executeScript(require __DIR__ . '/inject.php', [$token]);
$submit = $client->findElement(WebDriverBy::cssSelector('[type=submit]'));
$submit->click();
$client->wait(15)->until(WebDriverExpectedCondition::stalenessOf($submit));
$client->quit();
Waiting for the submit button to go stale keeps the script alive until the next page
has loaded, even when the form posts back to the same URL. Panther’s client is a
php-webdriver
driver, so findElement, executeScript and wait
work the same on a RemoteWebDriver connected to a Selenium server; there
the page is loaded with get($url) instead of request().
If the site rejects the token, make sure the browser’s user agent matches the
solve’s returned user_agent: some sites refuse a token submitted
by a different browser version. If a page keeps its sitekey out of the DOM and passes
it straight to hcaptcha.render(), read the sitekey parameter
off the hcaptcha.com/1/api.js script URL instead; the
sitekey guide shows where to look.
Without a browser: Guzzle and a form POST
Many sites don’t need a browser at all. Fetch the page, solve, and post the form
with the token in h-captcha-response. Keep one cookie jar and one exit IP
for the page load, the solve and the submit: give NoneCap the same proxy your
Guzzle client uses
(composer require guzzlehttp/guzzle), and send the solve’s
returned user_agent as your User-Agent header.
<?php
require __DIR__ . '/vendor/autoload.php';
foreach (['NoneCapException', 'NoneCapHttp', 'NoneCap'] as $f) require_once __DIR__ . "/$f.php";
$nonecap = new NoneCap(getenv('NONECAP_KEY'));
$url = 'https://target.example/login';
$proxy = 'http://user:pass@203.0.113.10:8080';
$site = new GuzzleHttp\Client(['cookies' => true, 'proxy' => $proxy]);
$html = (string) $site->get($url)->getBody();
if (!preg_match('/data-sitekey="(.+?)"/', $html, $m)) throw new RuntimeException('no sitekey');
$solve = $nonecap->solve(
['type' => 'hcaptcha', 'sitekey' => $m[1], 'url' => $url, 'proxy' => $proxy],
);
if ($solve['status'] !== 'solved') throw new RuntimeException("solve {$solve['status']}");
$token = $solve['token'];
$res = $site->post($url, [
'headers' => ['User-Agent' => $solve['user_agent']],
'form_params' => ['h-captcha-response' => $token, 'g-recaptcha-response' => $token],
]);
Tokens are single-use and expire within minutes, so solve right before you submit.
The proxy guide covers the proxy
formats and why a token solved on one exit can fail when submitted from another, and
the web scraping guide walks the whole fetch,
solve and submit pipeline.
Enterprise sitekeys
Some enterprise deployments pass a fresh rqdata value into
hcaptcha.render() or execute(). When the page supplies one,
send it with the enterprise type:
$solve = $nonecap->solve([
'type' => 'hcaptcha_enterprise',
'sitekey' => $sitekey,
'url' => $pageUrl,
'rqdata' => $rqdata,
]);
Capture rqdata right before solving; it is tied to one challenge. The
rqdata guide shows where it lives
in the page.
Already using 2captcha-php?
NoneCap answers 2Captcha’s in.php / res.php API at
https://api.nonecap.com/, with your NoneCap API key
as key and method=hcaptcha. The
2captcha/2captcha
package takes the server URL as an option, so pointing it there is the whole change:
<?php
require __DIR__ . '/vendor/autoload.php';
$solver = new TwoCaptcha\TwoCaptcha([
'apiKey' => getenv('NONECAP_KEY'),
'server' => 'https://api.nonecap.com/compat/2captcha',
]);
$result = $solver->hcaptcha([
'sitekey' => 'f5ab1c2d-7e8f-4a9b-b1c2-d3e4f5a6b7c8',
'url' => 'https://target.example/login',
]);
echo $result->code, PHP_EOL; // the hCaptcha token
The endpoint accepts sitekey, pageurl, data
(rqdata), userAgent, proxy and proxytype, and
res.php answers get, get2,
reportgood, reportbad and getbalance (in
credits). Other captcha methods answer ERROR_METHOD_DOES_NOT_EXIST.
Solves made this way bill and show in your dashboard like any other. The
API reference has the full
mapping, and NoneCap vs 2Captcha compares the two
services.
Scope, honestly
NoneCap solves hCaptcha only: regular, invisible, and enterprise sitekeys. If your PHP code is facing reCAPTCHA or Cloudflare Turnstile, this API won’t help today. Check which widget the page loads before writing the integration.
Last updated November 2026.
Frequently asked
Is there an official PHP SDK?
Does the client need Composer?
Which PHP version do the examples need?
readonly properties (8.1) and throw as an expression (8.0).How much does each solve cost?
How do I run many solves at once from PHP?
concurrency_limit_exceeded. The API reference lists the cap for each tier.