Socket
Socket
Sign inDemoInstall

captchaai-npm

Package Overview
Dependencies
16
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    captchaai-npm

Want you to get captcha verified tokens with a simple function call in your NodeJS application?


Version published
Weekly downloads
1
Maintainers
1
Install size
943 kB
Created
Weekly downloads
 

Readme

Source

captchaai.io api🧠 task handler

Want you to get captcha verified tokens with a simple function call in your NodeJS application?

Just install Axios and run with this repo. You will find a fast way to perform some automations.

  • Manage to solve captcha challenges with AI. (Captcha service based)
  • ❗❗ An API key is required.
  • 🔥 HCaptcha Image Classification it's now supported.

⬇️ Install

npm i captchaai-npm

✋ Usage

  1. Import module.

     const Captchaai = require('captchaai-npm');
    
  2. Declare singleton/handler.

     const handler = new Captchaai(apikey); // task handler / solver
    

❗ There are 2 different versions in order to handle task results:

1️⃣ fast-bind methods

example: balance check + .hcaptchaproxyless()

const Captchaai = require('captchaai-npm');
const handler = new Captchaai('apikey', 1); // verbose level 1
let b = await handler.balance();
if(b > 0){  // usd balance
    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: handle for hcaptcha task with .hcaptcha() using custom proxy server.

const Captchaai = require('captchaai-npm');
const handler = new Captchaai('apikey', 1); // verbose level 1
let b = await handler.balance();
if(b > 0){  // usd balance
    await handler.hcaptchaproxyless(
        'https://websiteurl.com/', 
        '000000-000000000-0000000',
        { proxy: "proxyType:proxyAddress:proxyPort:proxyLogin:proxyPassword" }   // 2nd proxyInfo format
    )
     .then(async r => {
         if(r.error === 0)
             console.log('got token!\n' + JSON.stringify(r.apiResponse));
     });
}

2️⃣ .runAnyTask(taskData)

example: build proxyless taskData schema performing 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: 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: { proxy: "proxyType:proxyAddress:proxyPort:proxyLogin:proxyPassword" }, // also string format is supported with `proxy`
    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.

ParameterTypeDescription
errornumber[-1] Request/solving error. [0] Success solving.
statusTextstringhttp status string
apiResponseobjectTask result. Captchaai.io API response.

✅Success object example:

{
  error: 0,
  statusText: '200 OK',
  apiResponse: {
    errorId: 0,
    taskId: '4e6c33f5-bc14-44d0-979e-d5f37b072c59',
    status: 'ready',
    solution: {
      gRecaptchaResponse: '03AIIukzgCys9brSNnrVbwXE9mTesvkxQ-ocK ...'
    }
  }
}

❌Invalid task object example:

{
  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

MethodReturns
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 above.
  • proxyInfo can be passed as { 'proxy' : 'proxystring...' } or as { proxyType:''}

balance

MethodReturns
await handler.balance()directly the float value or an error object
await handler.getBalance()succes or error object

fast-bind methods

Method
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.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

🆕 hcaptchaclassification(question, queries, coordinate):

Currently unsupported API methods:

❌ ReCaptchaV2Classification ❌ ImageToTextTask ❌ AntiKasadaTask ❌ AntiAkamaiBMPTask

Verbose level

const handler = new Captchaai(apikey, verbose); // on handler initialization

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

import Captchaai from 'captchaai-npm'; // import as ES6 module
const apikey = 'CAI-XXX...';
const captchaai = new Captchaai(apikey);

// proxyType: (http, https, socks4, socks5)
await captchaai.recaptchav3(
        'https://websiteurl.com/',
        '0000000000000_0000000',
        { 'proxyType': 'http', 'proxyAddress': 'ip_address', 'proxyPort': 3221, 'proxyLogin': 'username', 'proxyPassword': 'password' },
        'sign_in'
).then(response => { console.log(response); }) // actionMethod argument required in recaptchav3

*Building fast test-project with captchaai-npm

Keywords

FAQs

Last updated on 27 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc