getTaskResult
Poll getTaskResult with a taskId to read the task status and, once it is ready, its solution and final cost. Polling is free, only the task is charged.
getTaskResult returns a task's current status and, once the task is ready, its solution and final cost. Polling is free: only the task is charged.
https://api.anysolver.com /getTaskResultAuthentication
Send an API key as clientKey in the JSON body, with the header Content-Type: application/json. Any API key of the account that created the task can read it. A key of another account gets TASK_NOT_FOUND, the same answer as for an unknown task.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
clientKey* | string | Yes | Your API key. Create one in a workspace of the AnySolver dashboard. |
taskId* | string | Yes | Unique identifier returned when the task was created. |
Example
{
"clientKey": "YOUR_API_KEY",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88"
}Response body
| Field | Type | Required | Description |
|---|---|---|---|
status* | Yes | Task status: "processing", "ready", or "failed". Example: | |
errorId* | Yes |
Example: | |
taskId | string | No | Unique identifier returned when the task was created. Example: |
errorCode | No | Machine-readable error code. Example: | |
errorDescription | string | No | Human-readable error message with resolution hints. Example: |
cost | number | No | Actual cost charged for this task in USD. Example: |
taskType | No | The type of CAPTCHA task to solve. Example: | |
provider | No | Provider that handled this task. While processing, the provider currently solving it. Example: |
The fields of solution depend on the task type; each task type's page under Tasks lists them. Errors arrive with HTTP 200 and status: "failed", so branch on errorId and status. Error IDs explains what each errorId value means.
Status values
| Status | Description |
|---|---|
| Processing | Task is queued or being solved by a provider. |
| Ready | Task completed successfully. Solution is available. |
| Failed | Task failed. Check errorCode for details. |
Examples
A task that is still being solved returns processing. Poll again.
{
"status": "processing",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88",
"errorId": 0,
"taskType": "ReCaptchaV2TokenProxyLess",
"provider": "Multibot"
}A solved task returns ready with solution and cost. Use the solution.
{
"status": "ready",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88",
"errorId": 0,
"cost": 0.00012,
"taskType": "ReCaptchaV2TokenProxyLess",
"provider": "Multibot",
"solution": {
"token": "03AGdBq24PBCbwiDRaS_MJ7Z…"
}
}A failed task returns failed with errorCode. cost is 0 when the failure was refunded. Look up errorCode in Errors before you create a new task.
{
"status": "failed",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88",
"errorId": 1,
"errorCode": "CAPTCHA_UNSOLVABLE",
"errorDescription": "The captcha could not be solved. Check your parameters or try again.",
"cost": 0,
"taskType": "ReCaptchaV2TokenProxyLess",
"provider": "Multibot"
}Used proxy
When a finished task used a proxy, the response includes it as usedProxy: the proxy you sent, in the fields below plus its index, whether you sent it as an object or a string. With Auto Retry or Auto Fallback, it is the proxy of the final attempt. usedProxy is absent while the task is processing.
| Field | Type | Description |
|---|---|---|
index | number | Index of this proxy in the task.proxy array (0 for a single proxy). |
type | string | http, https, socks4 or socks5. |
host | string | Proxy host. |
port | number | Proxy port. |
username | string | Proxy username, if any. |
password | string | Proxy password, if any. |
Retry and fallback statistics
A task that runs with Auto Retry or Auto Fallback can return a retry object that lists every attempt. It is off by default to keep responses small. Turn it on per request with settings.statistics: true on createTask, or for every request on a key with Response statistics on the API keys page of the key's workspace.
retry is returned while the task is still processing, and then includes the attempt in progress. Poll a slow task to see which attempts failed and which provider is solving it now.
| Field | Type | Description |
|---|---|---|
totalAttempts | number | Attempts so far. While processing, this includes the attempt in progress. |
retries | number | Same-provider retries performed. |
fallbacks | number | Provider fallbacks performed. |
provider | string | Provider of the final attempt. While processing, the provider solving it now. |
attempts | array | One entry per attempt, including the one in progress while processing. |
Each entry in attempts:
| Field | Type | Description |
|---|---|---|
attempt | number | Zero-based attempt index. |
provider | string | Provider used for this attempt. |
kind | string | How the attempt was reached: initial, retry or fallback. |
proxyIndex | number | Index of the proxy used, if any. |
errorCode | string | Error that ended this attempt. Absent on success and on the attempt in progress. |
errorDescription | string | Description of that error. |
durationMs | number | Attempt duration in milliseconds. Absent on the attempt in progress. |
keySource | string | Whose provider key ran this attempt: byok (one of your own keys, see settings.routing.byok) or anysolver. Set on tasks that could use your own keys. |
byokKeyId | string | The ID of your own key that ran this attempt (byok_…, shown on the BYOK page), when keySource is byok. |
A proxyless task whose first provider fails with CAPTCHA_UNSOLVABLE returns this while the fallback attempt runs. Its attempts carry no proxyIndex, and the result has no usedProxy.
{
"status": "processing",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88",
"errorId": 0,
"taskType": "ReCaptchaV2TokenProxyLess",
"provider": "Multibot",
"retry": {
"totalAttempts": 2,
"retries": 0,
"fallbacks": 1,
"provider": "Multibot",
"attempts": [
{
"attempt": 0,
"provider": "SCTG",
"kind": "initial",
"errorCode": "CAPTCHA_UNSOLVABLE",
"errorDescription": "The captcha could not be solved. Check your parameters or try again.",
"durationMs": 18234
},
{
"attempt": 1,
"provider": "Multibot",
"kind": "fallback"
}
]
}
}An example run where the cheapest provider failed: SCTG, the cheapest for ReCaptchaV2TokenProxyLess at $0.08 per 1,000, returned CAPTCHA_UNSOLVABLE, and Multibot solved it. cost is Multibot's catalog rate, 0.00012 USD for this task ($0.12 per 1,000); when the cheapest provider solves, you pay its rate.
{
"status": "ready",
"taskId": "01KFNDF328KAN2AJ3BNHCQYE88",
"errorId": 0,
"cost": 0.00012,
"taskType": "ReCaptchaV2TokenProxyLess",
"provider": "Multibot",
"solution": {
"token": "03AGdBq24PBCbwiDRaS_MJ7Z…"
},
"retry": {
"totalAttempts": 2,
"retries": 0,
"fallbacks": 1,
"provider": "Multibot",
"attempts": [
{
"attempt": 0,
"provider": "SCTG",
"kind": "initial",
"errorCode": "CAPTCHA_UNSOLVABLE",
"errorDescription": "The captcha could not be solved. Check your parameters or try again.",
"durationMs": 18234
},
{
"attempt": 1,
"provider": "Multibot",
"kind": "fallback",
"durationMs": 9120
}
]
}
}Polling
Poll until status is ready or failed, as often as every 0.5 seconds. Polls count toward the request limit per IP. Every task reaches ready or failed within its 30-minute lifetime, so keep polling instead of giving up: a task you stop polling still runs and is still charged if it succeeds. An overall timeout of 31 minutes always reads the final status.
const API_URL = 'https://api.anysolver.com';
const API_KEY = 'YOUR_API_KEY';
const POLL_INTERVAL_MS = 1_000;
const POLL_TIMEOUT_MS = 31 * 60_000;
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function call(endpoint, params) {
const response = await fetch(`${API_URL}/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ clientKey: API_KEY, ...params }),
});
const data = await response.json();
if (data.errorId !== 0) throw new Error(`${data.errorCode}: ${data.errorDescription}`);
return data;
}
async function solve(task) {
const { taskId } = await call('createTask', { task });
const deadline = Date.now() + POLL_TIMEOUT_MS;
while (Date.now() < deadline) {
await sleep(POLL_INTERVAL_MS);
const result = await call('getTaskResult', { taskId });
if (result.status === 'ready') return result.solution;
}
throw new Error(`Task ${taskId} did not finish in time`);
}
solve({
type: 'ReCaptchaV2TokenProxyLess',
websiteURL: 'https://www.google.com/recaptcha/api2/demo',
websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
pageTitle: 'ReCAPTCHA demo',
}).then((solution) => console.log('Token:', solution.token));Task lifetime
A task can stay processing for at most 30 minutes from createTask, across every retry and fallback. A task still running then fails with TASK_TIMEOUT, and its estimate is refunded. A finished task stays readable for 5 minutes, then it is deleted and getTaskResult returns TASK_NOT_FOUND.
Save the solution as soon as you receive it
A deleted task cannot be read again, and its solution is lost: you would pay for a new task. Store the solution
from the first response that has status: "ready".
What is kept after that
Three places keep part of a task after it leaves the task store.
| Where | What | How long |
|---|---|---|
| AnySolver's task store | The whole task, with request, solution and error. getTaskResult and the dashboard read it. | 5 minutes after the task finishes |
| AnySolver's charge record | One billing line: task type, provider, cost, refund and errorCode. Not in the dashboard; support finds it by taskId. | 90 days |
| Your browser | The dashboard's copy of each finished task it showed while the task was in the task store. | Up to 30 days; least recently viewed dropped past 5 MB |
Your usage and spend totals in the dashboard are stored separately, so they stay correct after the tasks are deleted. To keep a failure reason, log the errorCode from getTaskResult in your own integration.
Errors
A poll returns these codes, among others.
| Error code | Cause | Fix |
|---|---|---|
TASK_NOT_FOUND | The taskId is unknown, was deleted 5 minutes after the task finished, or belongs to another account. | Poll with a key of the account that created the task, within 5 minutes of the task finishing. |
CAPTCHA_UNSOLVABLE | The provider could not solve the CAPTCHA. | Check websiteKey, websiteURL and the proxy, then create a new task. |
TASK_TIMEOUT | The task did not finish in time. | Create a new task. |
PROXY_CONNECTION_FAILED | The provider could not connect through your proxy. | Check that the proxy is reachable from the public internet. |
PROVIDER_PAUSED | The provider was paused while the task waited for it. | See PROVIDER_PAUSED. |
A task that fails with CAPTCHA_UNSOLVABLE, TASK_TIMEOUT, PROXY_CONNECTION_FAILED or PROVIDER_PAUSED is refunded in full: its cost is 0. Whether other codes are refunded is in the error code reference, and how a refund reaches your balance in Refunds.
Related
POSTcreateTask
Submit a CAPTCHA task with createTask: AnySolver picks a provider by your routing mode, deducts the estimate and returns a taskId to poll.
POSTsolveTask
Create a CAPTCHA task and receive its result in one request with solveTask, which waits up to 80 seconds and charges exactly as createTask does.