Skip to Content
AnySolver logo
AnySolver
Async

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.

POSThttps://api.anysolver.com/getTaskResult

Authentication

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

FieldTypeRequiredDescription
clientKey*
stringYes

Your API key. Create one in a workspace of the AnySolver dashboard.

taskId*
stringYes

Unique identifier returned when the task was created.

Example

{
    "clientKey": "YOUR_API_KEY",
    "taskId": "01KFNDF328KAN2AJ3BNHCQYE88"
}

Response body

FieldTypeRequiredDescription
status*
Yes

Task status: "processing", "ready", or "failed".

Example: ready

errorId*
Yes

0 on success; 1 or 2 on an error. Branch on errorCode: Error IDs explains the two error groups.

Example: 0

taskId
stringNo

Unique identifier returned when the task was created.

Example: 01KFNDF328KAN2AJ3BNHCQYE88

errorCode
No

Machine-readable error code.

Example: CAPTCHA_UNSOLVABLE

errorDescription
stringNo

Human-readable error message with resolution hints.

Example: The captcha could not be solved.

cost
numberNo

Actual cost charged for this task in USD.

Example: 0.002

taskType
No

The type of CAPTCHA task to solve.

Example: ReCaptchaV2TokenProxyLess

provider
No

Provider that handled this task. While processing, the provider currently solving it.

Example: Multibot

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

StatusDescription
ProcessingTask is queued or being solved by a provider.
ReadyTask completed successfully. Solution is available.
FailedTask 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.

FieldTypeDescription
indexnumberIndex of this proxy in the task.proxy array (0 for a single proxy).
typestringhttp, https, socks4 or socks5.
hoststringProxy host.
portnumberProxy port.
usernamestringProxy username, if any.
passwordstringProxy 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.

FieldTypeDescription
totalAttemptsnumberAttempts so far. While processing, this includes the attempt in progress.
retriesnumberSame-provider retries performed.
fallbacksnumberProvider fallbacks performed.
providerstringProvider of the final attempt. While processing, the provider solving it now.
attemptsarrayOne entry per attempt, including the one in progress while processing.

Each entry in attempts:

FieldTypeDescription
attemptnumberZero-based attempt index.
providerstringProvider used for this attempt.
kindstringHow the attempt was reached: initial, retry or fallback.
proxyIndexnumberIndex of the proxy used, if any.
errorCodestringError that ended this attempt. Absent on success and on the attempt in progress.
errorDescriptionstringDescription of that error.
durationMsnumberAttempt duration in milliseconds. Absent on the attempt in progress.
keySourcestringWhose 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.
byokKeyIdstringThe 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.

createTask solved error or 30 min deleted after 5 min deleted after 5 min processing ready failed

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.

WhereWhatHow long
AnySolver's task storeThe whole task, with request, solution and error. getTaskResult and the dashboard read it.5 minutes after the task finishes
AnySolver's charge recordOne billing line: task type, provider, cost, refund and errorCode. Not in the dashboard; support finds it by taskId.90 days
Your browserThe 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 codeCauseFix
TASK_NOT_FOUNDThe 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_UNSOLVABLEThe provider could not solve the CAPTCHA.Check websiteKey, websiteURL and the proxy, then create a new task.
TASK_TIMEOUTThe task did not finish in time.Create a new task.
PROXY_CONNECTION_FAILEDThe provider could not connect through your proxy.Check that the proxy is reachable from the public internet.
PROVIDER_PAUSEDThe 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.