DeOne4eg / 2captcha-rucaptcha

CAPTCHAFORUM

Administrator
2captcha-rucaptcha.png

Simple 2captcha and rucaptcha API wrapper for Node.js
The package is written in TypeScript and currently only supports base64 images.

Instalation
NPM:
npm i 2captcha-rucaptcha --save

Yarn:
yarn add 2captcha-rucaptcha

Usage
All examples are on the github.

Upload image to rucaptcha
Code:
const { Captcha } = require("2captcha-rucaptcha");
const fs = require("fs");

const captcha = new Captcha({
  type: 1,
  key: "<YOUR_API_KEY>"
});

const base64 = fs.readFileSync("base64.txt", "utf-8");
captcha
  .solve({ method: "base64", body: base64 })
  .then(result => {
    console.log(result);
  })
  .catch(e => {
    console.log(e);
  });

Upload image to 2captcha
Code:
const { Captcha } = require("2captcha-rucaptcha");
const fs = require("fs");

const captcha = new Captcha({
  type: 2,
  key: "<YOUR_API_KEY>"
});

const base64 = fs.readFileSync("base64.txt", "utf-8");
captcha
  .solve({ method: "base64", body: base64 })
  .then(result => {
    console.log(result);
  })
  .catch(e => {
    console.log(e);
  });

Report bad and good
To report a failed or successful captcha solution, you need to use the following methods:
bad(id) good(id)

Example:
Code:
solution = await captcha.solve({ method: "base64", body: base64, lang: "en", numeric: 1 });
if (ok) captcha.good(captcha.id);
else captcha.bad(captcha.id);

Documentation https://github.com/DeOne4eg/2captcha-rucaptcha