Logo of «GitHub»

Coordinates Method

Coordinates

The method can be used to bypass tasks where you need to click on some points of an image.

The method can be also used for cases when you need to calculate a distance between points. For example, to bypass custom slider captchas you can instruct our worker to click on a particular point of the image using comment and imgInstructions parameters and then use the point coordinates to calculate the distance between the slider start and end points and move the slider.

Supported image formats: JPEG, PNG, GIF
Max file size: 600 kB
Max image size: 1000px on any side

CoordinatesTask task type specification

Property Type Required Description
type String Yes Task type: CoordinatesTask
body String Yes Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported
comment String No A comment will be shown to workers to help them to solve the captcha properly
imgInstructions String No An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. Max file size: 100 kB
minClicks Integer No The minimum number of clicks to perform on the image. Default: 1
maxClicks Integer No The maximum number of clicks that can be performed on the image

Request example

Method: createTask
API endpoint: https://api.2captcha.com/createTask

{
    "clientKey":"YOUR_API_KEY",
    "task": {
        "type":"CoordinatesTask",
        "body":"/9j/4AAQSkZJRgABAQAAAQ..HIAAAAAAQwAABtbnRyUkdCIFhZ.wc5GOGSRF//Z",
        "comment":"click on the green apple"
    }
}

Response example

Method: getTaskResult
API endpoint: https://api.2captcha.com/getTaskResult

{
    "errorId": 0,
    "status": "ready",
    "solution": {
        "coordinates": [
            {
                "x": 358,
                "y": 268
            }
        ]
    },
    "cost": "0.0012",
    "ip": "1.2.3.4",
    "createTime": 1692863536,
    "endTime": 1692863556,
    "solveCount": 1
}

Code examples

  // https://github.com/2captcha/2captcha-php

  require(__DIR__ . '/../src/autoloader.php');

  $solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');

  try {
      $result = $solver->coordinates('path/to/captcha.jpg');
  } catch (\Exception $e) {
      die($e->getMessage());
  }

  die('Captcha solved: ' . $result->code);
# https://github.com/2captcha/2captcha-python

import sys
import os

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

from twocaptcha import TwoCaptcha

api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')

solver = TwoCaptcha(api_key)

try:
  result = solver.coordinates('path/to/captcha.jpg')

except Exception as e:
  sys.exit(e)

else:
  sys.exit('solved: ' + str(result))
  // https://github.com/2captcha/2captcha-csharp

  using System;
  using System.Linq;
  using TwoCaptcha.Captcha;

  namespace TwoCaptcha.Examples
  {
      public class CoordinatesExample
      {
          public static void Main()
          {
              var solver = new TwoCaptcha("YOUR_API_KEY");
              Coordinates captcha = new Coordinates("path/to/captcha.jpg");
              try
              {
                  solver.Solve(captcha).Wait();
                  Console.WriteLine("Captcha solved: " + captcha.Code);
              }
              catch (AggregateException e)
              {
                  Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
              }
          }
      }
  }
  // https://github.com/2captcha/2captcha-java

  package examples;

  import com.twocaptcha.TwoCaptcha;
  import com.twocaptcha.captcha.Coordinates;

  public class CoordinatesExample {
      public static void main(String[] args) {
          TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
          Coordinates captcha = new Coordinates("path/to/captcha.jpg");
          try {
              solver.solve(captcha);
              System.out.println("Captcha solved: " + captcha.getCode());
          } catch (Exception e) {
              System.out.println("Error occurred: " + e.getMessage());
          }
      }

  }
  // https://github.com/2captcha/2captcha-go

  package main

  import (
      "fmt"
      "log"
      "github.com/2captcha/2captcha-go"
  )

  func main() {
      client := api2captcha.NewClient("API_KEY")
      captcha := api2captcha.Coordinates{
          File: "/path/to/captcha.jpg",
      }
      code, err := client.Solve(captcha.ToRequest())
      if err != nil {
          log.Fatal(err);
      }
      fmt.Println("code "+code)
  }
  require 'api_2captcha'

  client =  Api2Captcha.new("YOUR_API_KEY")

  result = client.coordinates({ image: 'path/to/captcha.jpg'})
  # OR
  result = client.coordinates({
  image: 'https://site-with-captcha.com/path/to/captcha.jpg'
  })