capsolver.com api wrapper🧠
now binded: 🔥 AntiTurnstile. 🔥 AntiCloudflare. 🔥 Geetest V4.
![](https://img.shields.io/badge/documentation-docs.capsolver.com-blue)
⬇️ Install
npm i capsolver-npm
✋ Usage
-
Import module.
const CapSolver = require('capsolver-npm');
-
Define tasks handler (singleton).
const handler = new CapSolver(apikey);
❗ 2 version for handle captcha tasks results are the followind:
1️⃣ task-bind methods (handle task results in one step)
example: check capsolver.com balance + run for one hcaptcha token (.hcaptchaproxyless()
):
const CapSolver = require('capsolver-npm');
const handler = new CapSolver('apikey', 1);
let b = await handler.balance();
if(b > 0){
await handler.hcaptchaproxyless('https://websiteurl.com/', '000000-000000000-0000000')
.then(async response => {
if(response.error === 0){ console.log(response.solution) }
else{ console.log('error ' + JSON.stringify(response.apiResponse)) }
});
}
2️⃣ Run any task and build taskData
schema for a task type.
Check task parameters at official docs in order to bind manually captcha tasks.
example: run for one hcaptcha token w/ custom proxy (.runAnyTask()):
const CapSolver = require("capsolver-npm");
const handler = new CapSolver("apikey");
const taskData =
{
type : "HCaptchaTask",
websiteURL : "https://website.com/",
websiteKey : "000000-00000-000000-000000000",
proxyInfo: {
"proxyType": "http",
"proxyAddress": "ip_address",
"proxyPort": 3221,
"proxyLogin": "username",
"proxyPassword": "password"
},
}
handler.runAnyTask(taskData)
.then(async response => {
if(response.error === 0){ console.log(response.solution) }
else{ console.log("error " + JSON.stringify(response.apiResponse)) }
});
↩️ Get solutions
All methods returns the following schema:
Parameter | Type | Description |
---|
error | number | [-1] Request/Solving error. [0] Success solve. |
statusText | string | HTTP status string. |
apiResponse | object | Results/solution (capsolver.com API response). |
solution | object | Solution got from success solve. |
{
error: 0,
statusText: "200 OK",
apiResponse: {
errorId: 0,
taskId: "4e6c33f5-bc14-44d0-979e-d5f37b072c59",
status: "ready",
solution: {
gRecaptchaResponse: "03AIIukzgCys9brSNnrVbwXE9mTesvkxQ-ocK ..."
}
}
}
{
error: -1,
statusText: "400 Bad Request",
apiResponse: {
errorCode: "ERROR_INVALID_TASK_DATA",
errorDescription: "clientKey error",
errorId: 1
}
}
📖 Supported captcha tasks
Method | Returns |
---|
await handler.balance() | get balance as float number |
await handler.runAnyTask(taskData) | CapSolver API response |
Custom proxy usage (proxyInfo schema):
const proxyInfo = {
"proxyType": "http",
"proxyAddress": "ip_address",
"proxyPort": 3221,
"proxyLogin": "username",
"proxyPassword": "password"
}
const proxyInfo = {
proxy: "proxyType:proxyAddress:proxyPort:proxyLogin:proxyPassword"
}
(proxyLogin & proxyPassword are optionals)
task-bin methods:
⚙️ HCaptcha
Parameter queries
: base64 images array
await handler.hcaptcha(websiteURL, websiteKey, proxyInfo, userAgent, isInvisible, enterprisePayload)
await handler.hcaptchaproxyless(websiteURL, websiteKey, userAgent, isInvisible, enterprisePayload)
await handler.hcaptchaclassification(question, base64)
⚙️ ReCaptcha
await handler.recaptchav2(websiteURL, websiteKey, proxyInfo, userAgent, isInvisible, recaptchaDataSValue, cookies)
await handler.recaptchav2proxyless(websiteURL, websiteKey, userAgent=null, isInvisible=null, recaptchaDataSValue=null, cookies=null)
await handler.recaptchav2enterprise(websiteURL, websiteKey, proxyInfo, userAgent=null, enterprisePayload=null, apiDomain=null, cookies=null)
await handler.recaptchav2enterpriseproxyless(websiteURL, websiteKey, userAgent=null, enterprisePayload=null, apiDomain=null, cookies=null)
await handler.recaptchav3(websiteURL, websiteKey, proxyInfo, pageAction, minScore=null)
await handler.recaptchav3proxyless(websiteURL, websiteKey, pageAction, minScore=null)
await handler.recaptchav3enterprise(websiteURL, websiteKey, proxyInfo, pageAction, minScore=null, enterprisePayload=null, apiDomain=null, userAgent=null, cookies=null)
await handler.recaptchav3enterpriseproxyless(websiteURL, websiteKey, pageAction, minScore=null, enterprisePayload=null, apiDomain=null, userAgent=null, cookies=null)
⚙️ Datadome
await handler.datadome(websiteURL, userAgent, captchaUrl, proxyInfo)
⚙️ FunCaptcha
Parameter image
: base64 screenshot image
await handler.funcaptcha(websiteURL, websitePublicKey, proxyInfo, funcaptchaApiJSSubdomain, userAgent, data)
await handler.funcaptchaproxyless(websiteURL, websitePublicKey, funcaptchaApiJSSubdomain, userAgent, data)
await handler.funcaptchaclassification(image, question)
⚙️ Geetest
❗ Supports for Geetest V3 & Geetest V4: Manage through GeetestTask documentation.
await handler.geetest(websiteURL, gt, challenge, proxyInfo, geetestApiServerSubdomain, captchaId)
await handler.geetestproxyless(websiteURL, gt, challenge, geetestApiServerSubdomain, captchaId)
⚙️ MTCaptcha
await handler.mtcaptcha(websiteURL, websiteKey, proxyInfo)
await handler.mtcaptchaproxyless(websiteURL, websiteKey)
⚙️ ImageToText
await handler.image2text(body)
Currently unsupported API methods:
❌ ReCaptchaV2Classification ❌ VoiceRecognition ❌ Turnstile ❌ Cloudflare Challenge
Verbose level
const handler = new CapSolver(apikey, verbose);
Verbose level undefined
or 0
: Dont print logs, just handle for solution.
Verbose level 1
: Only log task status in console.
Verbose level 2
: Log API response in console.
📁 Working examples
Figure out here all supported captcha examples.