node-anticaptcha
v1.0.1
Published
Modern Node.js library for Anti-Captcha.com API
Maintainers
Readme
node-anticaptcha
Modern Node.js library for the Anti-Captcha.com API. Clean, typed, and easy to use.
Installation
npm install node-anticaptcha
# or
pnpm install node-anticaptcha
# or
yarn add node-anticaptchaFeatures
- 🎯 Clean, modern API design
- 🧠 Built-in TypeScript declarations
- 🔄 Automatic task polling
- 🎨 Verbose logging support
- 💰 Revenue sharing support
- 🔧 Fully configurable
Usage
CommonJS
const { AntiCaptcha } = require('node-anticaptcha');
const client = new AntiCaptcha('YOUR_API_KEY', {
verbose: true,
verboseIdentifier: 'MyBot',
delay: 2000,
});ES Modules
import { AntiCaptcha } from 'node-anticaptcha';
const client = new AntiCaptcha('YOUR_API_KEY', {
verbose: true,
verboseIdentifier: 'MyBot',
delay: 2000,
});TypeScript
import { AntiCaptcha, type RecaptchaV2TaskProxyless } from 'node-anticaptcha';
const client = new AntiCaptcha('YOUR_API_KEY', {
verbose: true,
});
const task: RecaptchaV2TaskProxyless = {
type: 'RecaptchaV2TaskProxyless',
websiteURL: 'https://example.com',
websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
};
const result = await client.solve(task);Constructor Options
softId- Your developer softId from developer center to earn 10% commissionverbose- Enable verbose logging (default:false)verboseIdentifier- Custom identifier for logsapiUrl- API endpoint URL (default:https://api.anti-captcha.com)delay- Delay between status checks in milliseconds (default:2000)callbackUrl- Optional web address where we can send the results of captcha task processing. Contents are sent by AJAX POST request and are identical to the contents of getTaskResult method.
Examples
Get Balance
const balance = await client.getBalance();
console.log(`Balance: $${balance.balance}`);Solve ReCaptcha V2
const result = await client.solve({
type: 'RecaptchaV2TaskProxyless',
websiteURL: 'https://example.com',
websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
});
console.log('Token:', result.solution.gRecaptchaResponse);Solve ReCaptcha V3
const result = await client.solve({
type: 'RecaptchaV3TaskProxyless',
websiteURL: 'https://example.com',
websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
minScore: 0.7,
pageAction: 'submit',
});
console.log('Token:', result.solution.gRecaptchaResponse);Solve Turnstile (Cloudflare)
const result = await client.solve({
type: 'TurnstileTaskProxyless',
websiteURL: 'https://example.com',
websiteKey: '0x4AAAAAAADnPIDROzbs0Ajs',
});
console.log('Token:', result.solution.token);Solve Image Captcha
const fs = require('node:fs');
const imageBuffer = fs.readFileSync('captcha.png');
const result = await client.solve({
type: 'ImageToTextTask',
body: imageBuffer, // Can be Buffer or base64 string
phrase: false,
case: false,
numeric: 0,
math: false,
minLength: 0,
maxLength: 0,
languagePool: 'en',
});
console.log('Text:', result.solution.text);Solve GeeTest
const result = await client.solve({
type: 'GeeTestTaskProxyless',
websiteURL: 'https://example.com',
gt: 'gt_value_here',
challenge: 'challenge_value_here',
});
console.log('Solution:', result.solution);Solve FunCaptcha
const result = await client.solve({
type: 'FunCaptchaTaskProxyless',
websiteURL: 'https://example.com',
websitePublicKey: 'public_key_here',
});
console.log('Token:', result.solution.token);Drive AntiGate Template
const result = await client.solve({
type: 'AntiGateTask',
websiteURL: 'https://example.com/login',
templateName: 'Login and fetch session',
variables: {
login: '[email protected]',
password: 'strong-password',
twoFactorCode: '_WAIT_FOR_IT_', // send later via pushAntiGateVariable
},
domainsOfInterest: ['example.com'],
// Optional HTTPS proxy fields
proxyAddress: '1.2.3.4',
proxyPort: 8080,
proxyLogin: 'proxyUser',
proxyPassword: 'proxyPass',
});
console.log('Cookies:', result.solution.cookies);Using Proxy
const result = await client.solve({
type: 'RecaptchaV2Task', // Note: Not "Proxyless"
websiteURL: 'https://example.com',
websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
proxyType: 'http',
proxyAddress: '1.2.3.4',
proxyPort: 8080,
proxyLogin: 'username',
proxyPassword: 'password',
userAgent: 'Mozilla/5.0...',
});
console.log('Token:', result.solution.gRecaptchaResponse);API Methods
getBalance()
Get account balance.
Returns: Promise<AntiCaptchaBalanceResponse>
createTask(task, callbackUrl?)
Create a new captcha task.
Parameters:
task- Task object (see task types below)callbackUrl- Optional web address where we can send the results of captcha task processing. Contents are sent by AJAX POST request and are identical to the contents of getTaskResult method. If not provided, will use the callbackUrl from constructor options if set.
Returns: Promise<AntiCaptchaCreateTaskResponse>
getTaskResult(taskId)
Get result of a task.
Parameters:
taskId- Task ID fromcreateTask()
Returns: Promise<AntiCaptchaGetTaskResultResponse>
solve(task)
Create and automatically poll for task completion.
Parameters:
task- Task object (see task types below)
Returns: Promise<AntiCaptchaSolveTaskResult>
reportIncorrectImageCaptcha(taskId)
Report incorrect image captcha result.
Parameters:
taskId- Task ID to report
Returns: Promise<AntiCaptchaReportResponse>
reportIncorrectRecaptcha(taskId)
Report incorrect recaptcha result.
Parameters:
taskId- Task ID to report
Returns: Promise<AntiCaptchaReportResponse>
reportCorrectRecaptcha(taskId)
Report correct recaptcha result (for statistics and worker whitelisting).
Parameters:
taskId- Task ID to report
Returns: Promise<AntiCaptchaReportResponse>
pushAntiGateVariable(taskId, name, value)
Push variable to AntiGate task during execution.
Parameters:
taskId- Task IDname- Variable namevalue- Variable value
Returns: Promise<AntiCaptchaReportResponse>
getQueueStats(queueId, templateName?)
Get queue load statistics to determine a suitable time for uploading tasks.
Parameters:
queueId- Queue identifier (1-29). See documentation for queue IDstemplateName- Optional template name for AntiGate queue (ID 25)
Returns: Promise<AntiCaptchaQueueStatsResponse>
getSpendingStats(date?, queue?, softId?, ip?)
Retrieve account spending statistics for a 24 hour period.
Parameters:
date- Unix timestamp of the hour from which to grab 24 hour stats (optional)queue- Queue name to filter by (optional)softId- Filter by softId from Developer Center (optional)ip- Filter by IP address used for API calls (optional)
Returns: Promise<AntiCaptchaSpendingStatsResponse>
getAppStats(softId, mode?)
Retrieve daily statistics for your registered application.
Parameters:
softId- The ID of your app from the Developer Centermode- Type of stats: 'errors', 'views', 'downloads', 'users', 'money' (default: 'errors')
Returns: Promise<AntiCaptchaAppStatsResponse>
test(data?)
Test method for debugging API requests. Returns parsed and raw POST data.
Parameters:
data- Any data object to test with (optional)
Returns: Promise<unknown>
Supported Task Types
Image Tasks
ImageToTextTask- Solve image captchaImageToCoordinatesTask- Click coordinates on image
ReCaptcha
RecaptchaV2TaskProxyless- ReCaptcha V2 without proxyRecaptchaV2Task- ReCaptcha V2 with proxyRecaptchaV2EnterpriseTaskProxyless- ReCaptcha V2 Enterprise without proxyRecaptchaV2EnterpriseTask- ReCaptcha V2 Enterprise with proxyRecaptchaV3TaskProxyless- ReCaptcha V3 (supports Enterprise)
FunCaptcha
FunCaptchaTaskProxyless- FunCaptcha without proxyFunCaptchaTask- FunCaptcha with proxy
GeeTest
GeeTestTaskProxyless- GeeTest without proxy (V3 and V4)GeeTestTask- GeeTest with proxy (V3 and V4)
Turnstile (Cloudflare)
TurnstileTaskProxyless- Turnstile without proxyTurnstileTask- Turnstile with proxy
Other
AntiGateTask- Custom tasks with templatesProsopoTaskProxyless- Prosopo captcha without proxyProsopoTask- Prosopo captcha with proxyFriendlyCaptchaTaskProxyless- Friendly Captcha without proxyFriendlyCaptchaTask- Friendly Captcha with proxyAmazonTaskProxyless- Amazon WAF without proxyAmazonTask- Amazon WAF with proxyAltchaTaskProxyless- Altcha without proxyAltchaTask- Altcha with proxy
TypeScript Support
The library is authored in TypeScript and ships first-class type declarations for every task, option, and response. Editors such as VS Code provide rich IntelliSense out of the box.
Error Handling
try {
const result = await client.solve({
type: 'RecaptchaV2TaskProxyless',
websiteURL: 'https://example.com',
websiteKey: 'invalid_key',
});
console.log(result.solution);
} catch (error) {
if (error.response) {
// API error
console.error('API Error:', error.response.data);
} else {
// Network or other error
console.error('Error:', error.message);
}
}License
ISC
