captchaai.io api wrapper🧠 (tasks handler)
Want you to get captcha verified tokens calling one function within your NodeJS application?
Run with this repo and find a fast way to perform web/api automations.
now binded: 🔥 AntiKasada & AntiAkamaiBMP. 🔥 HCaptcha & FunCaptcha Images Classification.
⬇️ Install
npm i captchaai-npm
✋ Usage
-
Import module.
const Captchaai = require('captchaai-npm');
-
Declare singleton/handler.
const handler = new Captchaai(apikey);
❗ There are 2 different versions in order to handle task results:
1️⃣ fast-bind methods
example: check captchaai.io balance + run for one .hcaptchaproxyless()
const Captchaai = require('captchaai-npm');
const handler = new Captchaai('apikey', 1);
let b = await handler.balance();
if(b > 0){
await handler.hcaptchaproxyless('https://websiteurl.com/', '000000-000000000-0000000')
.then(async r => {
if(r.error === 0)
console.log('got token!\n' + JSON.stringify(r.apiResponse));
});
}
example: run HCaptchaTask with .hcaptcha()
w/custom proxy server.
const Captchaai = require('captchaai-npm');
const handler = new Captchaai('apikey', 1);
let b = await handler.balance();
if(b > 0){
await handler.hcaptcha(
'https://websiteurl.com/',
'000000-000000000-0000000',
{ proxy: "proxyType:proxyAddress:proxyPort:proxyLogin:proxyPassword" }
)
.then(async r => {
if(r.error === 0)
console.log('got token!\n' + JSON.stringify(r.apiResponse));
});
}
2️⃣ Run any task. Build taskData
schema for a task type.
example: build custom proxy taskData
schema for HCaptchaTask.
const Captchaai = require('captchaai-npm');
const handler = new Captchaai('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(response => { console.log(response); });
↩️ Returned object
All methods return the following schema.
Parameter | Type | Description |
---|
error | number | [-1] request/solving error. [0] success solving. |
statusText | string | http status string |
apiResponse | object | results/solution (captchaai.io API response). |
{
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
}
}
- Each method it's an easy way to launch and handle multiple requests to captchaai API.
- Some determinated captchas task have required arguments which mostly are of type string or type object. Anycase, this is described in captchaai.io official docs page.
- reffered docs.
⚙️Supported API methods
Method | Returns |
---|
await handler.balance() | directly the float value or an error object |
await handler.getBalance() | succes or error object |
await handler.runAnyTask(taskData) | handle task results for a taskData schema passed. In order to build this object, use !reffered docs and check parameters by catpcha task type. |
taskData
schema it's shown in examples.proxyInfo
schema has 2 versions:
{ 'proxy' : 'proxyType:proxyAddress:proxyPort:proxyLogin:proxyPassword' }
or
{ 'proxyType': 'http', 'proxyAddress': 'ip_address', 'proxyPort': 3221, 'proxyLogin': 'username', 'proxyPassword': 'password' }
(proxyLogin & proxyPassword are optionals)
task-bind methods
retrieve solutions (tokens/coordenates) with the followings:
await handler.image2text(body)
await handler.antikasada(pageURL, proxyInfo, onlyCD, userAgent)
await handler.antiakamaibmp(packageName, version, deviceId, deviceName, count)
await handler.hcaptcha(websiteURL, websiteKey, proxyInfo, userAgent, isInvisible, enterprisePayload)
await handler.hcaptchaproxyless(websiteURL, websiteKey, userAgent, isInvisible, enterprisePayload)
await handler.hcaptchaclassification(question, queries, coordinate)
await handler.recaptchav2(websiteURL, websiteKey, proxyInfo, userAgent, isInvisible, recaptchaDataSValue, cookies)
await handler.recaptchav2proxyless(websiteURL, websiteKey, userAgent, isInvisible, recaptchaDataSValue, cookies)
await handler.recaptchav2enterprise(websiteURL, websiteKey, proxyInfo, userAgent, enterprisePayload, apiDomain, cookies)
await handler.recaptchav2enterpriseproxyless(websiteURL, websiteKey, userAgent, enterprisePayload, apiDomain, cookies)
await handler.recaptchav3(websiteURL, websiteKey, proxyInfo, pageAction, minScore)
await handler.recaptchav3proxyless(websiteURL, websiteKey, pageAction, minScore)
await handler.datadome(websiteURL, userAgent, captchaUrl, proxyInfo)
await handler.funcaptcha(websiteURL, websitePublicKey, proxyInfo, funcaptchaApiJSSubdomain, userAgent, data)
await handler.funcaptchaproxyless(websiteURL, websitePublicKey, funcaptchaApiJSSubdomain, userAgent, data)
await handler.funcaptchaclassification(image, question)
await handler.geetest(websiteURL, gt, challenge, geetestApiServerSubdomain, proxyInfo, version, userAgent, geetestGetLib, initParameters)
await handler.geetestproxyless(websiteURL, gt, challenge, geetestApiServerSubdomain, version, userAgent, geetestGetLib, initParameters)
pass null instead of empty for optional arguments
Currently unsupported API methods:
❌ ReCaptchaV2Classification
🆕 News
Verbose level
const handler = new Captchaai(apikey, verbose);
Verbose level undefined || 0
: Dont print logs, just get response.
Verbose level 1
: Print logs about performed requests during execution.
Verbose level 2
: Appends full captchaai api response in verbose level 1 outputs.
More code examples
example: build proxyless taskData
schema for HCaptchaTaskProxyless.
const Captchaai = require('captchaai-npm');
const handler = new Captchaai('apikey');
const taskData =
{ type : 'HCaptchaTaskProxyless', websiteURL : 'https://website.com/', websiteKey : '000000-00000-000000-000000000' }
await handler.runAnyTask(taskData).then(response => { console.log(response); });
example: recaptchav3.
import Captchaai from 'captchaai-npm';
const apikey = 'CAI-XXX...';
const handler = new Captchaai(apikey);
await handler.recaptchav3(
'https://websiteurl.com/',
'0000000000000_0000000',
{ 'proxyType': 'http', 'proxyAddress': 'ip_address', 'proxyPort': 3221, 'proxyLogin': 'username', 'proxyPassword': 'password' },
'sign_in'
).then(response => { console.log(response); })
*Building fast test-project with captchaai-npm