2Captcha format API
2Captcha's in.php and res.php for Turnstile, so a 2Captcha client works after changing only its base URL and key. Priced and charged as the other dialects are. Every reply is HTTP 200, as plain text or, with `json=1`, JSON; only a failure outside the endpoint is a problem document.
Every operation of the API reference is generated from the contract the API serves, version 0.1.0. Replace YOUR_API_KEY in the samples with your key; each response shows an example in the contract's shape.
Submit a task (2Captcha)
/in.phpAuthentication. Your API key, as key in the query string, as 2Captcha's clients send it.
2Captcha's in.php for Cloudflare Turnstile: method=turnstile with sitekey and pageurl, and optionally action, data, proxy and pingback. The reply is OK|<task id>, or {"status": 1, "request": "<task id>"} with json=1; poll res.php with the ID. Priced, held and charged as POST /v1/tasks is; an Idempotency-Key header works as it does there.
Parameters
| Field | What it is |
|---|---|
key | Your API key, |
method |
|
sitekey | The widget's site key. |
pageurl | The page the widget is on: a public http or https page, as |
action | The widget's action, if it sets one. |
data | The widget's cData, if it sets one. |
pingback | Where to POST the result once the task ends: 2Captcha's pingback form, |
json |
|
proxy | Your proxy as |
proxytype |
|
soft_id | Accepted and ignored. |
header_acao | Accepted and ignored: this service sends no CORS headers. |
pagedata | Sent for a Turnstile widget on a Cloudflare challenge page, which this format does not serve: a task with it is |
userAgent | Accepted and ignored. |
Idempotency-Key | Your ID for this task, 1 to 255 visible ASCII characters, as on |
Responses
| Status | What it means |
|---|---|
| 200 OK |
text/plain, TwoCaptchaReply (application/json) |
| Any other status | Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Problem (application/problem+json) |
Error codes
The errors reference says what each means, whether a retry helps and what it costs.
Request
curl 'https://api.zerocaptcha.io/in.php?key=YOUR_API_KEY&method=turnstile&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&pageurl=https%3A%2F%2Fexample.com%2Flogin&json=1' \ -H "Idempotency-Key: order-4521-attempt-1"const response = await fetch("https://api.zerocaptcha.io/in.php?key=YOUR_API_KEY&method=turnstile&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&pageurl=https%3A%2F%2Fexample.com%2Flogin&json=1", { headers: { "Idempotency-Key": "order-4521-attempt-1", },});console.log(response.status, await response.text());import requests
response = requests.get( "https://api.zerocaptcha.io/in.php?key=YOUR_API_KEY&method=turnstile&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&pageurl=https%3A%2F%2Fexample.com%2Flogin&json=1", headers={"Idempotency-Key": "order-4521-attempt-1"}, timeout=30,)print(response.status_code, response.text)Response
OK
{
"status": 1,
"request": "10000004821"
}ERROR_ZERO_BALANCE
{
"status": 0,
"request": "ERROR_ZERO_BALANCE",
"error_text": "Your available balance does not cover the task. Add funds."
}JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|10000004821, ERROR_ZERO_BALANCE.
payload_too_large
{
"type": "https://zerocaptcha.io/docs/reference/errors/#payload_too_large",
"title": "Request body too large",
"status": 413,
"instance": "/in.php",
"code": "payload_too_large",
"request_id": "0192f3a4-7b1c-7d2e-9f10-3c4d5e6f7a8b"
}Example values in the contract's shape, version 0.1.0.
Submit a task by POST (2Captcha)
/in.phpAuthentication. Your API key, as key in the form or JSON body, or in the query string, which wins, as 2Captcha's clients send it.
in.php as a POST, the way 2Captcha's own clients send it: the parameters as a form (application/x-www-form-urlencoded or multipart/form-data) or a JSON object, and any in the query string too, which win. The replies are those of GET /in.php.
Parameters
| Field | What it is |
|---|---|
Idempotency-Key | Your ID for this task, 1 to 255 visible ASCII characters, as on |
Request body Form · TwoCaptchaSubmit
Also taken as multipart/form-data or a JSON object.
| Field | What it is |
|---|---|
key | Your API key, |
method |
|
pageurl | The page the widget is on: a public http or https page, as |
sitekey | The widget's site key. |
action | The widget's action, if it sets one. |
data | The widget's cData, if it sets one. |
header_acao | Accepted and ignored: this service sends no CORS headers. |
json |
|
pagedata | Sent for a Turnstile widget on a Cloudflare challenge page, which this format does not serve: a task with it is |
pingback | Where to POST the result once the task ends: 2Captcha's pingback form, |
proxy | Your proxy as |
proxytype |
|
soft_id | Accepted and ignored. |
userAgent | Accepted and ignored. |
Responses
| Status | What it means |
|---|---|
| 200 OK |
text/plain, TwoCaptchaReply (application/json) |
| Any other status | Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Problem (application/problem+json) |
Error codes
The errors reference says what each means, whether a retry helps and what it costs.
Request
curl -X POST https://api.zerocaptcha.io/in.php \ -H "Idempotency-Key: order-4521-attempt-1" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d 'key=YOUR_API_KEY&method=turnstile&pageurl=https%3A%2F%2Fexample.com%2Flogin&sitekey=0x4AAAAAAAB1cD2eF3gH4iJ5&json=1'const response = await fetch("https://api.zerocaptcha.io/in.php", { method: "POST", headers: { "Idempotency-Key": "order-4521-attempt-1", "Content-Type": "application/x-www-form-urlencoded", }, body: new URLSearchParams({ "key": "YOUR_API_KEY", "method": "turnstile", "pageurl": "https://example.com/login", "sitekey": "0x4AAAAAAAB1cD2eF3gH4iJ5", "json": "1" }),});console.log(response.status, await response.text());import requests
response = requests.post( "https://api.zerocaptcha.io/in.php", headers={"Idempotency-Key": "order-4521-attempt-1"}, data={ "key": "YOUR_API_KEY", "method": "turnstile", "pageurl": "https://example.com/login", "sitekey": "0x4AAAAAAAB1cD2eF3gH4iJ5", "json": "1", }, timeout=30,)print(response.status_code, response.text)Response
OK
{
"status": 1,
"request": "10000004821"
}ERROR_ZERO_BALANCE
{
"status": 0,
"request": "ERROR_ZERO_BALANCE",
"error_text": "Your available balance does not cover the task. Add funds."
}JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|10000004821, ERROR_ZERO_BALANCE.
payload_too_large
{
"type": "https://zerocaptcha.io/docs/reference/errors/#payload_too_large",
"title": "Request body too large",
"status": 413,
"instance": "/in.php",
"code": "payload_too_large",
"request_id": "0192f3a4-7b1c-7d2e-9f10-3c4d5e6f7a8b"
}Example values in the contract's shape, version 0.1.0.
Get a result or the balance (2Captcha)
/res.phpAuthentication. Your API key, as key in the query string, as 2Captcha's clients send it.
2Captcha's res.php. action=get&id=<task id> answers CAPCHA_NOT_READY while the task runs, then OK|<token>, or an error code such as ERROR_CAPTCHA_UNSOLVABLE (nothing charged) or ERROR_TOKEN_EXPIRED; action=get2 adds the price, OK|<token>|<price>. action=get&ids=<id>,<id>,… reads up to 100 tasks at once: each one's token, CAPCHA_NOT_READY or error code, in order, joined by |. action=reportbad or reportgood with id records whether the site took the token (OK_REPORT_RECORDED): recorded for our staff, never refunded, as tasks are final. action=getbalance answers the available balance in US dollars, such as 12.3456. With json=1, each as {"status": …, "request": …}. Reads share their budgets with REST; over one, the reply is ERROR: 1005 with Retry-After. action=get or get2 with id, of a task still running, is answered as soon as the task ends, or after a few seconds with CAPCHA_NOT_READY.
Parameters
| Field | What it is |
|---|---|
key | Your API key, as for in.php. |
action |
|
id | The task's ID, as in.php gave it, for |
ids | With |
json |
|
Responses
| Status | What it means |
|---|---|
| 200 OK | The token, text/plain, TwoCaptchaReply (application/json) |
| Any other status | Only a failure outside the dialect, as RFC 9457 problem details: a body over the size limit (413), a request that ran out of time (504), this instance shedding load (503, with Problem (application/problem+json) |
Error codes
The errors reference says what each means, whether a retry helps and what it costs.
Request
curl 'https://api.zerocaptcha.io/res.php?key=YOUR_API_KEY&action=get&id=10000004821&json=1'const response = await fetch("https://api.zerocaptcha.io/res.php?key=YOUR_API_KEY&action=get&id=10000004821&json=1");console.log(response.status, await response.text());import requests
response = requests.get( "https://api.zerocaptcha.io/res.php?key=YOUR_API_KEY&action=get&id=10000004821&json=1", timeout=30,)print(response.status_code, response.text)Response
OK
{
"status": 1,
"request": "token"
}OK, with action=get2
{
"status": 1,
"request": "token",
"price": "0.0004"
}CAPCHA_NOT_READY
{
"status": 0,
"request": "CAPCHA_NOT_READY"
}ERROR_CAPTCHA_UNSOLVABLE
{
"status": 0,
"request": "ERROR_CAPTCHA_UNSOLVABLE",
"error_text": "The task was not solved, or not before its deadline; nothing is charged."
}JSON, as the samples ask with json=1. Without it, the same replies in plain text: OK|token, OK|token|0.0004, CAPCHA_NOT_READY, ERROR_CAPTCHA_UNSOLVABLE.
payload_too_large
{
"type": "https://zerocaptcha.io/docs/reference/errors/#payload_too_large",
"title": "Request body too large",
"status": 413,
"instance": "/res.php",
"code": "payload_too_large",
"request_id": "0192f3a4-7b1c-7d2e-9f10-3c4d5e6f7a8b"
}Example values in the contract's shape, version 0.1.0.