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

Alibaba Cloud Captcha

Task examples

Below are examples of Alibaba Captcha task types that are currently supported by the CapMonster Cloud service:

Puzzle
Image restoration
Click
Slider
Checkbox
Attention!

CapMonster Cloud uses built-in proxies by default — their cost is already included in the service. You only need to specify your own proxies in cases where the website does not accept the token or access to the built-in services is restricted.

If you are using a proxy with IP authorization, make sure to whitelist the address 65.21.190.34.

Request parameters

type<string>required

CustomTask


class<string>required

alibaba


websiteURL<string>required

Full URL of the page with the CAPTCHA.


sceneId (inside metadata)<string>required

The captcha scenario identifier, passed in the following format: "sceneId":"1ww7426c"the value is provided as an example.
Use your own value. Instructions for obtaining it are provided in the corresponding section.


prefix (inside metadata)<string>required

CAPTCHA initialization parameter, passed in the URL of the request used to load the task text on the page.
For example, if the URL looks like: https://dlw3kug.captcha-open.example.aliyuncs.com/, then the value of the prefix parameter corresponds to the subdomain — dlw3kug.


Some websites require additional parameters:

Specify these parameters only if they are present on the website (see more details in the section Working with websites that include extended parameters).

userId (inside metadata)<string>optional

A unique identifier of the user or session on the website side.
Example: HpadJlQnz2zSKcSmjXBaqQvjYUvP4jMJIk/ZwGNDNiM=


userUserId (inside metadata)<string>optional

An additional (secondary) user identifier.
Example: /uSXKkVFuuwxXA21/MpXGxpLStWBEup1B3jjlMUWwNE=


verifyType (inside metadata)<string>optional

The version or type of the CAPTCHA verification mechanism.
Example: 1.0


region (inside metadata)<string>optional

The server or data center region through which the CAPTCHA is processed.
Example: sgp


UserCertifyId (inside metadata)<string>optional

A unique verification ID associated with the current CAPTCHA session.
Example: 0a03e59417757735511105780e2a5e


apiGetLib (inside metadata)<string>optional

A link to the CAPTCHA JS library used by the website. The value is generated on the client side and may change dynamically on each page render.
Example: https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041


punishUrl (inside metadata)<string>optional

Full URL of the verification page obtained from the target website.

Use this parameter for websites where Alibaba returns a separate /punish URL for verification. Pass the full URL, including its query parameters.

Example: https://example.com:443//api/example/testlogin/_____tmd_____/punish?x5secdata=xgf6888e6c4d5d8115ka6bba95967ab87aa13767f97ccadf409d1782833032a-388365139a1244837524abakc3dafclick33ba7696f04104647438bcba5be532d2833__bx__example.com:443/api/example/testlogin/&x5step=2&action=captchaclick&pureCaptcha=

For instructions on obtaining the URL, see How to find all required parameters for task creationpunishUrl.


cookieRequired (inside metadata)<boolean>optional

Returns cookies together with the CAPTCHA solution.

Use true only for websites that use Alibaba WAF or Amazon WAF and require cookies after successful verification.

By default, this parameter is not used.


userAgent<string>optional

Browser User-Agent. Use the current value supported by CapMonster Cloud: userAgentPlaceholder

You can get the latest value at: https://capmonster.cloud/api/useragent/actual.


proxyType<string>optional

http - standard http/https proxy;
https - try this if "http" doesn't work (needed for some custom proxies);
socks4 - socks4 proxy;
socks5 - socks5 proxy.


proxyAddress<string>optional

IP address of the proxy (IPv4/IPv6). Not allowed:

  • using transparent proxies (those exposing the client IP);
  • using local machine proxies.


proxyPort<integer>optional

Proxy port.


proxyLogin<string>optional

Proxy login.


proxyPassword<string>optional

Proxy password.


Create task method

Standard variant (without additional parameters)

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

Request example

{
"clientKey": "API_KEY",
"task": {
"type": "CustomTask",
"class": "alibaba",
"websiteURL": "https://www.example.com",
"userAgent": "userAgentPlaceholder",
"metadata": {
"sceneId": "your-scene-id",
"prefix": "your-prefix"
}
}
}

Response example

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

Option with extended parameters (userId, userUserId, verifyType, etc.):

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

Request example

{
"clientKey": "API_KEY",
"task": {
"type": "CustomTask",
"class": "alibaba",
"websiteURL": "https://www.example.com",
"userAgent": "userAgentPlaceholder",
"metadata": {
"sceneId": "your-scene-id",
"prefix": "your-prefix",
"userId": "your-user-id",
"userUserId": "your-user-user-id",
"verifyType": "your-verify-type",
"region": "your-region",
"UserCertifyId": "your-user-certify-id",
"apiGetLib": "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041"
}
}
}

Response example

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

Option with punishUrl

On some websites protected by Alibaba, verification is triggered through a separate /punish URL. In this case, pass the obtained URL in the punishUrl parameter (inside metadata).

Alibaba Punish may use verification methods such as selecting matching images or a slider.

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

Request example

{
"clientKey": "API_KEY",
"task": {
"type": "CustomTask",
"class": "alibaba",
"websiteURL": "https://www.example.com",
"userAgent": "userAgentPlaceholder",
"metadata": {
"punishUrl": "https://example.com/_____tmd_____/punish?x5secdata=your-x5secdata&x5step=2"
}
}
}

Response example

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

For some websites using Alibaba WAF or Amazon WAF, cookies must be obtained after the CAPTCHA is successfully solved. These cookies are then used in subsequent requests.

To enable this, add the following parameter to the metadata object:

{
"cookieRequired": true
}
POST
https://api.capmonster.cloud/createTask

Request example

{
"clientKey": "API_KEY",
"task": {
"type": "CustomTask",
"class": "alibaba",
"websiteURL": "https://example.com",
"userAgent": "userAgentPlaceholder",
"metadata": {
"prefix": "your-prefix",
"sceneId": "your-scene-id",
"userId": "your-user-id",
"userUserId": "your-user-user-id",
"verifyType": "1.0",
"region": "sgp",
"UserCertifyId": "your-user-certify-id",
"apiGetLib": "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041",
"cookieRequired": true
}
}
}

Response example

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

Get task result method

Use the getTaskResult method to obtain the Alibaba CAPTCHA solution.

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

Request example

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

Response example

{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"status": "ready",
"solution": {
"data": {
"tokens": "{\"sceneId\":\"1ww7426c4\",\"certifyId\":\"kBjCxX2W2c\",\"deviceToken\":\"U0dfV0VCIzM3...wOGJkMjY=\",\"data\":\"JRMnX3B...EUQdCpLkqSj7THYNf3dn\"}"
}
}
}

If "cookieRequired": true was specified in the request, the response additionally contains cookies grouped by domain. This also applies to tasks with punishUrl. Use cookies from the solution.domains object in subsequent requests to the corresponding domain together with the CAPTCHA solution.

Response example

{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"status": "ready",
"solution": {
"domains": {
"example.com": {
"cookies": {
"arms_uid": "23906d34-14da-4ddb-b651-b4d72d5376e1",
"sca": "ec12103d",
"atpsida": "b8cd8cc0185b...1196_1",
"cna": "vJsNIxNBKGMCAax0zMDiXVu1",
"cbc": "T2gAde24vOm4...wkkwYA=",
"x5sec": "7b2274223a...227d",
"tfstk": "gPEnRZi0vyuB...ECvCA."
}
}
}
}
}

How to find all required parameters for task creation

sceneId

sceneId can be obtained after successfully solving the CAPTCHA once:

  1. Solve the CAPTCHA manually on the website.
  2. Open DevToolsNetwork tab.
  3. Find the request sent after successful verification (for example: verify, check, validate).
  4. In Payload or Response, locate the sceneId (CaptchaSceneId or sId) parameter.

This parameter can also be found using search across network requests:

  1. Open the page with the CAPTCHA, then go to DevToolsNetwork tab.
  2. Search (Ctrl + F) for sceneId or CaptchaSceneId.


prefix

prefix can be obtained from the request URL used on the website to load the CAPTCHA task text:

  1. Open the page with the CAPTCHA.
  2. Find the request related to loading the task (usually via DevToolsNetwork).



punishUrl

punishUrl is the Alibaba verification URL returned when protection is triggered on the target website.

You can usually obtain this URL from a network request whose response contains the following error:

FAIL_SYS_USER_VALIDATE

Obtaining it through DevTools

  1. Open the target page and perform the action that triggers Alibaba verification.
  2. Open DevToolsNetwork.
  3. Find the request sent when the protection is triggered. You can use the response containing the FAIL_SYS_USER_VALIDATE error as a reference.
  4. Open the request and go to the Preview tab. In the response, find the data field — it contains the verification URL to use as punishUrl.


  1. You can also find the target URL in the Response tab.


  1. Copy the full URL and pass it in the punishUrl parameter (inside metadata) when creating the task.

The resulting URL must contain the port (for example, 443), the _____tmd_____/punish path, and the x5secdata, x5step, action, and pureCaptcha parameters.

URL format:

https://example.com:443//api/example/testlogin/_____tmd_____/punish?x5secdata=xgf6888e6c4d5d8115ka6bba95967ab87aa13767f97ccadf409d1782833032a-388365139a1244837524abakc3dafclick33ba7696f04104647438bcba5be532d2833__bx__example.com:443/api/example/testlogin/&x5step=2&action=captchaclick&pureCaptcha=

Automatic retrieval of punishUrl

You can also obtain punishUrl programmatically in one of the following ways:

  • via HTTP requests — if the API URL, method, headers, and other request parameters are known;
  • via Playwright — if you need to track the request directly in the browser.

In some cases, an intermediate URL containing x5secdata and x5step is returned first, and after it is processed, the final punishUrl with the action and pureCaptcha parameters is returned.

For HTTP requests, use the parameters of the actual request made by the target website. In the browser scenario, specify the required page and perform the action that triggers Alibaba Punish.

Important

The examples demonstrate the general approach to obtaining punishUrl. Replace URLs, headers, and other values with the current data from the target website.

Show code (via HTTP requests)
const USER_AGENT =
"userAgentPlaceholder";

const TIMEOUT = 30000;

/* ================= REQUEST SETTINGS ================= */
// All values below are provided as examples
// Specify the parameters of the actual request made by the target website
// Add additional headers such as origin, referer, and accept-language if needed

const REQUEST_CONFIG = {
pageUrl: "https://example.com/login",

url: "https://api.example.com/login?fromSite=example&appName=example-app",

method: "POST",

// Request query parameters, for example: login, email,
// phone number, or other values
params: {
value: "example"
},

headers: {
accept: "application/json, text/plain, */*",
"content-type": "application/json",
"user-agent": USER_AGENT,
origin: "https://example.com",
referer: "https://example.com/login",
},
};

/* ================= GENERAL LOGIC ================= */

function isPunishUrl(url) {
return typeof url === "string" && url.includes("_____tmd_____/punish");
}

function hasParam(url, name) {
try {
return new URL(url).searchParams.has(name);
} catch {
return false;
}
}

function isFinalPunishUrl(url) {
return (
isPunishUrl(url) &&
["x5secdata", "x5step", "action", "pureCaptcha"].every((name) =>
hasParam(url, name),
)
);
}

function cookiesToHeader(cookies = {}) {
return Object.entries(cookies)
.map(([name, value]) => `${name}=${value}`)
.join("; ");
}

function extractFromHtml(html, baseUrl) {
const match = html.match(
/(?:["']url["']\s*:\s*["']([^"']+)["'])|(https?:\/\/[^\s"'<>]+\/_____tmd_____\/punish\?[^\s"'<>]+)/i,
);

if (!match) {
return null;
}

const value = (match[1] || match[2])
.replace(/\\\//g, "/")
.replace(/&amp;/g, "&")
.replace(/&#x3D;|&#61;/gi, "=");

try {
const url = new URL(value, baseUrl).href;
return isPunishUrl(url) ? url : null;
} catch {
return null;
}
}

async function extractPunishUrl(response) {
const text = await response.text();

try {
const url = JSON.parse(text)?.data?.url;

if (isPunishUrl(url)) {
return url;
}
} catch {}

return extractFromHtml(text, response.url);
}

async function sendRequest(config) {
const url = new URL(config.url);

for (const [name, value] of Object.entries(config.params || {})) {
if (value != null) {
url.searchParams.set(name, value);
}
}

const headers = {
...(config.headers || {}),
};

const cookie = cookiesToHeader(config.cookies);

if (cookie) {
headers.cookie = cookie;
}

const method = (config.method || "GET").toUpperCase();

const options = {
method,
headers,
signal: AbortSignal.timeout(TIMEOUT),
};

if (method !== "GET" && method !== "HEAD") {
if (config.json != null) {
options.body = JSON.stringify(config.json);
} else if (config.data != null) {
options.body = config.data;
}
}

const response = await fetch(url, options);

if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`);
}

return response;
}

async function resolvePunishUrl(response, config, maxSteps = 3) {
const visited = new Set();

for (let step = 0; step < maxSteps; step++) {
const punishUrl = await extractPunishUrl(response);

if (!punishUrl) {
throw new Error("punishUrl was not found in the response");
}

if (visited.has(punishUrl)) {
throw new Error("A repeated punishUrl was detected");
}

visited.add(punishUrl);

if (isFinalPunishUrl(punishUrl)) {
return punishUrl;
}

const headers = {
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent": USER_AGENT,
referer: config.pageUrl,
};

const cookie = cookiesToHeader(config.cookies);

if (cookie) {
headers.cookie = cookie;
}

response = await fetch(punishUrl, {
headers,
signal: AbortSignal.timeout(TIMEOUT),
});

if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`);
}
}

throw new Error("Failed to obtain the final punishUrl");
}

async function main() {
try {
const response = await sendRequest(REQUEST_CONFIG);

const punishUrl = await resolvePunishUrl(response, REQUEST_CONFIG);

console.log("Final punishUrl:");
console.log(punishUrl);
} catch (error) {
console.error("Failed to obtain punishUrl:");
console.error(error.message);
}
}

main();
Show code (via Playwright)
const { chromium } = require("playwright");

// Page where Alibaba Punish is used
const PAGE_URL = "https://example.com/";

const TIMEOUT = 180000;

function isPunishUrl(url) {
return (
typeof url === "string" &&
url.includes("_____tmd_____/punish")
);
}

function hasParam(url, name) {
try {
return new URL(url).searchParams.has(name);
} catch {
return false;
}
}

function isFinalPunishUrl(url) {
return (
isPunishUrl(url) &&
hasParam(url, "x5secdata") &&
hasParam(url, "x5step") &&
hasParam(url, "action") &&
hasParam(url, "pureCaptcha")
);
}

function addHttpsPort(url) {
if (
typeof url !== "string" ||
!url.startsWith("https://")
) {
return url;
}

if (/^https:\/\/[^/]+:\d+(?:\/|$)/i.test(url)) {
return url;
}

return url.replace(
/^https:\/\/([^/]+)/i,
"https://$1:443"
);
}

function waitForPunishUrl(page) {
return new Promise((resolve, reject) => {
let finalPunishUrl = null;

const timer = setTimeout(() => {
cleanup();

reject(
new Error(
"Final punishUrl was not found"
)
);
}, TIMEOUT);

function cleanup() {
clearTimeout(timer);

page.off("request", onRequest);
page.off("response", onResponse);
}

function processUrl(url) {
if (
finalPunishUrl ||
!isFinalPunishUrl(url)
) {
return;
}

finalPunishUrl =
addHttpsPort(url);

cleanup();
resolve(finalPunishUrl);
}

function onRequest(request) {
processUrl(
request.url()
);
}

function onResponse(response) {
processUrl(
response.url()
);
}

page.on("request", onRequest);
page.on("response", onResponse);
});
}

async function main() {
const browser = await chromium.launch({
headless: false,
});

const context =
await browser.newContext();

const page =
await context.newPage();

const punishUrlPromise =
waitForPunishUrl(page);

await page.goto(
PAGE_URL,
{
waitUntil: "domcontentloaded",
}
);

console.log(
"Perform the action on the page that triggers Alibaba verification"
);

try {
const punishUrl =
await punishUrlPromise;

console.log(
"Final punishUrl:"
);

console.log(punishUrl);
} catch (error) {
console.error(
"Failed to obtain punishUrl:"
);

console.error(
error.message
);
}

await browser.close();
}

main().catch(console.error);

Working with websites that include extended parameters

Extracting and preparing captcha parameters

This section describes the general process of extracting required parameters, solving the captcha, and re-submitting the authentication request on the target website.

  1. Initial authentication request:
POST https://example.com/api/v2/auths/signin

User credentials are sent:

{
"email": "[email protected]",
"password": "hashed_password"
}

Examples of headers are provided in the section Examples of automatic captcha solving.

  1. Server response detection. The server may return two types of responses:
  • 2.1 Standard JSON (no captcha required):
{
"success": false,
"data": {
"code": "Bad_Request",
"details": "The email or password provided is incorrect..."
}
}

This means that no captcha is required and the request is processed normally.

  • 2.2 Captcha response (the server returns an HTML page instead of JSON):
<!doctype html>
<meta charset="UTF-8">
<meta name="aliyun_waf_aa" content="...">
<meta name="aliyun_waf_bb" content="...">
...
  1. Inside the page there is an object with the following data:
var requestInfo = {
data,
region,
sceneId,
token,
traceid,
type,
userId,
userUserId
}

From this object, extract the following parameters used for captcha solving:

  • userId
  • userUserId
  • verifyType (corresponds to type)
  • region
  • UserCertifyId (corresponds to traceid)

Important: additionally, you must store the authentication values token and traceid. They are used in subsequent authentication requests as u_atoken and u_asig respectively.


  1. Example of generating the captcha JS library URL:
this.currentDate = new Date()

this.AliyunGeneratedDynamicJS =
`https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=${
this.currentDate.getFullYear() +
(this.currentDate.getMonth() + 1) +
this.currentDate.getDate() +
this.currentDate.getHours()
}`
  1. Building metadata and the captcha solving request.

These data are sent to our captcha solving service:

Important: all values shown are provided for example purposes only. Replace them with the actual values for your project before use.

{
"metadata": {
"sceneId": "1ww7426c4",
"prefix": "dlw3kug",
"userId": "HpadJlQnz2zSKcSmjXBaqQvjYUvP4jMJIk/ZwGNDNiM=",
"userUserId": "/uSXKkVFuuwxXA21/MpXGxpLStWBEup1B3jjlMUWwNE=",
"verifyType": "1.0",
"region": "sgp",
"UserCertifyId": "0a03e59417757735511105780e2a5e",
"apiGetLib": "https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=2041"
}
}
  1. Captcha solution retrieval and re-sending the authentication request using previously saved u_atoken and u_asig parameters:
POST https://example.com/api/v2/auths/signin?u_atoken=...&u_asig=...&u_aref=undefined

If the captcha is solved successfully, the server returns the authentication result (see step 2.1).

Examples of automatic captcha solving

Important

The examples are for demonstration purposes only and illustrate the general logic of working with your website using Alibaba Cloud Captcha protection. In real-world projects, the code may require adaptation depending on the specific website, its requests, and headers.

Important data (API keys, proxy settings, etc.) should be stored in .env files or environment variables.

Show code (Node.js)
import "dotenv/config";
import fs from "fs";

import { gotScraping } from "got-scraping";

function parse(text, start, end, isJson = true) {
const startIndex = text.indexOf(start);
if (startIndex === -1) return null;

const contentStart = startIndex + start.length;
const endIndex = text.indexOf(end, contentStart);
if (endIndex === -1) return null;

let extracted = text.substring(contentStart, endIndex).trim();

extracted = extracted.replace(/\n/g, "").trim();

let jsonStr = extracted
.replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2":')
.replace(/'/g, '"');

try {
return isJson ? JSON.parse(jsonStr) : jsonStr;
} catch (err) {
console.error("Failed to parse JSON:", err.message);
console.error("Parse attempt:", jsonStr);
return null;
}
}

function buildProxyLine(proxyUrl) {
if (!proxyUrl) return undefined;

const parts = proxyUrl.split(":");

// Handling format protocol:ip:port (3 parts)
if (parts.length === 3) {
const [protocol, ip, port] = parts;
return { proxyLine: `${protocol}://${ip}:${port}`, protocol, ip, port };
}

// Handling format protocol:username:password:ip:port (5 parts)
if (parts.length === 5) {
const [protocol, username, password, ip, port] = parts;
return {
proxyLine: `${protocol}://${username}:${password}@${ip}:${port}`,
protocol,
ip,
port,
username,
password,
};
}

// Invalid format
return undefined;
}

const proxyUrl =
process.env.proxyUrl || "http:username:password:127.0.0.1:9029"; // Replace with your proxy or set in .env file
const proxyLine = buildProxyLine(proxyUrl);
const delay = (ms) => new Promise((res) => setTimeout(res, ms));

class Worker {
constructor() {
this.providerVendorSolverUrl = "https://api.capmonster.cloud";
this.API_KEY = process.env.apiKey || "YOUR_API_KEY"; // Replace with your CapMonster Cloud API key

this.currentDate = new Date();
// Dynamic captcha JS library URL generation
`https://o.example.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js?t=${
this.currentDate.getFullYear() +
(this.currentDate.getMonth() + 1) +
this.currentDate.getDate() +
this.currentDate.getHours()
}`;

this.websiteUrl = "https://example.com/auth"; // Replace with captcha page URL
this.userAgent =
"userAgentPlaceholder";
}

async executor() {
console.log(`Fetching captcha parameters....`);
const RequireAuthorizationResponses =
await this.getAuthorizationResponses();
console.log("Captcha pages successfully received");
const requireParamsCaptchas = await this.requireParamsCaptchasData(
RequireAuthorizationResponses,
);
console.log(`Captcha parameters: `, requireParamsCaptchas);
const AlibabaSolvedResult = await this.requireAlibabaSolverResponse(
requireParamsCaptchas,
);
console.log(
`Captcha solving result: `,
AlibabaSolvedResult?.solution?.data?.tokens,
);
const RequireAuthorizationResponsesAfterCaptchaBypass =
await this.sendAuthrozationsRequest();
console.log(RequireAuthorizationResponsesAfterCaptchaBypass);
}

async sendAuthrozationsRequest() {
const response = await gotScraping.post(
`https://example.com/api/v2/auths/signin?u_atoken=${this.AuthorizationParams.u_atoken}&u_asig=${this.AuthorizationParams.u_asig}&u_aref=undefined`,
{
body: JSON.stringify({
password:
"e2577eeb61dc2197dfe94816d731f2941ccd0b66de8dc97aacb377bfe8476970",
}),
headers: {
Accept: "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
Origin: "https://example.com",
Pragma: "no-cache",
Referer: "https://example.com/auth",
Timezone: "Thu Apr 09 2026 23:29:23 GMT+0300",
"User-Agent":
"userAgentPlaceholder",
Version: "0.2.36",
"X-Request-Id": "2b4a7a52-d273-4049-a826-156aae856fe5",
"bx-v": "2.5.36",
"sec-ch-ua":
'"Chromium";v="150", "Not-A.Brand";v="24", "Google Chrome";v="150"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
source: "web",
},
},
);

return response.body;
}

async getAuthorizationResponses() {
const response = await gotScraping.post(
`https://example.com/api/v2/auths/signin`, // Replace with actual auth URL that triggers captcha
{
body: JSON.stringify({
password:
"e2577eeb61dc2197dfe94816d731f2941ccd0b66de8dc97aacb377bfe8476970",
}),
headers: {
Accept: "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Content-Type": "application/json",
Origin: "https://example.com", // Replace with actual Origin
Pragma: "no-cache",
Referer: "https://example.com/auth", // Replace with actual Referer
Timezone: "Thu Apr 09 2026 23:29:23 GMT+0300",
"User-Agent":
"userAgentPlaceholder",
Version: "0.2.36",
"X-Request-Id": "2b4a7a52-d273-4049-a826-156aae856fe5",
"bx-v": "2.5.36",
"sec-ch-ua":
'"Chromium";v="150", "Not-A.Brand";v="24", "Google Chrome";v="150"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
source: "web",
},
},
);

if (response.body.includes("requestInfo")) {
console.log("Captcha response received successfully:");
fs.writeFileSync("./baseResponse.txt", response.body);
console.log(response.body.substring(0, 150));
return response.body;
}

console.log(response.body);
return await this.getAuthorizationResponses();
}

async requireAlibabaSolverResponse(captchaMetadataParams) {
let cmReqData = {
type: "CustomTask",
class: "alibaba",
websiteURL: this.websiteUrl,
websiteKey: "customTask",
userAgent: this.userAgent,
};

if (captchaMetadataParams) {
cmReqData.metadata = captchaMetadataParams;
}

const response = await gotScraping.post(
`${this.providerVendorSolverUrl}/createTask`,
{
body: JSON.stringify({ clientKey: this.API_KEY, task: cmReqData }),
headers: {
"Content-Type": "application/json",
},
},
);

let JSON_responseData = JSON.parse(response.body);
if (JSON_responseData.errorId) throw new Error("JSON.TaskId.error");

let taskId = JSON_responseData.taskId;
let responseData;

while (true) {
let cmTaskRes = { clientKey: this.API_KEY, taskId: taskId };

let task_response = await gotScraping.post(
`${this.providerVendorSolverUrl}/getTaskResult`,
{
body: JSON.stringify(cmTaskRes),
headers: {
"Content-Type": "application/json",
},
},
);

let JSON_responseDataTaskResponse = JSON.parse(task_response.body);

if (JSON_responseDataTaskResponse.status !== "processing") {
responseData = JSON_responseDataTaskResponse;
break;
}

await delay(5000);
}

return responseData;
}

async requireParamsCaptchasData(responsesCaptchaPage) {
const JsonData = parse(
responsesCaptchaPage,
':none">var requestInfo = ',
";",
true,
);

// Save authorization parameters for later use in retry login request
this.AuthorizationParams = {
u_atoken: JsonData.token,
u_asig: JsonData.traceid,
};

return {
prefix: "57d98d02303c01e7d2f7814c75224396",
sceneId: JsonData.sceneId,
userId: JsonData.userId,
userUserId: JsonData.userUserId,
verifyType: "1.0",
region: JsonData.region,
UserCertifyId: JsonData.traceid,
apiGetLib: this.AliyunGeneratedDynamicJS,
};
}
}

new Worker().executor();

Use the SDK library

Show code (for browser)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver

import {
CapMonsterCloudClientFactory,
ClientOptions,
AlibabaRequest
} from "@zennolab_com/capmonstercloud-client";

document.addEventListener("DOMContentLoaded", async () => {

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let alibabaRequest = new AlibabaRequest({
websiteURL: "https://yourwebsite.com/page-with-alibaba",
userAgent: "userAgentPlaceholder",
metadata: {
sceneId: "your-scene-id",
prefix: "your-prefix",
},
});

// Example using your proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};

alibabaRequest = new AlibabaRequest({
websiteURL: "https://yourwebsite.com/page-with-alibaba",
userAgent: "userAgentPlaceholder",
metadata: {
sceneId: "your-scene-id",
prefix: "your-prefix",
},
proxy,
});
*/

// You can check your balance if necessary
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(alibabaRequest);
console.log("Solution:", result.solution);
});
Show code (Node.js)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver

const {
CapMonsterCloudClientFactory,
ClientOptions,
AlibabaRequest,
} = require("@zennolab_com/capmonstercloud-client");

const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key

async function solveAlibaba() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY }),
);

// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let alibabaRequest = new AlibabaRequest({
websiteURL: "https://yourwebsite.com/page-with-alibaba",
userAgent: "userAgentPlaceholder",
metadata: {
sceneId: "your-scene-id",
prefix: "your-prefix",
},
});

// Example using your proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};

alibabaRequest = new AlibabaRequest({
websiteURL: "https://yourwebsite.com/page-with-alibaba",
userAgent: "userAgentPlaceholder",
metadata: {
sceneId: "your-scene-id",
prefix: "your-prefix",
},
proxy,
});
*/

// You can check your balance if necessary
const balance = await client.getBalance();
console.log("Balance:", balance);

const result = await client.Solve(alibabaRequest);
console.log("Solution:", result.solution);
}

solveAlibaba().catch(console.error);