Skip to Content
Peak Solutions

getTaskResult

POST /getTaskResult returns a task's status and, once it's ready, its solution.

POST https://api.peak.fo/getTaskResult

Returns whether a task from createTask is still being solved, and its solution once it's ready. Poll it every 3 to 5 seconds.

Request

FieldTypeRequiredDescription
clientKeystringYesYour API key. Any key on the account that created the task works.
taskIdnumber, stringYesThe taskId from createTask. A number may also be sent as a string.
Terminal
curl https://api.peak.fo/getTaskResult \
  -H "Content-Type: application/json" \
  -d '{"clientKey": "pk_your_api_key", "taskId": 4826153907261}'

Response

FieldTypeDescription
errorIdnumber0 if the request worked.
statusstringprocessing while solving, ready when the solution is in.
solutionobjectOnly when ready. Its fields are below.
coststringOnly when ready. What the solve was charged, in USD, as a string.
createTimenumberOnly when ready. When the task was created, as a Unix time in seconds.
endTimenumberOnly when ready. When the solve finished, as a Unix time in seconds.
solveCountnumberOnly when ready. Always 1.
taskIdstringOnly when ready, for CapSolver tasks. The task's id.

Solution

Tasksolution fields
Turnstiletoken: the Turnstile token.
5-second challenge, CapMonster codecf_clearance: the cookie value. userAgent: the user-agent the cookie is bound to.
5-second challenge, CapSolver codecookies: every cookie set, including cf_clearance. token: the cf_clearance value. userAgent.

Send the cookie with the same userAgent, through the same proxy you gave the task. Cloudflare checks both.

{
  "errorId": 0,
  "status": "processing"
}

A failed solve isn't charged. errorDescription says why it failed, in the same words as the native API's error. See Error codes for how failures map to errorCode.

Task not found

ERROR_NO_SUCH_CAPCHA_ID (CapSolver code: ERROR_TASKID_INVALID) means one of these:

  • The taskId is wrong.
  • The task finished more than 5 minutes ago and was removed.
  • Peak Solutions restarted since you created it.
  • It belongs to another account.

Create a new task. If the solve had already finished, it was charged.

A complete loop

import time

import requests

API = "https://api.peak.fo"
API_KEY = "pk_your_api_key"


def solve_turnstile(url: str, sitekey: str) -> str:
    """Creates a Turnstile task and polls until it has a token."""
    created = requests.post(
        f"{API}/createTask",
        json={
            "clientKey": API_KEY,
            "task": {"type": "TurnstileTaskProxyless", "websiteURL": url, "websiteKey": sitekey},
        },
        timeout=30,
    ).json()
    if created["errorId"] != 0:
        raise RuntimeError(f"{created['errorCode']}: {created['errorDescription']}")

    for _ in range(40):
        time.sleep(3)
        result = requests.post(
            f"{API}/getTaskResult",
            json={"clientKey": API_KEY, "taskId": created["taskId"]},
            timeout=30,
        ).json()
        if result["errorId"] != 0:
            raise RuntimeError(f"{result['errorCode']}: {result['errorDescription']}")
        if result["status"] == "ready":
            return result["solution"]["token"]
    raise TimeoutError("no result after 2 minutes")


if __name__ == "__main__":
    print(solve_turnstile("https://example.com/login", "0x4AAAAAAA..."))

On this page