Skip to content

GeeTest v4 Task

GeeTest: Solving v3/v4

This task type is used to solve GeeTest captchas, including slider, icon, and other variants. The solution provides a complex object with validation data.

1. Create Task

Use the `createTask` method to initiate the solving process. You must provide the `websiteURL`, the GeeTest `captchaId`, and a `proxy`.

Task Object Parameters

PropertyTypeRequiredDescription
typeStringYesMust be `GeeTestTask`
websiteURLStringYesThe full URL of the page where the GeeTest captcha is present.
captchaIdStringYesThe `gt` or `captcha_id` public key for the GeeTest instance.
proxyStringYesYour proxy address in the format `http:login:password@ip:port`.
geetestApiServerSubdomainStringNoOptional. A custom subdomain for the GeeTest API if one is used by the target site.

Example Request

POST https://api.captchasonic.com/createTask
Host: api.captchasonic.com
Content-Type: application/json
{
    "apiKey": "YOUR_API_KEY",
    "task": {
        "type": "GeeTestTask",
        "websiteURL": "https://captest.jscaptcha.com",
        "captchaId": "62c528ead784206de7e6db17765b9ac0",
        "proxy": "http:login:[email protected]:8888"
    }
}

Example Response

A successful creation request returns a taskId which you will use in the next step.

{
    "errorId": 0,
    "status": "idle",
    "taskId": "9a0c1bf2-54ed-4c12-8d45-1234ac110987"
}

2. Get Result

After creating a task, use the `getTaskResult` method to check the status and retrieve the solution. Poll this endpoint every 5-10 seconds until the status is `completed`.

Example Request

POST https://api.captchasonic.com/getTaskResult
Host: api.captchasonic.com
Content-Type: application/json
{
    "apiKey": "YOUR_API_KEY",
    "taskId": "9a0c1bf2-54ed-4c12-8d45-1234ac110987"
}

Example Success Response

When the task status becomes completed, the response will contain the solution object.

{
    "errorId": 0,
    "status": "completed",
    "solution": {
        "captcha_id": "62c528ead784206de7e6db17765b9ac0",
        "lot_number": "a1b2c3d4e5f67890",
        "pass_token": "12345abcde_example_pass_token_67890",
        "gen_time": "1672531200",
        "captcha_output": "a1b2c3d4e5f67890_12345abcde_example_pass_token_67890"
    },
    "taskId": "9a0c1bf2-54ed-4c12-8d45-1234ac110987"
}

SDK Usage

# Coming soon: A simplified Python SDK
# pip install --upgrade captchasonic
#
# from captchasonic import CaptchaSonic
#
# client = CaptchaSonic(api_key="YOUR_API_KEY")
#
# solution = client.solve_geetest(
#   website_url="https://captest.jscaptcha.com",
#   captcha_id="62c528ead784206de7e6db17765b9ac0",
#   proxy="http:login:[email protected]:8888"
# )
# print(f"GeeTest Pass Token: {solution['pass_token']}")

Full Sample Code

import requests
import time

API_KEY = "YOUR_API_KEY"
API_URL = "https://api.captchasonic.com"

def solve_geetest():
    # 1. Create the task
    print("Creating GeeTest task...")
    create_payload = {
        "apiKey": API_KEY,
        "task": {
            "type": "GeeTestTask",
            "websiteURL": "https://captest.jscaptcha.com",
            "captchaId": "62c528ead784206de7e6db17765b9ac0",
            "proxy": "http:login:[email protected]:8888"
        }
    }
    res = requests.post(f"{API_URL}/createTask", json=create_payload)
    if res.status_code != 200:
        print(f"Error creating task: {res.text}")
        return

    task_id = res.json().get("taskId")
    if not task_id:
        print(f"Could not find taskId in response: {res.json()}")
        return
    
    print(f"Task created successfully. Task ID: {task_id}")

    # 2. Poll for the result
    while True:
        print("Polling for result...")
        time.sleep(5) # Wait 5 seconds between polls
        get_payload = {"apiKey": API_KEY, "taskId": task_id}
        res = requests.post(f"{API_URL}/getTaskResult", json=get_payload)
        
        if res.status_code != 200:
            print(f"Error getting result: {res.text}")
            continue

        resp_json = res.json()
        status = resp_json.get("status")
        
        if status == "completed":
            print("Task completed!")
            return resp_json.get("solution")
        elif status == "failed":
            print(f"Task failed: {resp_json.get('errorDescription')}")
            return
        elif status == "processing":
            print("Task is still processing, trying again...")
        else:
            print(f"Unknown status: {status}, response: {resp_json}")
            
# Run the solver
solution = solve_geetest()
if solution:
    print("\n--- SOLUTION ---")
    for key, value in solution.items():
        print(f"{key}: {value}")
    print("----------------")