anticaptcha 0.0.2+2
anticaptcha: ^0.0.2+2 copied to clipboard
Anti-Captcha.com unofficial dart library
AntiCaptcha Dart Client #
A modern, type-safe, and asynchronous Dart library for the Anti-Captcha service. Powered by Dio and json_serializable.
๐ Features #
- ๐ก๏ธ Type-Safe: Comprehensive models for all captcha tasks and responses.
- โก Modern Networking: Built on top of
Diofor efficient HTTP requests and configurable timeouts. - ๐ Automated Polling: Simplified result retrieval with smart polling logic.
- ๐ฐ Balance Check: Easily check your account balance.
- ๐ Soft ID Support: Support for developer attribution (softId).
- ๐ ๏ธ Extensible: Easily support new captcha types like Cloudflare Turnstile, Recaptcha V2, and more.
- ๐ฆ Clean Architecture: Organized codebase for better maintainability.
๐ฆ Installation #
Add this to your pubspec.yaml:
dependencies:
anticaptcha: ^0.0.1
Then run:
dart pub get
๐ ๏ธ Usage #
Quick Start #
import 'package:anticaptcha/anticaptcha.dart';
void main() async {
// Initialize the client with your API key and optional softId
final client = AntiCaptchaClient('YOUR_API_KEY');
// Check balance
final balance = await client.getBalance();
print('Current Balance: $balance');
try {
// Solve an Image-to-Text captcha
final base64Image = await client.imageToBase64('captcha.jpeg');
final result = await client.solve(ImageToTextTask(body: base64Image));
print('Captcha Solved: ${result.solution?['text']}');
} on AntiCaptchaException catch (e) {
print('Error: ${e.message}');
}
}
Supported Captcha Types #
Cloudflare Turnstile (Proxyless)
final result = await client.solve(
TurnstileTaskProxyless(
websiteURL: 'https://example.com',
websiteKey: 'YOUR_TURNSTILE_KEY',
action: 'login', // optional
),
);
print('Token: ${result.solution?['token']}');
Cloudflare Turnstile (With Proxy)
final result = await client.solve(
TurnstileTask(
websiteURL: 'https://example.com',
websiteKey: 'YOUR_TURNSTILE_KEY',
proxyType: 'http',
proxyAddress: '1.2.3.4',
proxyPort: 8080,
proxyLogin: 'user', // optional
proxyPassword: 'pass', // optional
),
);
print('Token: ${result.solution?['token']}');
Recaptcha V2 (Proxyless)
final result = await client.solve(
RecaptchaV2TaskProxyless(
websiteURL: 'https://example.com',
websiteKey: 'YOUR_RECAPTCHA_KEY',
),
);
print('gRecaptchaResponse: ${result.solution?['gRecaptchaResponse']}');
Recaptcha V2 (With Proxy)
final result = await client.solve(
RecaptchaV2Task(
websiteURL: 'https://example.com',
websiteKey: 'YOUR_RECAPTCHA_KEY',
proxyType: 'http',
proxyAddress: '1.2.3.4',
proxyPort: 8080,
userAgent: 'Mozilla/5.0...',
proxyLogin: 'user', // optional
proxyPassword: 'pass', // optional
),
);
print('gRecaptchaResponse: ${result.solution?['gRecaptchaResponse']}');
โ๏ธ Advanced Configuration #
You can customize the Dio instance or adjust polling behavior:
final client = AntiCaptchaClient(
'YOUR_API_KEY',
timeout: Duration(seconds: 45), // Custom HTTP timeout
);
final result = await client.solve(
task,
pollingInterval: Duration(seconds: 3), // Wait 3s between checks
maxRetries: 40, // Total attempts
);
๐งช Testing #
The library uses dotenv for integration tests. Create a .env file in the root directory:
ANTICAPTCHA_KEY=your_actual_api_key
Then run:
dart test
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer: This is an unofficial library and is not affiliated with Anti-Captcha.com.