captchakings 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CaptchaKings
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include examples *.py
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.4
2
+ Name: captchakings
3
+ Version: 1.0.0
4
+ Summary: Official Python client for CaptchaKings API
5
+ Home-page: https://captchakings.com
6
+ Author: CaptchaKings
7
+ Author-email: support@captchakings.com
8
+ Project-URL: Documentation, https://captchakings.com?section=documentation
9
+ Project-URL: Source, https://captchakings.com
10
+ Project-URL: Bug Reports, https://captchakings.com
11
+ Keywords: captcha,ocr,captcha-solver,captchakings,api-client
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.6
18
+ Classifier: Programming Language :: Python :: 3.7
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Requires-Python: >=3.6
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests>=2.25.0
27
+ Dynamic: author
28
+ Dynamic: author-email
29
+ Dynamic: classifier
30
+ Dynamic: description
31
+ Dynamic: description-content-type
32
+ Dynamic: home-page
33
+ Dynamic: keywords
34
+ Dynamic: license-file
35
+ Dynamic: project-url
36
+ Dynamic: requires-dist
37
+ Dynamic: requires-python
38
+ Dynamic: summary
39
+
40
+ # CaptchaKings Python Library
41
+
42
+ [![Python Version](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
43
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
44
+
45
+ Official Python client library for [CaptchaKings API](https://captchakings.com) - Fast, accurate, and affordable CAPTCHA solving service.
46
+
47
+ ## ✨ Features
48
+
49
+ - 🚀 **Simple & Clean API** - Just 2 lines of code to solve CAPTCHAs
50
+ - 🔄 **Automatic Retry** - Built-in retry logic for failed requests
51
+ - 🛡️ **Type Hints** - Full type annotations for better IDE support
52
+ - ⚡ **Fast & Reliable** - Optimized for performance
53
+ - 🎯 **Error Handling** - Custom exceptions for different error types
54
+ - 📦 **Zero Configuration** - Works out of the box
55
+
56
+ ## 📦 Installation
57
+
58
+ ### From Source (Local Development)
59
+
60
+ ```bash
61
+ cd captchakings-python
62
+ pip install -e .
63
+ ```
64
+
65
+ ### Requirements
66
+
67
+ - Python 3.6 or higher
68
+ - `requests` library (automatically installed)
69
+
70
+ ## 🚀 Quick Start
71
+
72
+ ```python
73
+ from captchakings import CaptchaKings
74
+
75
+ # Initialize client
76
+ client = CaptchaKings('ck_your_api_key_here')
77
+
78
+ # Solve CAPTCHA
79
+ result = client.solve('captcha.jpg')
80
+
81
+ print(f"Solved: {result['prediction']}")
82
+ print(f"Confidence: {result['confidence']}")
83
+ print(f"Credits Remaining: {result['credits_remaining']}")
84
+ ```
85
+
86
+ That's it! Just 3 lines of code. 🎉
87
+
88
+ ## 📖 Usage Examples
89
+
90
+ ### Basic Usage
91
+
92
+ ```python
93
+ from captchakings import CaptchaKings
94
+
95
+ client = CaptchaKings('ck_your_api_key')
96
+ result = client.solve('path/to/captcha.jpg')
97
+
98
+ if result:
99
+ print(f"✅ CAPTCHA Solved: {result['prediction']}")
100
+ print(f"Confidence: {result['confidence']}")
101
+ print(f"Credits Remaining: {result['credits_remaining']}")
102
+ ```
103
+
104
+ ### With Automatic Retry
105
+
106
+ ```python
107
+ from captchakings import CaptchaKings
108
+
109
+ client = CaptchaKings('ck_your_api_key')
110
+
111
+ # Automatically retry up to 5 times with 2 second delay
112
+ result = client.solve_with_retry(
113
+ 'captcha.jpg',
114
+ max_retries=5,
115
+ retry_delay=2
116
+ )
117
+
118
+ print(f"Solved: {result['prediction']}")
119
+ ```
120
+
121
+ ### Error Handling
122
+
123
+ ```python
124
+ from captchakings import CaptchaKings
125
+ from captchakings.exceptions import (
126
+ AuthenticationError,
127
+ InsufficientCreditsError,
128
+ InvalidImageError,
129
+ APIError
130
+ )
131
+
132
+ client = CaptchaKings('ck_your_api_key')
133
+
134
+ try:
135
+ result = client.solve('captcha.jpg')
136
+ print(f"Solved: {result['prediction']}")
137
+
138
+ except AuthenticationError:
139
+ print("❌ Invalid API key")
140
+ except InsufficientCreditsError:
141
+ print("❌ Not enough credits")
142
+ except InvalidImageError:
143
+ print("❌ Invalid image file")
144
+ except APIError as e:
145
+ print(f"❌ API Error: {e}")
146
+ ```
147
+
148
+ ### Using Context Manager
149
+
150
+ ```python
151
+ from captchakings import CaptchaKings
152
+
153
+ # Automatically closes session after use
154
+ with CaptchaKings('ck_your_api_key') as client:
155
+ result = client.solve('captcha.jpg')
156
+ print(f"Solved: {result['prediction']}")
157
+ ```
158
+
159
+ ### Processing Multiple CAPTCHAs
160
+
161
+ ```python
162
+ from captchakings import CaptchaKings
163
+ import os
164
+
165
+ client = CaptchaKings('ck_your_api_key')
166
+
167
+ captcha_folder = 'captchas/'
168
+ for filename in os.listdir(captcha_folder):
169
+ if filename.endswith(('.jpg', '.png', '.jpeg')):
170
+ filepath = os.path.join(captcha_folder, filename)
171
+
172
+ try:
173
+ result = client.solve(filepath)
174
+ print(f"{filename}: {result['prediction']}")
175
+ except Exception as e:
176
+ print(f"{filename}: Error - {e}")
177
+ ```
178
+
179
+ ## 🎯 API Reference
180
+
181
+ ### CaptchaKings Class
182
+
183
+ #### `__init__(api_key, base_url='https://captchakings.com/api/process.php')`
184
+
185
+ Initialize the client.
186
+
187
+ **Parameters:**
188
+ - `api_key` (str): Your CaptchaKings API key
189
+ - `base_url` (str, optional): API endpoint URL
190
+
191
+ #### `solve(image_path, timeout=30)`
192
+
193
+ Solve a CAPTCHA from an image file.
194
+
195
+ **Parameters:**
196
+ - `image_path` (str): Path to CAPTCHA image file
197
+ - `timeout` (int, optional): Request timeout in seconds (default: 30)
198
+
199
+ **Returns:**
200
+ - `dict`: Response containing:
201
+ - `prediction` (str): Solved CAPTCHA text
202
+ - `confidence` (float): Prediction confidence score
203
+ - `process_time` (float): Processing time in seconds
204
+ - `credits_deducted` (int): Credits used for this request
205
+ - `credits_remaining` (int): Remaining credits in account
206
+ - `plan` (str): Your current plan name
207
+
208
+ **Raises:**
209
+ - `InvalidImageError`: Image file not found or invalid
210
+ - `AuthenticationError`: Invalid API key
211
+ - `InsufficientCreditsError`: Not enough credits
212
+ - `TimeoutError`: Request timeout
213
+ - `NetworkError`: Connection error
214
+ - `APIError`: Other API errors
215
+
216
+ #### `solve_with_retry(image_path, max_retries=3, retry_delay=2, timeout=30)`
217
+
218
+ Solve CAPTCHA with automatic retry on transient failures.
219
+
220
+ **Parameters:**
221
+ - `image_path` (str): Path to CAPTCHA image file
222
+ - `max_retries` (int, optional): Maximum retry attempts (default: 3)
223
+ - `retry_delay` (int, optional): Delay between retries in seconds (default: 2)
224
+ - `timeout` (int, optional): Request timeout in seconds (default: 30)
225
+
226
+ **Returns:**
227
+ - Same as `solve()` method
228
+
229
+ ## 🎨 Response Format
230
+
231
+ ```python
232
+ {
233
+ 'prediction': 'ABC123', # Solved CAPTCHA text
234
+ 'confidence': 0.98, # Confidence score (0-1)
235
+ 'process_time': 0.234, # Processing time in seconds
236
+ 'credits_deducted': 1, # Credits used
237
+ 'credits_remaining': 9999, # Remaining credits
238
+ 'plan': 'Professional' # Your plan name
239
+ }
240
+ ```
241
+
242
+ ## ⚠️ Exception Types
243
+
244
+ - `CaptchaKingsException` - Base exception class
245
+ - `APIError` - General API errors
246
+ - `AuthenticationError` - Invalid API key
247
+ - `InsufficientCreditsError` - Not enough credits
248
+ - `InvalidImageError` - Invalid or missing image file
249
+ - `TimeoutError` - Request timeout
250
+ - `NetworkError` - Network connection error
251
+
252
+ ## 🔑 Getting API Key
253
+
254
+ 1. Visit [CaptchaKings.com](https://captchakings.com)
255
+ 2. Register for an account
256
+ 3. Go to Dashboard
257
+ 4. Copy your API key (starts with `ck_`)
258
+
259
+ ## 💡 Tips
260
+
261
+ 1. **Use context manager** - Ensures proper session cleanup
262
+ 2. **Enable retry logic** - For better reliability
263
+ 3. **Handle exceptions** - For robust error handling
264
+ 4. **Batch processing** - Reuse the same client instance
265
+
266
+ ## 📚 More Examples
267
+
268
+ Check the `examples/` folder for more usage examples:
269
+
270
+ - `basic_usage.py` - Simple CAPTCHA solving
271
+ - `advanced_usage.py` - Advanced features and error handling
272
+ - `batch_processing.py` - Process multiple CAPTCHAs
273
+
274
+ ## 🤝 Support
275
+
276
+ - **Website**: [captchakings.com](https://captchakings.com)
277
+ - **Documentation**: [captchakings.com/docs](https://captchakings.com?section=documentation)
278
+ - **Email**: support@captchakings.com
279
+
280
+ ## 📄 License
281
+
282
+ MIT License - see LICENSE file for details
283
+
284
+ ## 🌟 Why CaptchaKings?
285
+
286
+ - ✅ **High Accuracy** - 99%+ success rate
287
+ - ✅ **Fast Processing** - < 1 second average response time
288
+ - ✅ **Affordable Pricing** - Starting from $1/1000 solves
289
+ - ✅ **24/7 Support** - Always here to help
290
+ - ✅ **No Setup Required** - Start in seconds
291
+
292
+ ---
293
+
294
+ Made with ❤️ by [CaptchaKings](https://captchakings.com)
@@ -0,0 +1,255 @@
1
+ # CaptchaKings Python Library
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
+
6
+ Official Python client library for [CaptchaKings API](https://captchakings.com) - Fast, accurate, and affordable CAPTCHA solving service.
7
+
8
+ ## ✨ Features
9
+
10
+ - 🚀 **Simple & Clean API** - Just 2 lines of code to solve CAPTCHAs
11
+ - 🔄 **Automatic Retry** - Built-in retry logic for failed requests
12
+ - 🛡️ **Type Hints** - Full type annotations for better IDE support
13
+ - ⚡ **Fast & Reliable** - Optimized for performance
14
+ - 🎯 **Error Handling** - Custom exceptions for different error types
15
+ - 📦 **Zero Configuration** - Works out of the box
16
+
17
+ ## 📦 Installation
18
+
19
+ ### From Source (Local Development)
20
+
21
+ ```bash
22
+ cd captchakings-python
23
+ pip install -e .
24
+ ```
25
+
26
+ ### Requirements
27
+
28
+ - Python 3.6 or higher
29
+ - `requests` library (automatically installed)
30
+
31
+ ## 🚀 Quick Start
32
+
33
+ ```python
34
+ from captchakings import CaptchaKings
35
+
36
+ # Initialize client
37
+ client = CaptchaKings('ck_your_api_key_here')
38
+
39
+ # Solve CAPTCHA
40
+ result = client.solve('captcha.jpg')
41
+
42
+ print(f"Solved: {result['prediction']}")
43
+ print(f"Confidence: {result['confidence']}")
44
+ print(f"Credits Remaining: {result['credits_remaining']}")
45
+ ```
46
+
47
+ That's it! Just 3 lines of code. 🎉
48
+
49
+ ## 📖 Usage Examples
50
+
51
+ ### Basic Usage
52
+
53
+ ```python
54
+ from captchakings import CaptchaKings
55
+
56
+ client = CaptchaKings('ck_your_api_key')
57
+ result = client.solve('path/to/captcha.jpg')
58
+
59
+ if result:
60
+ print(f"✅ CAPTCHA Solved: {result['prediction']}")
61
+ print(f"Confidence: {result['confidence']}")
62
+ print(f"Credits Remaining: {result['credits_remaining']}")
63
+ ```
64
+
65
+ ### With Automatic Retry
66
+
67
+ ```python
68
+ from captchakings import CaptchaKings
69
+
70
+ client = CaptchaKings('ck_your_api_key')
71
+
72
+ # Automatically retry up to 5 times with 2 second delay
73
+ result = client.solve_with_retry(
74
+ 'captcha.jpg',
75
+ max_retries=5,
76
+ retry_delay=2
77
+ )
78
+
79
+ print(f"Solved: {result['prediction']}")
80
+ ```
81
+
82
+ ### Error Handling
83
+
84
+ ```python
85
+ from captchakings import CaptchaKings
86
+ from captchakings.exceptions import (
87
+ AuthenticationError,
88
+ InsufficientCreditsError,
89
+ InvalidImageError,
90
+ APIError
91
+ )
92
+
93
+ client = CaptchaKings('ck_your_api_key')
94
+
95
+ try:
96
+ result = client.solve('captcha.jpg')
97
+ print(f"Solved: {result['prediction']}")
98
+
99
+ except AuthenticationError:
100
+ print("❌ Invalid API key")
101
+ except InsufficientCreditsError:
102
+ print("❌ Not enough credits")
103
+ except InvalidImageError:
104
+ print("❌ Invalid image file")
105
+ except APIError as e:
106
+ print(f"❌ API Error: {e}")
107
+ ```
108
+
109
+ ### Using Context Manager
110
+
111
+ ```python
112
+ from captchakings import CaptchaKings
113
+
114
+ # Automatically closes session after use
115
+ with CaptchaKings('ck_your_api_key') as client:
116
+ result = client.solve('captcha.jpg')
117
+ print(f"Solved: {result['prediction']}")
118
+ ```
119
+
120
+ ### Processing Multiple CAPTCHAs
121
+
122
+ ```python
123
+ from captchakings import CaptchaKings
124
+ import os
125
+
126
+ client = CaptchaKings('ck_your_api_key')
127
+
128
+ captcha_folder = 'captchas/'
129
+ for filename in os.listdir(captcha_folder):
130
+ if filename.endswith(('.jpg', '.png', '.jpeg')):
131
+ filepath = os.path.join(captcha_folder, filename)
132
+
133
+ try:
134
+ result = client.solve(filepath)
135
+ print(f"{filename}: {result['prediction']}")
136
+ except Exception as e:
137
+ print(f"{filename}: Error - {e}")
138
+ ```
139
+
140
+ ## 🎯 API Reference
141
+
142
+ ### CaptchaKings Class
143
+
144
+ #### `__init__(api_key, base_url='https://captchakings.com/api/process.php')`
145
+
146
+ Initialize the client.
147
+
148
+ **Parameters:**
149
+ - `api_key` (str): Your CaptchaKings API key
150
+ - `base_url` (str, optional): API endpoint URL
151
+
152
+ #### `solve(image_path, timeout=30)`
153
+
154
+ Solve a CAPTCHA from an image file.
155
+
156
+ **Parameters:**
157
+ - `image_path` (str): Path to CAPTCHA image file
158
+ - `timeout` (int, optional): Request timeout in seconds (default: 30)
159
+
160
+ **Returns:**
161
+ - `dict`: Response containing:
162
+ - `prediction` (str): Solved CAPTCHA text
163
+ - `confidence` (float): Prediction confidence score
164
+ - `process_time` (float): Processing time in seconds
165
+ - `credits_deducted` (int): Credits used for this request
166
+ - `credits_remaining` (int): Remaining credits in account
167
+ - `plan` (str): Your current plan name
168
+
169
+ **Raises:**
170
+ - `InvalidImageError`: Image file not found or invalid
171
+ - `AuthenticationError`: Invalid API key
172
+ - `InsufficientCreditsError`: Not enough credits
173
+ - `TimeoutError`: Request timeout
174
+ - `NetworkError`: Connection error
175
+ - `APIError`: Other API errors
176
+
177
+ #### `solve_with_retry(image_path, max_retries=3, retry_delay=2, timeout=30)`
178
+
179
+ Solve CAPTCHA with automatic retry on transient failures.
180
+
181
+ **Parameters:**
182
+ - `image_path` (str): Path to CAPTCHA image file
183
+ - `max_retries` (int, optional): Maximum retry attempts (default: 3)
184
+ - `retry_delay` (int, optional): Delay between retries in seconds (default: 2)
185
+ - `timeout` (int, optional): Request timeout in seconds (default: 30)
186
+
187
+ **Returns:**
188
+ - Same as `solve()` method
189
+
190
+ ## 🎨 Response Format
191
+
192
+ ```python
193
+ {
194
+ 'prediction': 'ABC123', # Solved CAPTCHA text
195
+ 'confidence': 0.98, # Confidence score (0-1)
196
+ 'process_time': 0.234, # Processing time in seconds
197
+ 'credits_deducted': 1, # Credits used
198
+ 'credits_remaining': 9999, # Remaining credits
199
+ 'plan': 'Professional' # Your plan name
200
+ }
201
+ ```
202
+
203
+ ## ⚠️ Exception Types
204
+
205
+ - `CaptchaKingsException` - Base exception class
206
+ - `APIError` - General API errors
207
+ - `AuthenticationError` - Invalid API key
208
+ - `InsufficientCreditsError` - Not enough credits
209
+ - `InvalidImageError` - Invalid or missing image file
210
+ - `TimeoutError` - Request timeout
211
+ - `NetworkError` - Network connection error
212
+
213
+ ## 🔑 Getting API Key
214
+
215
+ 1. Visit [CaptchaKings.com](https://captchakings.com)
216
+ 2. Register for an account
217
+ 3. Go to Dashboard
218
+ 4. Copy your API key (starts with `ck_`)
219
+
220
+ ## 💡 Tips
221
+
222
+ 1. **Use context manager** - Ensures proper session cleanup
223
+ 2. **Enable retry logic** - For better reliability
224
+ 3. **Handle exceptions** - For robust error handling
225
+ 4. **Batch processing** - Reuse the same client instance
226
+
227
+ ## 📚 More Examples
228
+
229
+ Check the `examples/` folder for more usage examples:
230
+
231
+ - `basic_usage.py` - Simple CAPTCHA solving
232
+ - `advanced_usage.py` - Advanced features and error handling
233
+ - `batch_processing.py` - Process multiple CAPTCHAs
234
+
235
+ ## 🤝 Support
236
+
237
+ - **Website**: [captchakings.com](https://captchakings.com)
238
+ - **Documentation**: [captchakings.com/docs](https://captchakings.com?section=documentation)
239
+ - **Email**: support@captchakings.com
240
+
241
+ ## 📄 License
242
+
243
+ MIT License - see LICENSE file for details
244
+
245
+ ## 🌟 Why CaptchaKings?
246
+
247
+ - ✅ **High Accuracy** - 99%+ success rate
248
+ - ✅ **Fast Processing** - < 1 second average response time
249
+ - ✅ **Affordable Pricing** - Starting from $1/1000 solves
250
+ - ✅ **24/7 Support** - Always here to help
251
+ - ✅ **No Setup Required** - Start in seconds
252
+
253
+ ---
254
+
255
+ Made with ❤️ by [CaptchaKings](https://captchakings.com)
@@ -0,0 +1,37 @@
1
+ """
2
+ CaptchaKings Python Library
3
+
4
+ Simple and powerful Python client for CaptchaKings API.
5
+
6
+ Example:
7
+ >>> from captchakings import CaptchaKings
8
+ >>> client = CaptchaKings('ck_your_api_key')
9
+ >>> result = client.solve('captcha.jpg')
10
+ >>> print(result['prediction'])
11
+ """
12
+
13
+ __version__ = '1.0.0'
14
+ __author__ = 'CaptchaKings'
15
+ __license__ = 'MIT'
16
+
17
+ from .client import CaptchaKings
18
+ from .exceptions import (
19
+ CaptchaKingsException,
20
+ APIError,
21
+ AuthenticationError,
22
+ InsufficientCreditsError,
23
+ InvalidImageError,
24
+ TimeoutError,
25
+ NetworkError
26
+ )
27
+
28
+ __all__ = [
29
+ 'CaptchaKings',
30
+ 'CaptchaKingsException',
31
+ 'APIError',
32
+ 'AuthenticationError',
33
+ 'InsufficientCreditsError',
34
+ 'InvalidImageError',
35
+ 'TimeoutError',
36
+ 'NetworkError'
37
+ ]