link and install according to the instructions.

npm i @2captcha/captcha-solver 

We invite you to explore our GitHub repository where you can find JavaScript API client for easy integration with our API.

Configuration

Description of all the necessary parameters to configure the installed package

An instance of the Solver class can be created like this:

import { Solver } from '@2captcha/captcha-solver'
const solver = new Captcha.Solver("<Your 2captcha api key>")

Solve captcha

When you submit any image-based captcha use can provide additional options to help 2Captcha workers to solve it properly

Captcha options
OptionDefault valueDescription
numeric-Defines if captcha contains numeric or other symbols see more info in the API docs
min_len-minimal answer length
max_len-maximum answer length
phrase-defines if the answer contains multiple words or not
regsense-defines if the answer is case sensitive
calc-defines captcha requires calculation
lang-defines the captcha language, see the list of supported languages
textinstructions-hint or task text shown to workers with the captcha
simpleCaptcha

To bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image.

solver.imageCaptcha({
    body: 'data:image/png;base64,iVBORw0KGgoAAAANSUhE...',
})
.then((res) => {
  // Logs the image text
  console.log(res);
})
recaptchaV2

Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.

solver.recaptcha({
    pageurl: 'https://2captcha.com/demo/recaptcha-v2',
    googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u'
  })
.then((res) => {
 console.log(res);
})
recaptchaV3

This method provides reCAPTCHA V3 solver and returns a token.

solver.recaptcha({
    pageurl: 'https://2captcha.com/demo/recaptcha-v3',
    googlekey: '6Lcyqq8oAAAAAJE7eVJ3aZp_hnJcI6LgGdYD8lge',
    version: "v3",
    min_score: "0.4",
    action: 'demo_action'
})
.then((res) => {
  console.log(res);
})
funCaptcha

FunCaptcha (Arkoselabs) solving method. Returns a token.

solver.funCaptcha({
    pageurl: "https://www.site.com/page/funcaptcha",
    publickey: "823480F4-6844-FFA1-ED4E-5877CA1F1EG0"
  })
  .then((res) => {
    console.log(res);
  })
geeTest

Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON.

solver.geetest({ 
    pageurl: 'https://2captcha.com/demo/geetest',
    gt: '81388ea1fc187e0c335c0a8907ff2625',
    challenge: '12345678abc90123d45678ef90123a456b'
  })
  .then((res) => {
    console.log(res);
  })
capy

Token-based method to bypass Capy puzzle captcha.

solver.capyPuzzle({
    pageurl: "http://mysite.com/",
    captchakey: "PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v"
})
.then((res) => {
    console.log(res);
})
clickCaptcha

ClickCaptcha method returns coordinates of points on captcha image. Can be used if you need to click on particular points on the image.

solver.coordinates({
    body: 'data:image/png;base64,iVBORw0KGgoAAAANSUhE...',
    textinstructions: 'Select all photos containing the boat'
 })
.then((res) => {
    console.log(res);
})

Other methods

Additional valid methods used during the work of the main scripts

send / get

These methods can be used for manual captcha submission and answer polling.

solver.imageCaptcha({
    body: 'data:image/png;base64,iVBORw0KGgoAAAANSUhE...',
})
.then((res) => {
  // Logs the result
  console.log(res);
})

balance

Use this method to get your account's balance.

solver.balance()
.then((res) => {
    console.log(res)
})

report

Use this method to report good or bad captcha answer.

solver.goodReport('7031846604') // captcha solved correctly
solver.badReport('7031854546')  // captcha solved incorrectly

Error handling

Possible variants of standard errors returned by the service when processing requests

If case of an error captcha solver throws an exception. It's important to properly handle these cases. We recommend to use try/catch or .catch() to handle exceptions.

solver.imageCaptcha({
    body: 'data:image/png;base64,iVBORw0KGgoAAAANSUhE...',
})
.then((res) => {
  // Logs the result
  console.log(res);
})
.catch((err) => {
  // Error handling
  console.log(err);
})

Other languages for integration with the service API