[![All dependencies](https://img.shields.io/librariesio/release/npm/rucaptcha-2captcha/2.2.0?style=flat-square "All dependencies of rucaptcha-2captcha@2.2.0")](https://libraries.io/npm/rucaptcha-2captcha/2.2.0)
[![Reported vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/rucaptcha-2captcha@2.2.0?style=flat-square "Reported vulnerabilities of rucaptcha-2captcha@2.2.0")](https://snyk.io/test/npm/rucaptcha-2captcha/2.2.0)
[![Commits](https://flat.badgen.net/github/commits/ArthurKa/rucaptcha-2captcha)](https://github.com/ArthurKa/rucaptcha-2captcha/commits/master)
[![NPM-version](https://img.shields.io/badge/npm-v2.2.0-blue.svg?style=flat-square&&logo=npm "Current NPM-version")](https://www.npmjs.com/package/rucaptcha-2captcha/v/2.2.0)
[![Total downloads](https://img.shields.io/npm/dt/rucaptcha-2captcha?style=flat-square "Total downloads for all the time")](https://npm-stat.com/charts.html?package=rucaptcha-2captcha)
[![Developed by](https://img.shields.io/badge/developed_by-ArthurKa-blueviolet.svg?style=flat-square "GitHub")](https://github.com/ArthurKa)\
[![Publish size](https://flat.badgen.net/packagephobia/publish/rucaptcha-2captcha@2.2.0?label=publish 'Publish size of rucaptcha-2captcha@2.2.0')](https://packagephobia.now.sh/result?p=rucaptcha-2captcha@2.2.0)
[![Install size](https://flat.badgen.net/packagephobia/install/rucaptcha-2captcha@2.2.0?label=install 'Install size of rucaptcha-2captcha@2.2.0')](https://packagephobia.now.sh/result?p=rucaptcha-2captcha@2.2.0)
[![Minified size](https://img.shields.io/bundlephobia/min/rucaptcha-2captcha@2.2.0?style=flat-square&label=minified "Minified size of rucaptcha-2captcha@2.2.0")](https://bundlephobia.com/result?p=rucaptcha-2captcha@2.2.0)
[![Minified + gzipped size](https://img.shields.io/bundlephobia/minzip/rucaptcha-2captcha@2.2.0?style=flat-square&label=minzipped "Minified + gzipped size of rucaptcha-2captcha@2.2.0")](https://bundlephobia.com/result?p=rucaptcha-2captcha@2.2.0)
# rucaptcha-2captcha@2.2.0
Helps you to operate with [RuCaptcha] or [2Captcha] services conveniently.
Full documentation you can find on official sites: [RuCaptcha Docs][RuCaptchaAPI], [2Captcha Docs][2CaptchaAPI].
## Installation
`rucaptcha-2captcha` is available via NPM:
```bash
$ npm i rucaptcha-2captcha@2.2.0
```
## Usage
### Initialization
#### Synopsis
new RuCaptcha2Captcha(apiKey[, type]) → `captchaSolver` object
| Name | Type | Required | Description
|--------|--------------|----------|-
| apiKey | string | yes | Your account API key from settings ([RuCaptcha][RuCaptchaSettings] \| [2Captcha][2CaptchaSettings]).
| type | `2` \| `'2'` | no | Provide string or number **2** for [2Captcha]. Any other for [RuCaptcha].
#### Example
```ts
import RuCaptcha2Captcha from 'rucaptcha-2captcha';
const captchaSolver = new RuCaptcha2Captcha();
// or for operating with 2Captcha.com
const captchaSolver = new RuCaptcha2Captcha(, 2);
```
### captchaSolver.send method
#### Synopsis
captchaSolver.send(params) → `Promise`
| Name | Type | Required | Description
|--------|--------|----------|-
| params | object | yes | Object with properties from documentation ([RuCaptcha][RuCaptchaParams] \| [2Captcha][2CaptchaParams]), except: `key`, `json` and `soft_id`. Among these properties of `url`, `method`, `file` and `body` can be used only the next combinations: • single `url` • `method` + `body` • `method` + `file`
Use this method to send captcha for solving.
#### Example
```ts
const id = await captchaSolver.send({
method: 'base64',
body: ,
// any other parameter from documentation,
// except: file, key, json and soft_id
});
// id: '4503599627'
```
#### Sending image from your local file system or the Internet
```ts
const id = await captchaSolver.send({
// url: './captchas/W68HP.gif',
url: 'https://user-images.githubusercontent.com/16370704/87232185-aad0b680-c3c5-11ea-8cfc-b769bba631d4.gif',
// any other parameter from documentation,
// except: method, file, body, key, json and soft_id
// for example
regsense: 1, // for case-sensitive
numeric: 4, // for both numbers and letters
min_len: 5, //
max_len: 5, // for exactly 5 symbols
language: 2, // for Roman alphabet
});
// id: '4503599672'
```
### captchaSolver.get method
#### Synopsis
captchaSolver.get(id | ids | strIds) → `Promise` | `Promise>`
| Name | Type | Required | Description
|--------|-----------|------------|-
| id | string | one of all | Id of sent captcha via [send-method](#captchasolversend-method).
| ids | Array | one of all | Array of captcha ids.
| strIds | string | one of all | String of comma-separated captcha ids.
Method for getting captcha solutions.\
Returns promise which resolves as soon as all captchas by provided ids will be solved on service.
#### Example
```ts
import { ArrayLikeString, isArrayLikeString } from 'rucaptcha-2captcha/src/types';
const id = '';
const id2 = '';
const ids = ',';
const token = await captchaSolver.get(id); // 'pgh3Ds'
const tokens = await captchaSolver.get([id, id2]); // ['pgh3Ds', 'q5ZZpt']
const tokens2 = await captchaSolver.get(ids as ArrayLikeString); // ['pgh3Ds', 'q5ZZpt']
if(isArrayLikeString(ids)) {
const tokens = await captchaSolver.get(ids); // ['pgh3Ds', 'q5ZZpt']
}
```
### Solution reporting methods
#### Synopsis
captchaSolver.reportGood(id) → `Promise