Skip to main content
Are you experiencing issues obtaining the token?
Contact support

ImageToTextTask

This is a regular captcha, which is an image with text to be entered into the corresponding line.

Request parameters

type<string>required

ImageToTextTask


body<string>required

File body encoded in base64*. Make sure to send it without line breaks.


capMonsterModule<string>optional

The name of recognizing module, for example, “yandex“. Alternative way to pass module name and list of all available modules you can find here.
Example: yandex, special and others


recognizingThreshold<integer>optional

Captcha recognition threshold with a possible value from 0 to 100. For example, if recognizingThreshold was set to 90 and the task was solved with a confidence of 80, you won't be charged. In this case the user will get a response ERROR_CAPTCHA_UNSOLVABLE. An alternative method for setting the threshold for deducting money is described in the article.


case<boolean>optional

true - if captcha is case sensitive.


numeric<integer>optional

1 - if captcha contains numbers only.
Possible values: 0, 1


math<boolean>optional

false — undefined;
true — if captcha requires a mathematical operation (for example: captcha 2 + 6 = will return a value of 8).


*Base64 is a data encoding method that allows you to represent binary data as text. Here is an example of obtaining a captcha image in base64 format using the console in the Developer Tools:

const captchaUrl = 'https://example.com/captcha.jpg';

function loadAndEncodeCaptchaToBase64(url) {
fetch(url)
.then(response => response.blob())
.then(blob => {
const reader = new FileReader();
reader.readAsDataURL(blob);

reader.onloadend = function() {
const base64Data = reader.result;
console.log('Base64 Encoded Captcha:', base64Data);

};
})
.catch(error => {
console.error('Error occurred while loading or encoding the captcha:', error);
});
}

loadAndEncodeCaptchaToBase64(captchaUrl);

Create task method

POST
https://api.capmonster.cloud/createTask

Request

{
"clientKey":"API_KEY",
"task": {
"type":"ImageToTextTask",
"body":"BASE64_BODY_HERE!"
}
}

Response

{
"errorId":0,
"taskId":407533072
}

Get task result method

Use the getTaskResult method to get the captcha solution. Depending on the system load, you will receive an answer within an interval from 300 ms to 6 s

POST
https://api.capmonster.cloud/getTaskResult

Request

{
"clientKey":"API_KEY",
"taskId": 407533072
}

Response

{
"errorId":0,
"status":"ready",
"solution": {
"text":"answer"
}
}

PropertyTypeDescription
textStringCaptcha answer

How to Find All Required Parameters for Task Creation

Manually

  1. Open your website where the captcha appears in the browser.
  2. Right-click on the captcha element and select Inspect.

base64

Locate the required element in the DOM tree and hover over it – the base64-encoded image will be displayed directly in the element's attributes:

base64elements

If the image references an external URL rather than containing base64-encoded data, you can find it in the network requests (Network). Right-click on the relevant request and select Copy image as data URI. This will copy the base64-encoded image data to your clipboard.

base64network

Automatically

A convenient way to automate the search for all necessary parameters. Some parameters are regenerated every time the page loads, so you'll need to extract them through a browser — either regular or headless (e.g., using Playwright). Since the values of dynamic parameters are short-lived, the captcha must be solved immediately after retrieving them.

Important!

The code snippets provided are basic examples for familiarization with extracting the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements/selectors it uses.

Show code (for browser)
(async () => {
const img = document.querySelector('img'); // Example selector

const imageUrl = img.src;

const response = await fetch(imageUrl);

if (!response.ok) {
throw new Error("Failed to load image");
}

const buffer = await response.arrayBuffer();

// Convert binary data to base64
const base64Image = btoa(String.fromCharCode(...new Uint8Array(buffer)));

console.log(base64Image);
})();
Show code (Node.js)
(async () => {
const imageUrl = "https://example/img/.jpg"; // Image URL

const response = await fetch(imageUrl);

if (!response.ok) {
throw new Error("Failed to load image");
}

const buffer = await response.arrayBuffer();

// Convert data to base64
const base64Image = Buffer.from(buffer).toString("base64");

console.log(base64Image);
})();

Use SDK Library

// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, ImageToTextRequest } from '@zennolab_com/capmonstercloud-client';

document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' }));
console.log(await cmcClient.getBalance());

const imageToTextRequest = new ImageToTextRequest({
body: 'some base64 body',
CapMonsterModule: CapMonsterModules.YandexWave,
Case: true,
numeric: 1,
recognizingThreshold: 65,
math: false,
});

console.log(await cmcClient.Solve(imageToTextRequest));
});