Skip to content
On this page
Home
>Task(Token)
>Geetest

GeeTestTask: solving GeeTest

TIP

Create the task with the createTask method and get the result with the getTaskResult method.

The task type types that we support:

  • GeeTestTaskProxyLess

SUPPORT IMG TYPES

TypeNoteState
img.pngslidestable
img_2.pngicon clickstable
img_2.pngicon crushstable
img_2.pngninestable
img_2.pnggobangstable

Create Task

Create a task with the createTask to create a task.

Task Object Structure

PropertiesTypeRequiredDescription
typeStringRequiredGeeTestTaskProxyLess
websiteURLStringRequiredWeb address of the website using geetest (Ex: https://geetest.com)
gtStringRequiredOnly Geetest V3 is required
challengeStringRequiredOnly Geetest V3 is required
captchaIdStringOptionalonly Geetest V4 is required
geetestApiServerSubdomainStringOptionalSpecial api subdomain, example: api.geetest.com

Example Request

Example request using Geetest V3

txt
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
json
{
    "clientKey": "YOUR_API_KEY",
    "task": {
        "type":"GeetestTaskProxyless",
        "websiteURL":"https://mywebsite.com/geetest/test.php",
        "gt":"",
        "challenge":"",
        "geetestApiServerSubdomain":"api.geetest.com" // Optional
    }
}

Example Request Using Geetest V4

txt
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
json
{
    "clientKey": "YOUR_API_KEY",
    "task": {
        "type":"GeetestTaskProxyless",
        "websiteURL":"https://mywebsite.com/geetest/test.php",
        "captchaId": "..."
    }
}

Example Response

json
{
    "errorId": 0,
    "status": "idle",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}

Getting Result

Use the getTaskResult to get the result, depending on the system load, you will get the result in the interval of 3s to 10s

Example Request

json
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json

{
    "clientKey":"YOU_API_KEY",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}

Example Response

Example response using GeetestV3

json
{
  "errorId": 0,
  "solution": {
    "challenge": "",
    "validate": ""
  },
  "status": "ready"
}

Example Response Using GeetestV4

json
{
  "errorId": 0,
  "taskId": "e0ecaaa8-06f6-41fd-a02e-a0c79b957b15",
  "status": "ready",
  "solution": {
    "captcha_id": "",
    "captcha_output": "",
    "gen_time": "",
    "lot_number": "",
    "pass_token": "",
    "risk_type": "slide"
  }
}

Use SDK Request

python
# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'

import capsolver

capsolver.api_key = "..."
# v3
solution = capsolver.solve({
    "type": "GeeTestTaskProxyLess",
    "websiteURL": "http://mywebsite.com/geetest/test.php",
    "gt": "...",
    "challenge": "..."
})

# v4
solution = capsolver.solve({
    "type": "GeeTestTaskProxyLess",
    "websiteURL": "http://mywebsite.com/geetest/test.php",
    "captchaId": "..."
})
go
package main

import (
	"fmt"
	capsolver_go "github.com/capsolver/capsolver-go"
	"log"
)

func main() {
	// first you need to install sdk
	//go get github.com/capsolver/capsolver-go

	capSolver := capsolver_go.CapSolver{ApiKey: "..."}
	// v3
	solution, err := capSolver.Solve(map[string]any{
		"type":        "GeeTestTaskProxyLess",
		"websiteURL":  "https://mywebsite.com/geetest/test.php",
		"gt":          "...",
		"challenge":   "...",
	})
	if err != nil {
		log.Fatal(err)
		return
	}
	fmt.Println(solution)

	//v4
	solution, err = capSolver.Solve(
		map[string]any{
			"type":        "GeeTestTaskProxyLess",
			"websiteURL":  "https://mywebsite.com/geetest/test.php",
			"captchaId":    "...",
		})
	if err != nil {
		log.Fatal(err)GeeTestTaskProxyLess
	}
	fmt.Println(solution)
}

Sample Code

python
# pip install requests
import requests
import time

api_key = "YOUR_API_KEY"  # TODO: your api key of capsolver


def capsolver():
    payload = {
        "clientKey": api_key,
        "task": {
            "type": 'GeeTestTaskProxyLess',
            "websiteURL": "https://mywebsite.com/geetest/test.php",  # page url of your site
            "gt": "...",  # v3 is required
            "challenge":   "...",  # v3 is required
            "captchaId":   "...",  # v4 is required
        }
    }
    res = requests.post("https://api.capsolver.com/createTask", json=payload)
    resp = res.json()
    task_id = resp.get("taskId")
    if not task_id:
        print("Failed to create task:", res.text)
        return
    print(f"Got taskId: {task_id} / Getting result...")

    while True:
        time.sleep(1)  # delay
        payload = {"clientKey": api_key, "taskId": task_id}
        res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
        resp = res.json()
        status = resp.get("status")
        if status == "ready":
            return resp.get("solution")
        if status == "failed" or resp.get("errorId"):
            print("Solve failed! response:", res.text)
            return


solution = capsolver()
print(solution)
go
package main

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"time"
)

type capSolverResponse struct {
	ErrorId          int32          `json:"errorId"`
	ErrorCode        string         `json:"errorCode"`
	ErrorDescription string         `json:"errorDescription"`
	TaskId           string         `json:"taskId"`
	Status           string         `json:"status"`
	Solution         map[string]any `json:"solution"`
}

func capSolver(ctx context.Context, apiKey string, taskData map[string]any) (*capSolverResponse, error) {
	uri := "https://api.capsolver.com/createTask"
	res, err := request(ctx, uri, map[string]any{
		"clientKey": apiKey,
		"task":      taskData,
	})
	if err != nil {
		return nil, err
	}
	if res.ErrorId == 1 {
		return nil, errors.New(res.ErrorDescription)
	}

	uri = "https://api.capsolver.com/getTaskResult"
	for {
		select {
		case <-ctx.Done():
			return res, errors.New("solve timeout")
		case <-time.After(time.Second):
			break
		}
		res, err = request(ctx, uri, map[string]any{
			"clientKey": apiKey,
			"taskId":    res.TaskId,
		})
		if err != nil {
			return nil, err
		}
		if res.ErrorId == 1 {
			return nil, errors.New(res.ErrorDescription)
		}
		if res.Status == "ready" {
			return res, err
		}
	}
}

func request(ctx context.Context, uri string, payload interface{}) (*capSolverResponse, error) {
	payloadBytes, err := json.Marshal(payload)
	if err != nil {
		return nil, err
	}
	req, err := http.NewRequestWithContext(ctx, "POST", uri, bytes.NewReader(payloadBytes))
	if err != nil {
		return nil, err
	}
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	responseData, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	capResponse := &capSolverResponse{}
	err = json.Unmarshal(responseData, capResponse)
	if err != nil {
		return nil, err
	}
	return capResponse, nil
}

func main() {
	apikey := "YOUR_API_KEY"
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
	defer cancel()

	res, err := capSolver(ctx, apikey, map[string]any{
		"type":       "GeeTestTaskProxyLess",
		"websiteURL": "https://mywebsite.com/geetest/test.php",
		"gt":         "...", // v3 is required
		"challenge":  "...", // v3 is required
		"captchaId":  "...", // v4 is required
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Solution)
}
javascript
// npm install axios
const axios = require('axios');

const api_key = "YOUR_API_KEY";

async function capsolver() {
  const payload = {
    clientKey: api_key,
    task: {
      type: 'GeeTestTaskProxyLess',
      websiteURL: "https://yourwebsite.com/",  // page url of your site
      gt: "...",         // v3 is required
      challenge: "...",  // v3 is required
      captchaId: "..."  // v4 is required
    }
  };

  try {
    const res = await axios.post("https://api.capsolver.com/createTask", payload);
    const task_id = res.data.taskId;
    if (!task_id) {
      console.log("Failed to create task:", res.data);
      return;
    }
    console.log("Got taskId:", task_id);

    while (true) {
      await new Promise(resolve => setTimeout(resolve, 1000)); // Delay for 1 second

      const getResultPayload = {clientKey: api_key, taskId: task_id};
      const resp = await axios.post("https://api.capsolver.com/getTaskResult", getResultPayload);
      const status = resp.data.status;

      if (status === "ready") {
        return resp.data.solution;
      }
      if (status === "failed" || resp.data.errorId) {
        console.log("Solve failed! response:", resp.data);
        return;
      }
    }
  } catch (error) {
    console.error("Error:", error);
  }
}

capsolver().then(solution => {
  console.log(solution);
});
java
package org.example.capsolver;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class Geetest {
    public static String API_KEY = "YOUR_API_KEY";
    public static String SITE_URL = "https://mywebsite.com/geetest/test.php";
    public static String GT = "";         // v3 is required
    public static String Challenge = "";  // v3 is required
    public static String CaptchaId = "";  // v4 is required

    public static void capsolver() throws IOException, InterruptedException {
        JSONObject param = new JSONObject();
        Map<String, Object> task = new HashMap<>();
        task.put("type", "GeeTestTaskProxyLess");
        task.put("websiteURL", SITE_URL);
        task.put("gt", GT);
        task.put("challenge", Challenge);
        task.put("captchaId", CaptchaId);
        param.put("clientKey", API_KEY);
        param.put("task", task);
        String taskId = createTask(param);

        if (Objects.equals(taskId, "")) {
            System.out.println("Failed to create task");
            return;
        }
        System.out.println("Got taskId: "+taskId+" / Getting result...");
        while (true){
            Thread.sleep(1000);
            String token = getTaskResult(taskId);
            if (Objects.equals(token, null)) {
                continue;
            }
            System.out.println(token);
            break;
        }
    }

    public static String requestPost(String url, JSONObject param) throws IOException {
        URL ipapi = new URL(url);
        HttpURLConnection c = (HttpURLConnection) ipapi.openConnection();
        c.setRequestMethod("POST");
        c.setDoOutput(true);

        OutputStream os = null;
        os = c.getOutputStream();
        os.write(param.toString().getBytes("UTF-8"));

        c.connect();
        BufferedReader reader = new BufferedReader(
             new InputStreamReader(c.getInputStream())
        );
        String line;
        StringBuilder sb = new StringBuilder();
        while ((line = reader.readLine()) != null)
        { sb.append(line); }

        return sb.toString();
    }

    public static String createTask(JSONObject param) throws IOException {
        String parsedJsonStr = requestPost("https://api.capsolver.com/createTask", param);
        JSONObject responseJson = new JSONObject(parsedJsonStr);
        return responseJson.get("taskId").toString();
    }

    public static String getTaskResult(String taskId) throws IOException {
        JSONObject param = new JSONObject();
        param.put("clientKey", API_KEY);
        param.put("taskId", taskId);
        String parsedJsonStr = requestPost("https://api.capsolver.com/getTaskResult", param);
        JSONObject responseJson = new JSONObject(parsedJsonStr);

        String status = responseJson.getString("status");
        if (status.equals("ready")) {
            JSONObject solution = responseJson.getJSONObject("solution");
            return solution.toString(4);
        }
        if (status.equals("failed") || responseJson.getInt("errorId")!=0) {
            System.out.println("Solve failed! response: "+parsedJsonStr);
            return "error";
        }
        return null;
    }
}

Points to note

  1. Please do not copy directly from the browser developer Tool, GET GT and challenge on request.

  2. A small number of errors to re-obtain the verification code parameters can be retried.

  3. Verification code parameters can only be submitted to identify once, do not repeat the same parameters submitted to identify, need to re-initialize the acquisition.

  4. Note: If you can not pass the site may be coding problems, then the CAPTCHA = symbol with% 3D replacement, other no coding, please note this.

5Parameters such as the test server can be queried here in the Geetest document.