Official Python client for CaptchaKings API
Project description
CaptchaKings Python Library
Official Python client library for CaptchaKings API - Fast, accurate, and affordable CAPTCHA solving service.
✨ Features
- 🚀 Simple & Clean API - Just 2 lines of code to solve CAPTCHAs
- 🔄 Automatic Retry - Built-in retry logic for failed requests
- 🛡️ Type Hints - Full type annotations for better IDE support
- ⚡ Fast & Reliable - Optimized for performance
- 🎯 Error Handling - Custom exceptions for different error types
- 📦 Zero Configuration - Works out of the box
📦 Installation
From Source (Local Development)
cd captchakings-python
pip install -e .
Requirements
- Python 3.6 or higher
requestslibrary (automatically installed)
🚀 Quick Start
from captchakings import CaptchaKings
# Initialize client
client = CaptchaKings('ck_your_api_key_here')
# Solve CAPTCHA
result = client.solve('captcha.jpg')
print(f"Solved: {result['prediction']}")
print(f"Confidence: {result['confidence']}")
print(f"Credits Remaining: {result['credits_remaining']}")
That's it! Just 3 lines of code. 🎉
📖 Usage Examples
Basic Usage
from captchakings import CaptchaKings
client = CaptchaKings('ck_your_api_key')
result = client.solve('path/to/captcha.jpg')
if result:
print(f"✅ CAPTCHA Solved: {result['prediction']}")
print(f"Confidence: {result['confidence']}")
print(f"Credits Remaining: {result['credits_remaining']}")
With Automatic Retry
from captchakings import CaptchaKings
client = CaptchaKings('ck_your_api_key')
# Automatically retry up to 5 times with 2 second delay
result = client.solve_with_retry(
'captcha.jpg',
max_retries=5,
retry_delay=2
)
print(f"Solved: {result['prediction']}")
Error Handling
from captchakings import CaptchaKings
from captchakings.exceptions import (
AuthenticationError,
InsufficientCreditsError,
InvalidImageError,
APIError
)
client = CaptchaKings('ck_your_api_key')
try:
result = client.solve('captcha.jpg')
print(f"Solved: {result['prediction']}")
except AuthenticationError:
print("❌ Invalid API key")
except InsufficientCreditsError:
print("❌ Not enough credits")
except InvalidImageError:
print("❌ Invalid image file")
except APIError as e:
print(f"❌ API Error: {e}")
Using Context Manager
from captchakings import CaptchaKings
# Automatically closes session after use
with CaptchaKings('ck_your_api_key') as client:
result = client.solve('captcha.jpg')
print(f"Solved: {result['prediction']}")
Processing Multiple CAPTCHAs
from captchakings import CaptchaKings
import os
client = CaptchaKings('ck_your_api_key')
captcha_folder = 'captchas/'
for filename in os.listdir(captcha_folder):
if filename.endswith(('.jpg', '.png', '.jpeg')):
filepath = os.path.join(captcha_folder, filename)
try:
result = client.solve(filepath)
print(f"{filename}: {result['prediction']}")
except Exception as e:
print(f"{filename}: Error - {e}")
🎯 API Reference
CaptchaKings Class
__init__(api_key, base_url='https://captchakings.com/api/process.php')
Initialize the client.
Parameters:
api_key(str): Your CaptchaKings API keybase_url(str, optional): API endpoint URL
solve(image_path, timeout=30)
Solve a CAPTCHA from an image file.
Parameters:
image_path(str): Path to CAPTCHA image filetimeout(int, optional): Request timeout in seconds (default: 30)
Returns:
dict: Response containing:prediction(str): Solved CAPTCHA textconfidence(float): Prediction confidence scoreprocess_time(float): Processing time in secondscredits_deducted(int): Credits used for this requestcredits_remaining(int): Remaining credits in accountplan(str): Your current plan name
Raises:
InvalidImageError: Image file not found or invalidAuthenticationError: Invalid API keyInsufficientCreditsError: Not enough creditsTimeoutError: Request timeoutNetworkError: Connection errorAPIError: Other API errors
solve_with_retry(image_path, max_retries=3, retry_delay=2, timeout=30)
Solve CAPTCHA with automatic retry on transient failures.
Parameters:
image_path(str): Path to CAPTCHA image filemax_retries(int, optional): Maximum retry attempts (default: 3)retry_delay(int, optional): Delay between retries in seconds (default: 2)timeout(int, optional): Request timeout in seconds (default: 30)
Returns:
- Same as
solve()method
🎨 Response Format
{
'prediction': 'ABC123', # Solved CAPTCHA text
'confidence': 0.98, # Confidence score (0-1)
'process_time': 0.234, # Processing time in seconds
'credits_deducted': 1, # Credits used
'credits_remaining': 9999, # Remaining credits
'plan': 'Professional' # Your plan name
}
⚠️ Exception Types
CaptchaKingsException- Base exception classAPIError- General API errorsAuthenticationError- Invalid API keyInsufficientCreditsError- Not enough creditsInvalidImageError- Invalid or missing image fileTimeoutError- Request timeoutNetworkError- Network connection error
🔑 Getting API Key
- Visit CaptchaKings.com
- Register for an account
- Go to Dashboard
- Copy your API key (starts with
ck_)
💡 Tips
- Use context manager - Ensures proper session cleanup
- Enable retry logic - For better reliability
- Handle exceptions - For robust error handling
- Batch processing - Reuse the same client instance
📚 More Examples
Check the examples/ folder for more usage examples:
basic_usage.py- Simple CAPTCHA solvingadvanced_usage.py- Advanced features and error handlingbatch_processing.py- Process multiple CAPTCHAs
🤝 Support
- Website: captchakings.com
- Documentation: captchakings.com/docs
- Email: support@captchakings.com
📄 License
MIT License - see LICENSE file for details
🌟 Why CaptchaKings?
- ✅ High Accuracy - 99%+ success rate
- ✅ Fast Processing - < 1 second average response time
- ✅ Affordable Pricing - Starting from $1/1000 solves
- ✅ 24/7 Support - Always here to help
- ✅ No Setup Required - Start in seconds
Made with ❤️ by CaptchaKings
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file captchakings-1.0.0.tar.gz.
File metadata
- Download URL: captchakings-1.0.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9bfad799d1e886c99cacf4f64503790d9a019ef08ab7cf3b3e30920df661d8b
|
|
| MD5 |
6ec350a0ae2b7501ab966d942e9148a5
|
|
| BLAKE2b-256 |
4ef85241473bec5c7b481b5755e509fc5f06fbfc5856ab64e850174171af8fd2
|
File details
Details for the file captchakings-1.0.0-py3-none-any.whl.
File metadata
- Download URL: captchakings-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61749ba78d52668e546d9ec17a5ab09b43e31563067e24662be63df068ab7dc4
|
|
| MD5 |
a6e4f4cd73fcdd2e00c0f6d455c78e2b
|
|
| BLAKE2b-256 |
80ae5876a38e4412eeaf6e2a1643777cef56ec7fcee2b3b9ffeb2439338b3a26
|