Skip to content

Commit ff8e7ae

Browse files
authored
added binance (#31)
1 parent 885bfc2 commit ff8e7ae

6 files changed

Lines changed: 127 additions & 1 deletion

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Examples of API requests for different captcha types are available on the [JavaS
4848
- [VkCaptcha](#vkcaptcha)
4949
- [Temu](#temu)
5050
- [Altcha](#altcha)
51+
- [Binance](#binance)
5152
- [Audio Captcha](#audio-captcha)
5253
- [Other methods](#other-methods)
5354
- [goodReport](#goodreport)
@@ -758,6 +759,29 @@ console.log(err);
758759
})
759760
```
760761

762+
### Binance
763+
764+
<sup>[API method description.](https://2captcha.com/2captcha-api#binance)</sup>
765+
766+
This method can be used to solve Binance captcha. Returns a token.
767+
768+
```js
769+
solver.binance({
770+
pageurl: "https://mysite.com/page/with/binance",
771+
sitekey: "register",
772+
validateId: "0a05453c44e2411195c0d0c15654d966",
773+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
774+
proxy: "login:password@1.2.3.4:8888",
775+
proxytype: "HTTP"
776+
})
777+
.then((res) => {
778+
console.log(res);
779+
})
780+
.catch((err) => {
781+
console.log(err);
782+
})
783+
```
784+
761785
### Audio Captcha
762786

763787
<sup>[API method description.](https://2captcha.com/2captcha-api#audio-recognition)</sup>

examples/binance.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const TwoCaptcha = require("../dist/index.js");
2+
require('dotenv').config();
3+
const APIKEY = process.env.APIKEY
4+
const proxy = process.env.proxy
5+
const proxytype = process.env.proxytype
6+
const solver = new TwoCaptcha.Solver(APIKEY);
7+
8+
solver.binance({
9+
pageurl: "https://mysite.com/page/with/binance",
10+
sitekey: "register",
11+
validateId: "0a05453c44e2411195c0d0c15654d966",
12+
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36",
13+
proxy: "login:password@1.2.3.4:8888",
14+
proxytype: "HTTP"
15+
})
16+
.then((res) => {
17+
console.log(res);
18+
})
19+
.catch((err) => {
20+
console.log(err);
21+
})

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"VkCaptcha",
5454
"Temu",
5555
"atbCAPTCHA",
56+
"Altcha",
57+
"Binance",
5658
"Audio Recognition"
5759
],
5860
"scripts": {

src/structs/2captcha.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ export interface paramsAltcha {
310310
proxytype?: string,
311311
}
312312

313+
export interface paramsBinance {
314+
pageurl: string,
315+
sitekey: string,
316+
validateId: string,
317+
userAgent?: string,
318+
proxy?: string,
319+
proxytype?: string,
320+
}
321+
313322
export interface paramsAudioCaptcha {
314323
body: string,
315324
lang: string,
@@ -2211,6 +2220,68 @@ public async altcha(params: paramsAltcha): Promise<CaptchaAnswer> {
22112220
}
22122221
}
22132222

2223+
2224+
/**
2225+
* ### Solves Binance Captcha
2226+
*
2227+
* This method can be used to solve Binance captcha. Returns a token.
2228+
* [Read more about Binance Method](https://2captcha.com/2captcha-api#binance).
2229+
*
2230+
* @param {{ pageurl, sitekey, validateId, userAgent, proxy, proxytype}} params Parameters Binance as an object.
2231+
* @param {string} params.pageurl Full URL of the page where you solve the captcha.
2232+
* @param {string} params.sitekey Value of 'bizId', 'bizType', or 'bizCode' from page requests.
2233+
* @param {string} params.validateId Dynamic value of 'validateId', 'securityId', or 'securityCheckResponseValidateId'.
2234+
* @param {string} params.userAgent Browser User-Agent. We recommend sending a valid Windows browser string.
2235+
* @param {string} params.proxy Format: `login:password@123.123.123.123:3128` You can find more info about proxies [here](https://2captcha.com/2captcha-api#proxies).
2236+
* @param {string} params.proxytype Type of your proxy: `HTTP`, `HTTPS`, `SOCKS4`, `SOCKS5`.
2237+
*
2238+
* @example
2239+
* solver.binance({
2240+
* pageurl: "https://mysite.com/page/with/binance",
2241+
* sitekey: "register",
2242+
* validateId: "0a05453c44e2411195c0d0c15654d966",
2243+
* })
2244+
* .then((res) => {
2245+
* console.log(res);
2246+
* })
2247+
* .catch((err) => {
2248+
* console.log(err);
2249+
* })
2250+
*/
2251+
2252+
public async binance(params: paramsBinance): Promise<CaptchaAnswer> {
2253+
params = renameParams(params)
2254+
2255+
checkCaptchaParams(params, "binance")
2256+
2257+
const payload = {
2258+
...this.defaultPayload,
2259+
...params,
2260+
method: "binance",
2261+
};
2262+
2263+
const response = await fetch(this.in, {
2264+
body: JSON.stringify(payload),
2265+
method: "post",
2266+
headers: { "Content-Type": "application/json" }
2267+
})
2268+
const result = await response.text()
2269+
2270+
let data;
2271+
try {
2272+
data = JSON.parse(result)
2273+
} catch {
2274+
throw new APIError(result)
2275+
}
2276+
2277+
if (data.status == 1) {
2278+
return this.pollResponse(data.request)
2279+
} else {
2280+
throw new APIError(data.request)
2281+
}
2282+
}
2283+
2284+
22142285
/**
22152286
* ### Method for solving Audio captcha.
22162287
*

src/utils/checkCaptchaParams.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Captcha methods for which parameter checking is available
22
const supportedMethods = ["userrecaptcha", "hcaptcha", "geetest", "geetest_v4","yandex","funcaptcha","lemin","amazon_waf",
33
"turnstile", "base64", "capy","datadome", "cybersiara", "mt_captcha", "bounding_box", 'friendly_captcha', 'grid',
4-
'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'audio']
4+
'textcaptcha', 'canvas', 'rotatecaptcha', 'keycaptcha', 'cutcaptcha', 'tencent', 'atb_captcha', 'prosopo', 'captchafox', 'vkimage', 'vkcaptcha', 'temu', 'altcha', 'binance', 'audio']
55

66
// Names of required fields that must be contained in the parameters captcha
77
const recaptchaRequiredFields = ['pageurl','googlekey']
@@ -35,6 +35,7 @@ const vkimageRequiredFields = ['body', 'steps']
3535
const vkcaptchaRequiredFields = ['redirect_uri', 'userAgent', 'proxy', 'proxytype']
3636
const temuRequiredFields = ['body', 'part1', 'part2', 'part3']
3737
const altchaRequiredFields = ['pageurl']
38+
const binanceRequiredFields = ['pageurl', 'sitekey', 'validate_id']
3839
const audioRequiredFields = ['body', 'lang']
3940

4041
/**
@@ -137,6 +138,9 @@ const getRequiredFildsArr = (method: string):Array<string> => {
137138
case "altcha":
138139
requiredFieldsArr = altchaRequiredFields
139140
break;
141+
case "binance":
142+
requiredFieldsArr = binanceRequiredFields
143+
break;
140144
case "audio":
141145
requiredFieldsArr = audioRequiredFields
142146
break;

src/utils/renameParams.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export default function renameParams(params: any) {
4343
// Altcha
4444
"challengeUrl": "challenge_url",
4545
"challengeJson": "challenge_json",
46+
47+
//Binance
48+
"validateId": "validate_id",
49+
"userAgent": "useragent"
4650
}
4751

4852
for(let key in params) {

0 commit comments

Comments
 (0)