capmonster-python 4.0.0__py3-none-any.whl → 5.0.0__py3-none-any.whl

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.
@@ -7,26 +7,40 @@ __all__ = [
7
7
  "VanillaTaskPayload",
8
8
  "ProxyPayload",
9
9
  "UserAgentPayload",
10
+ "AltchaTask",
11
+ "AltchaMetadata",
12
+ "AmazonTask",
10
13
  "BasiliskTask",
11
14
  "BinanceTask",
15
+ "CastleTask",
16
+ "CastleMetadata",
12
17
  "ComplexImageRecaptchaTask",
13
18
  "ComplexImageRecaptchaMetadata",
14
19
  "ComplexImageRecognitionTask",
15
20
  "DataDomeTask",
16
21
  "DataDomeMetadata",
22
+ "FunCaptchaTask",
17
23
  "GeeTestV3Task",
18
24
  "GeeTestV4Task",
25
+ "HuntTask",
19
26
  "ImageToTextTask",
20
27
  "ImpervaTask",
21
28
  "ImpervaTaskMetadata",
29
+ "MTCaptchaTask",
22
30
  "ProsopoTask",
31
+ "RecaptchaClickTask",
23
32
  "RecaptchaV2Task",
24
33
  "RecaptchaV2EnterpriseTask",
25
34
  "RecaptchaV3Task",
35
+ "RecaptchaV3EnterpriseTask",
26
36
  "TemuTask",
27
37
  "TenDITask",
38
+ "TSPDTask",
39
+ "TSPDMetadata",
28
40
  "TurnstileTask",
29
41
  "TurnstileCloudFlareTask",
42
+ "TurnstileWaitingRoomTask",
43
+ "YidunTask",
30
44
  "CapmonsterException",
31
45
  "CapmonsterAPIException",
32
46
  "CapmonsterValidationException"
@@ -5,7 +5,7 @@ from typing import Optional
5
5
  from httpx import Response, AsyncClient, Client
6
6
 
7
7
  from .exceptions import CapmonsterAPIException, CapmonsterException
8
- from .methods import GetBalancePayload, GetTaskResultPayload, CreateTaskPayload
8
+ from .methods import GetBalancePayload, GetTaskResultPayload, CreateTaskPayload, ReportIncorrectCaptchaPayload
9
9
  from .tasks.task import TaskPayload
10
10
 
11
11
 
@@ -14,14 +14,31 @@ class CapmonsterClient:
14
14
  __BALANCE_URL = "/getBalance"
15
15
  __TASK_RESULT_URL = "/getTaskResult"
16
16
  __CREATE_TASK_URL = "/createTask"
17
- __MAX_RETRY = 120
18
- __PER_RETRY_DELAY = 1
19
17
 
20
- def __init__(self, api_key: str, timeout: Optional[float] = 30.0) -> None:
18
+ __REPORT_IMAGE_URL = "/reportIncorrectImageCaptcha"
19
+ __REPORT_TOKEN_URL = "/reportIncorrectTokenCaptcha"
20
+ __USER_AGENT_URL = "https://capmonster.cloud/api/useragent/actual"
21
+
22
+ def __init__(self, api_key: str, timeout: Optional[float] = 30.0,
23
+ max_retries: int = 120, retry_delay: float = 2.0) -> None:
21
24
  self.api_key = api_key
25
+ self.__max_retries = max_retries
26
+ self.__retry_delay = retry_delay
22
27
  self.__async_client = AsyncClient(timeout=timeout, base_url=self.__BASE_URL)
23
28
  self.__sync_client = Client(timeout=timeout, base_url=self.__BASE_URL)
24
29
 
30
+ def __enter__(self) -> "CapmonsterClient":
31
+ return self
32
+
33
+ def __exit__(self, *args) -> None:
34
+ self.__sync_client.close()
35
+
36
+ async def __aenter__(self) -> "CapmonsterClient":
37
+ return self
38
+
39
+ async def __aexit__(self, *args) -> None:
40
+ await self.__async_client.aclose()
41
+
25
42
  def get_balance(self) -> float:
26
43
  """
27
44
  Fetches the current balance using the provided API key.
@@ -84,7 +101,7 @@ class CapmonsterClient:
84
101
  Asynchronously creates a task based on the provided payload and returns the task ID.
85
102
 
86
103
  This method is responsible for initiating a task by preparing the request with the
87
- provided task details and optional callback URL, sending a synchronous request to the
104
+ provided task details and optional callback URL, sending an asynchronous request to the
88
105
  task creation endpoint, and parsing the response to retrieve the task ID.
89
106
 
90
107
  Args:
@@ -166,16 +183,16 @@ class CapmonsterClient:
166
183
  CapmonsterException:
167
184
  If the maximum retry limit is exceeded without obtaining the task result.
168
185
  """
169
- for _ in range(0, self.__MAX_RETRY + 1):
186
+ for _ in range(0, self.__max_retries + 1):
170
187
  result = self.get_task_result(task_id)
171
188
  if result:
172
189
  return result
173
190
  elif not result:
174
- sleep(self.__PER_RETRY_DELAY)
191
+ sleep(self.__retry_delay)
175
192
  raise CapmonsterAPIException(
176
193
  61, "ERROR_MAXIMUM_TIME_EXCEED", "Maximum time is exceed.")
177
194
 
178
- async def join_task_result_async(self, task_id: int):
195
+ async def join_task_result_async(self, task_id: int) -> dict:
179
196
  """
180
197
  Asynchronously joins and retrieves the result of a task given its ID, retrying a specified number
181
198
  of times if the result is not immediately available.
@@ -191,19 +208,131 @@ class CapmonsterClient:
191
208
  CapmonsterException:
192
209
  If the maximum retry limit is exceeded without obtaining the task result.
193
210
  """
194
- for _ in range(0, self.__MAX_RETRY + 1):
211
+ for _ in range(0, self.__max_retries + 1):
195
212
  result = await self.get_task_result_async(task_id)
196
213
  if result:
197
214
  return result
198
215
  elif not result:
199
- await asyncio.sleep(self.__PER_RETRY_DELAY)
216
+ await asyncio.sleep(self.__retry_delay)
200
217
  raise CapmonsterAPIException(
201
218
  61, "ERROR_MAXIMUM_TIME_EXCEED", "Maximum time is exceed.")
202
219
 
220
+ def solve(self, task: TaskPayload, callback_url: Optional[str] = None) -> dict:
221
+ """
222
+ Convenience method that creates a task and polls for its result.
223
+
224
+ Equivalent to calling create_task() followed by join_task_result().
225
+
226
+ Args:
227
+ task: The task configuration payload.
228
+ callback_url: An optional callback URL for task completion.
229
+
230
+ Returns:
231
+ dict: The solution dictionary from the completed task.
232
+ """
233
+ task_id = self.create_task(task, callback_url)
234
+ return self.join_task_result(task_id)
235
+
236
+ async def solve_async(self, task: TaskPayload, callback_url: Optional[str] = None) -> dict:
237
+ """
238
+ Async convenience method that creates a task and polls for its result.
239
+
240
+ Equivalent to calling create_task_async() followed by join_task_result_async().
241
+
242
+ Args:
243
+ task: The task configuration payload.
244
+ callback_url: An optional callback URL for task completion.
245
+
246
+ Returns:
247
+ dict: The solution dictionary from the completed task.
248
+ """
249
+ task_id = await self.create_task_async(task, callback_url)
250
+ return await self.join_task_result_async(task_id)
251
+
252
+ def report_incorrect_image(self, task_id: int) -> None:
253
+ """
254
+ Reports an incorrect image captcha solution.
255
+
256
+ Args:
257
+ task_id: The identifier of the task to report.
258
+
259
+ Raises:
260
+ CapmonsterAPIException: If the API returns an error.
261
+ """
262
+ payload = ReportIncorrectCaptchaPayload(clientKey=self.api_key, taskId=task_id).model_dump()
263
+ self.__make_sync_request(self.__REPORT_IMAGE_URL, payload)
264
+
265
+ async def report_incorrect_image_async(self, task_id: int) -> None:
266
+ """
267
+ Asynchronously reports an incorrect image captcha solution.
268
+
269
+ Args:
270
+ task_id: The identifier of the task to report.
271
+
272
+ Raises:
273
+ CapmonsterAPIException: If the API returns an error.
274
+ """
275
+ payload = ReportIncorrectCaptchaPayload(clientKey=self.api_key, taskId=task_id).model_dump()
276
+ await self.__make_async_request(self.__REPORT_IMAGE_URL, payload)
277
+
278
+ def report_incorrect_token(self, task_id: int) -> None:
279
+ """
280
+ Reports an incorrect token captcha solution (reCAPTCHA, GeeTest, Turnstile, etc.).
281
+
282
+ Args:
283
+ task_id: The identifier of the task to report.
284
+
285
+ Raises:
286
+ CapmonsterAPIException: If the API returns an error.
287
+ """
288
+ payload = ReportIncorrectCaptchaPayload(clientKey=self.api_key, taskId=task_id).model_dump()
289
+ self.__make_sync_request(self.__REPORT_TOKEN_URL, payload)
290
+
291
+ async def report_incorrect_token_async(self, task_id: int) -> None:
292
+ """
293
+ Asynchronously reports an incorrect token captcha solution (reCAPTCHA, GeeTest, Turnstile, etc.).
294
+
295
+ Args:
296
+ task_id: The identifier of the task to report.
297
+
298
+ Raises:
299
+ CapmonsterAPIException: If the API returns an error.
300
+ """
301
+ payload = ReportIncorrectCaptchaPayload(clientKey=self.api_key, taskId=task_id).model_dump()
302
+ await self.__make_async_request(self.__REPORT_TOKEN_URL, payload)
303
+
304
+ def get_user_agent(self) -> str:
305
+ """
306
+ Fetches the current valid Windows User-Agent string from CapMonster Cloud.
307
+
308
+ Returns:
309
+ str: The current User-Agent string to use with captcha tasks.
310
+ """
311
+ try:
312
+ response = self.__sync_client.get(self.__USER_AGENT_URL)
313
+ return response.text
314
+ except Exception as e:
315
+ raise CapmonsterException(-1, type(e).__name__, str(e))
316
+
317
+ async def get_user_agent_async(self) -> str:
318
+ """
319
+ Asynchronously fetches the current valid Windows User-Agent string from CapMonster Cloud.
320
+
321
+ Returns:
322
+ str: The current User-Agent string to use with captcha tasks.
323
+ """
324
+ try:
325
+ response = await self.__async_client.get(self.__USER_AGENT_URL)
326
+ return response.text
327
+ except Exception as e:
328
+ raise CapmonsterException(-1, type(e).__name__, str(e))
329
+
203
330
  def __make_sync_request(self, url: str, payload: dict) -> Response:
204
331
  try:
205
332
  response = self.__sync_client.post(url, json=payload)
206
333
  return self.__check_response(response)
334
+ except CapmonsterException:
335
+ raise
207
336
  except Exception as e:
208
337
  raise CapmonsterException(-1, type(e).__name__, str(e))
209
338
 
@@ -211,22 +340,11 @@ class CapmonsterClient:
211
340
  try:
212
341
  post = await self.__async_client.post(url, json=payload)
213
342
  return self.__check_response(post)
343
+ except CapmonsterException:
344
+ raise
214
345
  except Exception as e:
215
346
  raise CapmonsterException(-1, type(e).__name__, str(e))
216
347
 
217
- @staticmethod
218
- def __is_ready(response: dict):
219
- status = response.get("status")
220
- if status == "processing":
221
- return False
222
- elif status == "ready":
223
- return True
224
- else:
225
- raise CapmonsterAPIException(error_id=-1,
226
- error_code="CAPMONSTER_API_ERROR",
227
- error_description="Sometimes can be happen if Capmonster "
228
- "servers there is too much intensity")
229
-
230
348
  @staticmethod
231
349
  def __check_response(data: Response) -> Response:
232
350
  response = data.json()
@@ -21,6 +21,11 @@ class GetTaskResultPayload(BaseModel):
21
21
  taskId: int = Field(..., description="ID which was obtained from create task method.")
22
22
 
23
23
 
24
+ class ReportIncorrectCaptchaPayload(BaseModel):
25
+ clientKey: str = Field(..., description="Client key")
26
+ taskId: int = Field(..., description="ID of the task to report as incorrect.")
27
+
28
+
24
29
  class CreateTaskPayload(BaseModel):
25
30
  clientKey: str = Field(..., description="Client key")
26
31
  task: TaskPayload = Field(..., description="Task data")
@@ -1,42 +1,66 @@
1
+ from .altcha import AltchaTask, AltchaMetadata
2
+ from .amazon import AmazonTask
1
3
  from .basilisk import BasiliskTask
2
4
  from .binance import BinanceTask
5
+ from .castle import CastleTask, CastleMetadata
3
6
  from .complex_image_recaptcha import ComplexImageRecaptchaTask, ComplexImageRecaptchaMetadata
4
7
  from .complex_image_recognition import ComplexImageRecognitionTask
5
8
  from .datadome import DataDomeTask, DataDomeMetadata
9
+ from .funcaptcha import FunCaptchaTask
6
10
  from .geetest import GeeTestV4Task, GeeTestV3Task
11
+ from .hunt import HuntTask
7
12
  from .image_to_text import ImageToTextTask
8
13
  from .imperva import ImpervaTask, ImpervaTaskMetadata
14
+ from .mtcaptcha import MTCaptchaTask
9
15
  from .prosopo import ProsopoTask
16
+ from .recaptcha_click import RecaptchaClickTask
10
17
  from .recaptcha_v2 import RecaptchaV2Task
11
18
  from .recaptcha_v2_enterprise import RecaptchaV2EnterpriseTask
12
19
  from .recaptcha_v3 import RecaptchaV3Task
20
+ from .recaptcha_v3_enterprise import RecaptchaV3EnterpriseTask
13
21
  from .task import VanillaTaskPayload, ProxyPayload, UserAgentPayload
14
22
  from .temu import TemuTask
15
23
  from .tendi import TenDITask
16
- from .turnstile import TurnstileTask, TurnstileCloudFlareTask
24
+ from .tspd import TSPDTask, TSPDMetadata
25
+ from .turnstile import TurnstileTask, TurnstileCloudFlareTask, TurnstileWaitingRoomTask
26
+ from .yidun import YidunTask
17
27
 
18
28
  __all__ = [
19
29
  "VanillaTaskPayload",
20
30
  "ProxyPayload",
21
31
  "UserAgentPayload",
32
+ "AltchaTask",
33
+ "AltchaMetadata",
34
+ "AmazonTask",
22
35
  "BasiliskTask",
23
36
  "BinanceTask",
37
+ "CastleTask",
38
+ "CastleMetadata",
24
39
  "ComplexImageRecaptchaTask",
25
40
  "ComplexImageRecaptchaMetadata",
26
41
  "ComplexImageRecognitionTask",
27
42
  "DataDomeTask",
28
43
  "DataDomeMetadata",
44
+ "FunCaptchaTask",
29
45
  "GeeTestV3Task",
30
46
  "GeeTestV4Task",
47
+ "HuntTask",
31
48
  "ImageToTextTask",
32
49
  "ImpervaTask",
33
50
  "ImpervaTaskMetadata",
51
+ "MTCaptchaTask",
34
52
  "ProsopoTask",
53
+ "RecaptchaClickTask",
35
54
  "RecaptchaV2Task",
36
55
  "RecaptchaV2EnterpriseTask",
37
56
  "RecaptchaV3Task",
57
+ "RecaptchaV3EnterpriseTask",
38
58
  "TemuTask",
39
59
  "TenDITask",
60
+ "TSPDTask",
61
+ "TSPDMetadata",
40
62
  "TurnstileTask",
41
- "TurnstileCloudFlareTask"
63
+ "TurnstileCloudFlareTask",
64
+ "TurnstileWaitingRoomTask",
65
+ "YidunTask"
42
66
  ]
@@ -0,0 +1,48 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field, BaseModel
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class AltchaMetadata(BaseModel):
9
+ """
10
+ Metadata for Altcha task.
11
+
12
+ Attributes:
13
+ challenge: Unique task identifier obtained from the website.
14
+ iterations: Number of iterations (corresponds to maxnumber value).
15
+ salt: Salt obtained from the site, used for hash generation.
16
+ signature: Digital signature of the request.
17
+ """
18
+ challenge: str = Field(..., description='Unique task identifier obtained from the website.')
19
+ iterations: str = Field(..., description='Number of iterations (corresponds to maxnumber value).')
20
+ salt: str = Field(..., description='Salt obtained from the site, used for hash generation.')
21
+ signature: str = Field(..., description='Digital signature of the request.')
22
+
23
+
24
+ class AltchaTask(TaskPayload, UserAgentPayload):
25
+ """
26
+ Represents a task for solving Altcha challenges.
27
+
28
+ Uses CustomTask type with class "altcha".
29
+
30
+ Attributes:
31
+ websiteURL: Main page URL where Altcha is located.
32
+ websiteKey: For this task, sending an empty string is allowed.
33
+ metadata: Altcha-specific metadata (challenge, iterations, salt, signature).
34
+ proxy: Optional proxy settings.
35
+ """
36
+ type: str = Field(default="CustomTask", frozen=True)
37
+ class_: str = Field(default="altcha", alias="class", frozen=True)
38
+ websiteURL: str = Field(..., description='Main page URL where Altcha is located.')
39
+ websiteKey: str = Field(default="", description='For this task, sending an empty string is allowed.')
40
+ metadata: AltchaMetadata = Field(..., description='Altcha-specific metadata.')
41
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
42
+
43
+ def to_request(self) -> dict[str, Any]:
44
+ base = self.model_dump(exclude_none=True, by_alias=True)
45
+ proxy_dict = base.pop("proxy", {})
46
+ if proxy_dict:
47
+ base.update(proxy_dict)
48
+ return base
@@ -0,0 +1,54 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class AmazonTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving Amazon AWS WAF captcha and challenge.
11
+
12
+ Supports multiple solving options:
13
+ - Option 1: websiteURL + websiteKey + captchaScript (simple captcha)
14
+ - Option 2: websiteURL + websiteKey + challengeScript + context + iv (full challenge)
15
+ - Option 3: websiteURL + challengeScript (invisible challenge only)
16
+
17
+ Attributes:
18
+ websiteURL: The main page address where the captcha is solved.
19
+ websiteKey: Found in the apiKey field when rendering captcha.
20
+ captchaScript: Link to jsapi.js or captcha.js on the HTML page.
21
+ challengeScript: Link to challenge.js.
22
+ context: Obtained from window.gokuProps.context.
23
+ iv: Obtained from window.gokuProps.iv.
24
+ cookieSolution: If true, returns aws-waf-token cookie instead of voucher/token.
25
+ proxy: Optional proxy settings.
26
+ """
27
+ type: str = Field(default="AmazonTask", frozen=True)
28
+ websiteURL: str = Field(..., description='The main page address where the captcha is solved.')
29
+ websiteKey: Optional[str] = Field(
30
+ default=None,
31
+ description='Can be found in the apiKey field when rendering captcha.')
32
+ captchaScript: Optional[str] = Field(
33
+ default=None,
34
+ description='Link to jsapi.js or captcha.js on the HTML page.')
35
+ challengeScript: Optional[str] = Field(
36
+ default=None,
37
+ description='Link to challenge.js.')
38
+ context: Optional[str] = Field(
39
+ default=None,
40
+ description='Obtained from window.gokuProps.context.')
41
+ iv: Optional[str] = Field(
42
+ default=None,
43
+ description='Obtained from window.gokuProps.iv.')
44
+ cookieSolution: Optional[bool] = Field(
45
+ default=None,
46
+ description='If true, returns aws-waf-token cookie instead of captcha_voucher and existing_token.')
47
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
48
+
49
+ def to_request(self) -> dict[str, Any]:
50
+ base = self.model_dump(exclude_none=True)
51
+ proxy_dict = base.pop("proxy", {})
52
+ if proxy_dict:
53
+ base.update(proxy_dict)
54
+ return base
@@ -0,0 +1,46 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field, BaseModel
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class CastleMetadata(BaseModel):
9
+ """
10
+ Metadata for Castle task.
11
+
12
+ Attributes:
13
+ wUrl: Link to cw.js file.
14
+ swUrl: Link to csw.js file.
15
+ count: Number of tokens to generate (default 1, max 49).
16
+ """
17
+ wUrl: str = Field(..., description='Link to cw.js file.')
18
+ swUrl: str = Field(..., description='Link to csw.js file.')
19
+ count: Optional[int] = Field(default=None, description='Number of tokens (default 1, max 49).', ge=1, le=49)
20
+
21
+
22
+ class CastleTask(TaskPayload, UserAgentPayload):
23
+ """
24
+ Represents a task for solving Castle challenges.
25
+
26
+ Uses CustomTask type with class "Castle".
27
+
28
+ Attributes:
29
+ websiteURL: URL of the page where Castle is located.
30
+ websiteKey: Publishable Key.
31
+ metadata: Castle-specific metadata (wUrl, swUrl, count).
32
+ proxy: Optional proxy settings.
33
+ """
34
+ type: str = Field(default="CustomTask", frozen=True)
35
+ class_: str = Field(default="Castle", alias="class", frozen=True)
36
+ websiteURL: str = Field(..., description='URL of the page where Castle is located.')
37
+ websiteKey: str = Field(..., description='Castle publishable key.')
38
+ metadata: CastleMetadata = Field(..., description='Castle-specific metadata.')
39
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
40
+
41
+ def to_request(self) -> dict[str, Any]:
42
+ base = self.model_dump(exclude_none=True, by_alias=True)
43
+ proxy_dict = base.pop("proxy", {})
44
+ if proxy_dict:
45
+ base.update(proxy_dict)
46
+ return base
@@ -0,0 +1,40 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class FunCaptchaTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving FunCaptcha (Arkose Labs) challenges.
11
+
12
+ Attributes:
13
+ websiteURL: The URL of the page where the captcha is located.
14
+ websitePublicKey: FunCaptcha public key (pk).
15
+ funcaptchaApiJSSubdomain: Arkose Labs API subdomain, only if it differs
16
+ from the default client-api.arkoselabs.com.
17
+ data: Additional data parameter, required if the site uses data[blob].
18
+ cookies: Additional cookies in the format cookieName1=value1; cookieName2=value2.
19
+ proxy: Optional proxy settings.
20
+ """
21
+ type: str = Field(default="FunCaptchaTask", frozen=True)
22
+ websiteURL: str = Field(..., description='The URL of the page where the captcha is located.')
23
+ websitePublicKey: str = Field(..., description='FunCaptcha public key (pk).')
24
+ funcaptchaApiJSSubdomain: Optional[str] = Field(
25
+ default=None,
26
+ description='Arkose Labs subdomain (surl). Specify only if it differs from client-api.arkoselabs.com.')
27
+ data: Optional[str] = Field(
28
+ default=None,
29
+ description='Additional data parameter, required if the site uses data[blob].')
30
+ cookies: Optional[str] = Field(
31
+ default=None,
32
+ description='Additional cookies in the format: cookieName1=value1; cookieName2=value2.')
33
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
34
+
35
+ def to_request(self) -> dict[str, Any]:
36
+ base = self.model_dump(exclude_none=True)
37
+ proxy_dict = base.pop("proxy", {})
38
+ if proxy_dict:
39
+ base.update(proxy_dict)
40
+ return base
@@ -0,0 +1,27 @@
1
+ from typing import Optional, Any
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class HuntTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving Hunt captcha challenges.
11
+
12
+ Attributes:
13
+ websiteURL: The URL of the webpage containing the captcha.
14
+ websiteKey: The Hunt captcha site key.
15
+ proxy: Optional proxy settings.
16
+ """
17
+ type: str = Field(default="HuntTask", frozen=True)
18
+ websiteURL: str = Field(..., description='Address of a webpage with captcha.')
19
+ websiteKey: str = Field(..., description='Hunt captcha site key.')
20
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
21
+
22
+ def to_request(self) -> dict[str, Any]:
23
+ base = self.model_dump(exclude_none=True)
24
+ proxy_dict = base.pop("proxy", {})
25
+ if proxy_dict:
26
+ base.update(proxy_dict)
27
+ return base
@@ -0,0 +1,36 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class MTCaptchaTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving MTCaptcha challenges.
11
+
12
+ Attributes:
13
+ websiteURL: URL of the page where the captcha is solved.
14
+ websiteKey: The MTCaptcha site key (passed as sk in network requests).
15
+ pageAction: The action parameter (passed as act in requests).
16
+ Only needed if it differs from the default "$".
17
+ isInvisible: Set to true if the captcha is invisible.
18
+ proxy: Optional proxy settings.
19
+ """
20
+ type: str = Field(default="MTCaptchaTask", frozen=True)
21
+ websiteURL: str = Field(..., description='URL of the page where the captcha is solved.')
22
+ websiteKey: str = Field(..., description='The MTCaptcha site key (passed as sk in network requests).')
23
+ pageAction: Optional[str] = Field(
24
+ default=None,
25
+ description='The action parameter (passed as act in requests). Only needed if different from default.')
26
+ isInvisible: Optional[bool] = Field(
27
+ default=None,
28
+ description='Set to true if the captcha is invisible.')
29
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
30
+
31
+ def to_request(self) -> dict[str, Any]:
32
+ base = self.model_dump(exclude_none=True)
33
+ proxy_dict = base.pop("proxy", {})
34
+ if proxy_dict:
35
+ base.update(proxy_dict)
36
+ return base
@@ -0,0 +1,31 @@
1
+ from typing import Optional, Any
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class RecaptchaClickTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving click-based reCAPTCHA challenges.
11
+
12
+ Attributes:
13
+ websiteURL: The URL of the webpage containing the reCAPTCHA challenge.
14
+ websiteKey: The site key associated with the reCAPTCHA on the webpage.
15
+ isInvisible: When set to True, specifies that the challenge
16
+ being solved is an invisible reCAPTCHA.
17
+ proxy: Optional proxy settings.
18
+ """
19
+ type: str = Field(default="RecaptchaClickTask", frozen=True)
20
+ websiteURL: str = Field(..., description='Address of a webpage with captcha.')
21
+ websiteKey: str = Field(..., description='reCAPTCHA website key.')
22
+ isInvisible: Optional[bool] = Field(default=None,
23
+ description='Set to true if you want to solve invisible reCAPTCHA.')
24
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
25
+
26
+ def to_request(self) -> dict[str, Any]:
27
+ base = self.model_dump(exclude_none=True)
28
+ proxy_dict = base.pop("proxy", {})
29
+ if proxy_dict:
30
+ base.update(proxy_dict)
31
+ return base
@@ -30,6 +30,10 @@ class RecaptchaV2Task(TaskPayload, UserAgentPayload):
30
30
  'and must be grabbed every time you want to solve a reCAPTCHA v2.')
31
31
  isInvisible: Optional[bool] = Field(default=None,
32
32
  description='Set to true if you want to solve invisible reCAPTCHA.')
33
+ cookies: Optional[str] = Field(default=None,
34
+ description='Additional cookies in the format: cookieName1=value1; cookieName2=value2.')
35
+ nocache: Optional[bool] = Field(default=None,
36
+ description='Set to true to force fresh token generation (prevents reuse of cached tokens).')
33
37
  proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
34
38
 
35
39
  def to_request(self) -> dict[str, Any]:
@@ -22,14 +22,18 @@ class RecaptchaV2EnterpriseTask(TaskPayload, UserAgentPayload):
22
22
  type: str = Field(default="RecaptchaV2EnterpriseTask", frozen=True)
23
23
  websiteURL: str = Field(..., description='Address of a webpage with Google reCAPTCHA Enterprise.')
24
24
  websiteKey: str = Field(..., description='reCAPTCHA website key.')
25
+ pageAction: Optional[str] = Field(default=None,
26
+ description='Action parameter if different from default “verify”.')
25
27
  enterprisePayload: Optional[str] = Field(default=None,
26
28
  description='Some implementations of the reCAPTCHA Enterprise widget '
27
29
  'may contain additional parameters that are passed to the '
28
- '“grecaptcha.enterprise.render” method along with the sitekey.')
30
+ '”grecaptcha.enterprise.render” method along with the sitekey.')
29
31
  apiDomain: Optional[str] = Field(default=None,
30
32
  description='Domain address from which to load reCAPTCHA Enterprise. '
31
33
  'Don\'t use a parameter if you don\'t know why it\'s needed.')
32
34
  cookies: Optional[str] = Field(default=None, description='Cookies to be sent with the request.')
35
+ nocache: Optional[bool] = Field(default=None,
36
+ description='Set to true to force fresh token generation (prevents reuse of cached tokens).')
33
37
  proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
34
38
 
35
39
  def to_request(self) -> dict[str, Any]:
@@ -25,6 +25,10 @@ class RecaptchaV3Task(TaskPayload):
25
25
  pageAction: Optional[str] = Field(default=None,
26
26
  description='Widget action value. Website owner defines what user is doing on '
27
27
  'the page through this parameter. Default value: verify')
28
+ isEnterprise: Optional[bool] = Field(default=None,
29
+ description='Set to true to solve as Enterprise (equivalent to RecaptchaV3EnterpriseTask).')
30
+ nocache: Optional[bool] = Field(default=None,
31
+ description='Set to true to force fresh token generation (prevents reuse of cached tokens).')
28
32
 
29
33
  def to_request(self) -> dict[str, Any]:
30
34
  return self.model_dump(exclude_none=True)
@@ -0,0 +1,30 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload
6
+
7
+
8
+ class RecaptchaV3EnterpriseTask(TaskPayload):
9
+ """
10
+ Represents a task for solving Google reCAPTCHA v3 Enterprise.
11
+
12
+ Attributes:
13
+ websiteURL: Address of the webpage that contains the reCAPTCHA to be solved.
14
+ websiteKey: The specific site key corresponding to the reCAPTCHA on the target website.
15
+ minScore: Defines the minimum acceptable score required for the captcha
16
+ result, ranging between 0.1 and 0.9.
17
+ pageAction: Specifies the widget action value. Default value: verify.
18
+ """
19
+ type: str = Field(default="RecaptchaV3EnterpriseTask", frozen=True)
20
+ websiteURL: str = Field(..., description='Address of a webpage with Google ReCaptcha Enterprise.')
21
+ websiteKey: str = Field(..., description='reCAPTCHA website key.')
22
+ minScore: Optional[float] = Field(default=None, description='Minimum score of a captcha.', ge=0.1, le=0.9)
23
+ pageAction: Optional[str] = Field(default=None,
24
+ description='Widget action value. Website owner defines what user is doing on '
25
+ 'the page through this parameter. Default value: verify')
26
+ nocache: Optional[bool] = Field(default=None,
27
+ description='Set to true to force fresh token generation (prevents reuse of cached tokens).')
28
+
29
+ def to_request(self) -> dict[str, Any]:
30
+ return self.model_dump(exclude_none=True)
@@ -0,0 +1,44 @@
1
+ from typing import Any
2
+
3
+ from pydantic import Field, BaseModel
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class TSPDMetadata(BaseModel):
9
+ """
10
+ Metadata for TSPD task.
11
+
12
+ Attributes:
13
+ tspdCookie: Cookies obtained on the TSPD challenge page.
14
+ htmlPageBase64: Entire TSPD page encoded in base64.
15
+ """
16
+ tspdCookie: str = Field(..., description='Cookies obtained on the TSPD challenge page.')
17
+ htmlPageBase64: str = Field(..., description='Entire TSPD page encoded in base64.')
18
+
19
+
20
+ class TSPDTask(TaskPayload, UserAgentPayload):
21
+ """
22
+ Represents a task for solving TSPD challenges.
23
+
24
+ Uses CustomTask type with class "tspd". Proxy is required for this task type.
25
+
26
+ Attributes:
27
+ websiteURL: URL of the page where the TSPD challenge is located.
28
+ metadata: TSPD-specific metadata (tspdCookie, htmlPageBase64).
29
+ userAgent: Browser User-Agent string (required, must be from Windows OS).
30
+ proxy: Proxy settings (required).
31
+ """
32
+ type: str = Field(default="CustomTask", frozen=True)
33
+ class_: str = Field(default="tspd", alias="class", frozen=True)
34
+ websiteURL: str = Field(..., description='URL of the page where the TSPD challenge is located.')
35
+ metadata: TSPDMetadata = Field(..., description='TSPD-specific metadata.')
36
+ userAgent: str = Field(..., description='Browser User-Agent string (required, must be from Windows OS).')
37
+ proxy: ProxyPayload = Field(..., description='Proxy settings (required).')
38
+
39
+ def to_request(self) -> dict[str, Any]:
40
+ base = self.model_dump(exclude_none=True, by_alias=True)
41
+ proxy_dict = base.pop("proxy", {})
42
+ if proxy_dict:
43
+ base.update(proxy_dict)
44
+ return base
@@ -80,3 +80,32 @@ class TurnstileCloudFlareTask(TurnstileTask):
80
80
  if proxy_dict:
81
81
  base.update(proxy_dict)
82
82
  return base
83
+
84
+
85
+ class TurnstileWaitingRoomTask(TaskPayload):
86
+ """
87
+ Represents a Turnstile task for Cloudflare Waiting Room challenges.
88
+
89
+ Returns a cf_clearance cookie. Proxy is required for this task type.
90
+
91
+ Attributes:
92
+ websiteURL: URL of the page containing the waiting room check.
93
+ websiteKey: Cloudflare site key.
94
+ htmlPageBase64: Base64-encoded HTML page containing the waiting room.
95
+ userAgent: Browser User-Agent string (must be from Windows OS).
96
+ proxy: Proxy settings (required).
97
+ """
98
+ type: str = Field(default="TurnstileTask")
99
+ websiteURL: str = Field(..., description='URL of the page containing the waiting room check.')
100
+ websiteKey: str = Field(..., description='Cloudflare site key.')
101
+ cloudflareTaskType: str = Field(default="wait_room", frozen=True)
102
+ htmlPageBase64: str = Field(..., description='Base64-encoded HTML page containing the waiting room.')
103
+ userAgent: str = Field(..., description='Browser User-Agent string (must be from Windows OS).')
104
+ proxy: ProxyPayload = Field(..., description='Proxy settings (required).')
105
+
106
+ def to_request(self) -> dict[str, Any]:
107
+ base = self.model_dump(exclude_none=True)
108
+ proxy_dict = base.pop("proxy", {})
109
+ if proxy_dict:
110
+ base.update(proxy_dict)
111
+ return base
@@ -0,0 +1,49 @@
1
+ from typing import Any, Optional
2
+
3
+ from pydantic import Field
4
+
5
+ from .task import TaskPayload, ProxyPayload, UserAgentPayload
6
+
7
+
8
+ class YidunTask(TaskPayload, UserAgentPayload):
9
+ """
10
+ Represents a task for solving Yidun (NECaptcha) challenges.
11
+
12
+ Attributes:
13
+ websiteURL: Full URL of the page with the captcha.
14
+ websiteKey: The siteKey value found on the page.
15
+ yidunGetLib: Path to the JS file responsible for loading the captcha (full URL).
16
+ Recommended for Enterprise versions with challenge/hcg/hct fields.
17
+ yidunApiServerSubdomain: Subdomain of the Yidun API server.
18
+ Required for custom/Enterprise servers.
19
+ challenge: Unique identifier of the current captcha (Enterprise).
20
+ hcg: Captcha hash used in the request (Enterprise).
21
+ hct: Numeric timestamp used in Enterprise version validation.
22
+ proxy: Optional proxy settings.
23
+ """
24
+ type: str = Field(default="YidunTask", frozen=True)
25
+ websiteURL: str = Field(..., description='Full URL of the page with the captcha.')
26
+ websiteKey: str = Field(..., description='The siteKey value found on the page.')
27
+ yidunGetLib: Optional[str] = Field(
28
+ default=None,
29
+ description='Path to the JS file responsible for loading the captcha (full URL).')
30
+ yidunApiServerSubdomain: Optional[str] = Field(
31
+ default=None,
32
+ description='Subdomain of the Yidun API server for custom/Enterprise servers.')
33
+ challenge: Optional[str] = Field(
34
+ default=None,
35
+ description='Unique identifier of the current captcha (Enterprise).')
36
+ hcg: Optional[str] = Field(
37
+ default=None,
38
+ description='Captcha hash used in the request (Enterprise).')
39
+ hct: Optional[int] = Field(
40
+ default=None,
41
+ description='Numeric timestamp used in Enterprise version validation.')
42
+ proxy: Optional[ProxyPayload] = Field(default=None, description='Proxy settings.')
43
+
44
+ def to_request(self) -> dict[str, Any]:
45
+ base = self.model_dump(exclude_none=True)
46
+ proxy_dict = base.pop("proxy", {})
47
+ if proxy_dict:
48
+ base.update(proxy_dict)
49
+ return base
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: capmonster_python
3
+ Version: 5.0.0
4
+ Summary: capmonster.cloud library/package for Python
5
+ Author-email: Alperen Sert <business@alperen.io>
6
+ License: MIT
7
+ Project-URL: Documentation, https://alperensert.github.io/capmonster_python/
8
+ Project-URL: Source, https://github.com/alperensert/capmonster_python/
9
+ Project-URL: Tracker, https://github.com/alperensert/capmonster_python/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: httpx>=0.27.0
20
+ Requires-Dist: pydantic>=2.0
21
+ Dynamic: license-file
22
+
23
+ # Capmonster Python
24
+
25
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster-python?style=for-the-badge)](https://pypi.org/project/capmonster-python/)
26
+ [![GitHub Release](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=for-the-badge)](https://github.com/alperensert/capmonster_python/releases)
27
+ [![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=for-the-badge)](https://github.com/alperensert/capmonster_python/commits/master)
28
+ [![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=for-the-badge&color=rgb(255%2C%20255%2C%20143)&cacheSeconds=3600)](https://github.com/alperensert/capmonster_python)
29
+
30
+ A modern, strongly-typed Python SDK for [CapMonster Cloud](https://capmonster.cloud/) — solve reCAPTCHA, Turnstile, GeeTest, and 20+ other CAPTCHA types with both sync and async support.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install capmonster_python
36
+ ```
37
+
38
+ > [!IMPORTANT]
39
+ > This is **v4** of Capmonster Python, which includes breaking changes from v3.x.
40
+ > For the legacy API: `pip install capmonster_python==3.2`
41
+
42
+ ## Quick Start
43
+
44
+ ```python
45
+ from capmonster_python import CapmonsterClient, RecaptchaV2Task
46
+
47
+ client = CapmonsterClient(api_key="YOUR_API_KEY")
48
+
49
+ task = RecaptchaV2Task(
50
+ websiteURL="https://example.com",
51
+ websiteKey="SITE_KEY_HERE"
52
+ )
53
+
54
+ result = client.solve(task)
55
+ print(result) # {"gRecaptchaResponse": "03AGdBq24..."}
56
+ ```
57
+
58
+ ### Async
59
+
60
+ ```python
61
+ import asyncio
62
+ from capmonster_python import CapmonsterClient, RecaptchaV3Task
63
+
64
+ async def main():
65
+ async with CapmonsterClient(api_key="YOUR_API_KEY") as client:
66
+ task = RecaptchaV3Task(
67
+ websiteURL="https://example.com",
68
+ websiteKey="SITE_KEY_HERE",
69
+ minScore=0.5,
70
+ pageAction="verify"
71
+ )
72
+ result = await client.solve_async(task)
73
+ print(result)
74
+
75
+ asyncio.run(main())
76
+ ```
77
+
78
+ ### With Proxy
79
+
80
+ ```python
81
+ from capmonster_python import CapmonsterClient, RecaptchaV2Task, ProxyPayload
82
+
83
+ client = CapmonsterClient(api_key="YOUR_API_KEY")
84
+
85
+ task = RecaptchaV2Task(
86
+ websiteURL="https://example.com",
87
+ websiteKey="SITE_KEY_HERE",
88
+ proxy=ProxyPayload(
89
+ proxyType="http",
90
+ proxyAddress="1.2.3.4",
91
+ proxyPort=8080,
92
+ proxyLogin="user",
93
+ proxyPassword="pass"
94
+ )
95
+ )
96
+
97
+ result = client.solve(task)
98
+ ```
99
+
100
+ ## Client API
101
+
102
+ ```python
103
+ CapmonsterClient(api_key, timeout=30.0, max_retries=120, retry_delay=2.0)
104
+ ```
105
+
106
+ | Method | Description |
107
+ |--------|-------------|
108
+ | `solve(task)` | Create task and poll until solved |
109
+ | `create_task(task)` | Create a task, returns `task_id` |
110
+ | `join_task_result(task_id)` | Poll until result is ready |
111
+ | `get_task_result(task_id)` | Single poll (no waiting) |
112
+ | `get_balance()` | Get account balance |
113
+ | `get_user_agent()` | Get current valid User-Agent string |
114
+ | `report_incorrect_image(task_id)` | Report bad image captcha solution |
115
+ | `report_incorrect_token(task_id)` | Report bad token captcha solution |
116
+
117
+ All methods have async variants with the `_async` suffix (e.g. `solve_async`, `get_balance_async`).
118
+
119
+ Both sync and async context managers are supported for proper connection cleanup.
120
+
121
+ ## Supported CAPTCHA Types
122
+
123
+ ### reCAPTCHA
124
+
125
+ | CAPTCHA Type | Class | Proxy |
126
+ |---|---|---|
127
+ | reCAPTCHA v2 | `RecaptchaV2Task` | Optional |
128
+ | reCAPTCHA v2 Enterprise | `RecaptchaV2EnterpriseTask` | Optional |
129
+ | reCAPTCHA v3 | `RecaptchaV3Task` | No |
130
+ | reCAPTCHA v3 Enterprise | `RecaptchaV3EnterpriseTask` | No |
131
+ | reCAPTCHA Click | `RecaptchaClickTask` | Optional |
132
+
133
+ ### Cloudflare
134
+
135
+ | CAPTCHA Type | Class | Proxy |
136
+ |---|---|---|
137
+ | Turnstile | `TurnstileTask` | No |
138
+ | Turnstile Challenge (cf_clearance) | `TurnstileCloudFlareTask` | Required |
139
+ | Turnstile Waiting Room | `TurnstileWaitingRoomTask` | Required |
140
+
141
+ ### Image-Based
142
+
143
+ | CAPTCHA Type | Class | Proxy |
144
+ |---|---|---|
145
+ | Image-to-Text OCR | `ImageToTextTask` | No |
146
+ | Complex Image (reCAPTCHA grid) | `ComplexImageRecaptchaTask` | No |
147
+ | Complex Image Recognition | `ComplexImageRecognitionTask` | No |
148
+
149
+ ### Behavioral / Interactive
150
+
151
+ | CAPTCHA Type | Class | Proxy |
152
+ |---|---|---|
153
+ | GeeTest v3 | `GeeTestV3Task` | Optional |
154
+ | GeeTest v4 | `GeeTestV4Task` | Optional |
155
+ | FunCaptcha (Arkose Labs) | `FunCaptchaTask` | Optional |
156
+ | Hunt | `HuntTask` | Optional |
157
+
158
+ ### Enterprise Protection
159
+
160
+ | CAPTCHA Type | Class | Proxy |
161
+ |---|---|---|
162
+ | DataDome | `DataDomeTask` | Required |
163
+ | Imperva (Incapsula) | `ImpervaTask` | Required |
164
+ | Amazon WAF | `AmazonTask` | Optional |
165
+ | TSPD | `TSPDTask` | Optional |
166
+
167
+ ### Platform-Specific
168
+
169
+ | CAPTCHA Type | Class | Proxy |
170
+ |---|---|---|
171
+ | Binance | `BinanceTask` | Required |
172
+ | Temu | `TemuTask` | No |
173
+ | TenDI | `TenDITask` | Required |
174
+
175
+ ### Other
176
+
177
+ | CAPTCHA Type | Class | Proxy |
178
+ |---|---|---|
179
+ | Altcha | `AltchaTask` | No |
180
+ | Basilisk | `BasiliskTask` | No |
181
+ | Castle | `CastleTask` | No |
182
+ | MTCaptcha | `MTCaptchaTask` | Optional |
183
+ | Prosopo | `ProsopoTask` | Optional |
184
+ | Yidun | `YidunTask` | Optional |
185
+
186
+ > Don't see your captcha type? Use `VanillaTaskPayload` to build custom task payloads without waiting for an SDK update.
187
+
188
+ ## Advanced Usage
189
+
190
+ ### Callback URLs
191
+
192
+ ```python
193
+ result = client.solve(task, callback_url="https://yoursite.com/callback")
194
+ ```
195
+
196
+ ### Report Incorrect Solutions
197
+
198
+ ```python
199
+ task_id = client.create_task(task)
200
+ result = client.join_task_result(task_id)
201
+
202
+ # If the token was rejected by the target site:
203
+ client.report_incorrect_token(task_id)
204
+ ```
205
+
206
+ ### Fresh Token Generation
207
+
208
+ Use `nocache=True` on reCAPTCHA tasks to prevent cached token reuse:
209
+
210
+ ```python
211
+ task = RecaptchaV2Task(
212
+ websiteURL="https://example.com",
213
+ websiteKey="SITE_KEY_HERE",
214
+ nocache=True
215
+ )
216
+ ```
217
+
218
+ ## Documentation
219
+
220
+ Full API reference available at [alperensert.github.io/capmonster_python](https://alperensert.github.io/capmonster_python/).
221
+
222
+ ## Support
223
+
224
+ - Found a bug? [Open an issue](https://github.com/alperensert/capmonster_python/issues)
225
+ - Contact: business@alperen.io
226
+
227
+ > [!NOTE]
228
+ > Support is limited to questions and issues related to this project. Custom integrations and application-specific logic are outside the scope of support.
229
+
230
+ ## License
231
+
232
+ [MIT License](/LICENSE)
@@ -0,0 +1,36 @@
1
+ capmonster_python/__init__.py,sha256=4ZUDfxU4KC75Yg5nCgugNb7jSdL7KhTwXN3Nr1tjguU,1069
2
+ capmonster_python/client.py,sha256=NauWFn4tHr4oLrzwmypB5wpdHSBQ8rf-U4kOKLMfV24,15045
3
+ capmonster_python/exceptions.py,sha256=D6skz5LX6PEaKv7_ApcWjknAmskR_36cHg843CHL6EI,2019
4
+ capmonster_python/methods.py,sha256=zaWW9Iqoy27h7xhZxSkkjThrLOQBGspvPZA5b-kbiAw,1288
5
+ capmonster_python/tasks/__init__.py,sha256=VBhdCHrVhC-9JcU3V87eKLphb_J34NRIGTfrriPxuoI,2098
6
+ capmonster_python/tasks/altcha.py,sha256=iHmS8sP-lUNO9fFsnFxY9dpvn2yVOcuorxDHtLbUVAg,2038
7
+ capmonster_python/tasks/amazon.py,sha256=BMVkX8E3vw0YjJQMP99ElPAuRe0ZSBs7UGEwJX4r0ww,2313
8
+ capmonster_python/tasks/basilisk.py,sha256=XrGTXEMUi0BPWK-uJ1fSdK7_SK3ep0nJojRipsue8Lc,1112
9
+ capmonster_python/tasks/binance.py,sha256=hsqJEaQrMxFQ65nUairLVKbuCAGUmJdmk2qKojbiGU4,1495
10
+ capmonster_python/tasks/castle.py,sha256=UN2cKUzu_idt8ksztcS7WndYf-pMuUs333QrLTZxA3E,1684
11
+ capmonster_python/tasks/complex_image_recaptcha.py,sha256=_6F6f3dX7IG4EuQezQtbihd0hiN8CcqapGhEbU9t8vc,3780
12
+ capmonster_python/tasks/complex_image_recognition.py,sha256=2uSNfKYmEdo3jsqQm1gzD2wnIPEDDNcH0p_CRBgBsCU,1328
13
+ capmonster_python/tasks/datadome.py,sha256=W7asQxAUqjWcDvRBPd_tCgJgwER4vfSn7whA0UQz37k,3014
14
+ capmonster_python/tasks/funcaptcha.py,sha256=G8sDAAjwji5oi1e2kgstkCBQqwfZI0K8yyZnQMaurPA,1782
15
+ capmonster_python/tasks/geetest.py,sha256=praIdVDrqQUkGzRL9Htv6GI54tVc9Ce4amj8oWjbQS0,3853
16
+ capmonster_python/tasks/hunt.py,sha256=sZux35D5xj5ne8tUwq9cAqvOtoPfmjT_kESlCMyiIV4,932
17
+ capmonster_python/tasks/image_to_text.py,sha256=HJ6XF8SDbmdunHqbNPYBf3J3ZsaD7-MusmqebW2iYII,2314
18
+ capmonster_python/tasks/imperva.py,sha256=q_SciFNxMG48DjPmnW33NnTjCRHLU2wb-rBzoM3VgZo,2289
19
+ capmonster_python/tasks/mtcaptcha.py,sha256=_eukGf4zwOO7BMExhFCpMXa8lFEkHwOvEYPc_CqQnM4,1507
20
+ capmonster_python/tasks/prosopo.py,sha256=-OzB3hU9KRfnN5UA80PbOVmPfqGpSejfmvVm00bh9ro,1004
21
+ capmonster_python/tasks/recaptcha_click.py,sha256=T3-Mi-Y8K9JUarDIg7pda7_NY-hMUNnBpUqTHekMpX8,1288
22
+ capmonster_python/tasks/recaptcha_v2.py,sha256=AWvyQAYN8xLC7xq5Tn1zphUD_8ghCFU93g_0YctcYLM,2437
23
+ capmonster_python/tasks/recaptcha_v2_enterprise.py,sha256=trATfPQWc3pG9i1KvEHY6oWRz-t8CvF7bD32MBphWps,2562
24
+ capmonster_python/tasks/recaptcha_v3.py,sha256=tBj_HvuzYj2h0CQqEvtU03SJaujFqOQWJ1EUxaOYSJ4,1877
25
+ capmonster_python/tasks/recaptcha_v3_enterprise.py,sha256=5lSGGIgkt-iG_0lCAlgOZ4YZODEp9g5H1Mk4CEGCF90,1537
26
+ capmonster_python/tasks/task.py,sha256=gdfelG_WYCOuWQyd4xyWocfUFJxq8vYja68icwBSlNo,5481
27
+ capmonster_python/tasks/temu.py,sha256=otf7CzPOeoaThXuBAkr2BFNw3sM8S26s0hSupQCgaU0,1247
28
+ capmonster_python/tasks/tendi.py,sha256=3-tlAGTnwXvFRQW5rxze1Lhv3WWWY_pokX7nBgjbu4c,1302
29
+ capmonster_python/tasks/tspd.py,sha256=peG_eHmz2hx3ZhAJ6d9xoBNPmtuOHM3uWG2bv4PWMg4,1735
30
+ capmonster_python/tasks/turnstile.py,sha256=v2RGtGfEurkigqTblIv37vwM48P4yC4s-Q0BDX8UWak,5396
31
+ capmonster_python/tasks/yidun.py,sha256=9JjIweDBrIJJE2Y_n3Efq8xkyDTQByEVViZ4BrslGqk,2162
32
+ capmonster_python-5.0.0.dist-info/licenses/LICENSE,sha256=dsx0VlJZP5DI64ranPoTdQuDmNvrABI9QNm-PctMmM4,1055
33
+ capmonster_python-5.0.0.dist-info/METADATA,sha256=WueMgNy41OTUVhMFsVKI5RDuiaGTJSIV6YRRnmXZcGA,7046
34
+ capmonster_python-5.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
35
+ capmonster_python-5.0.0.dist-info/top_level.txt,sha256=QW5VEUvOJfzDxYpD7fSJtGfUxhM3m7U7LFcZ-wRpU70,18
36
+ capmonster_python-5.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.1.0)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,150 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: capmonster_python
3
- Version: 4.0.0
4
- Summary: capmonster.cloud library/package for Python
5
- Author-email: Alperen Sert <business@alperen.io>
6
- License: MIT
7
- Project-URL: Documentation, https://alperensert.github.io/capmonster_python/
8
- Project-URL: Source, https://github.com/alperensert/capmonster_python/
9
- Project-URL: Tracker, https://github.com/alperensert/capmonster_python/issues
10
- Classifier: Development Status :: 4 - Beta
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Requires-Python: >=3.9
17
- Description-Content-Type: text/markdown
18
- License-File: LICENSE
19
- Requires-Dist: httpx>=0.27.0
20
- Requires-Dist: pydantic>=2.0
21
- Dynamic: license-file
22
-
23
- # 🤖 Capmonster Python
24
-
25
- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/capmonster-python?style=for-the-badge)
26
- ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/alperensert/capmonster_python?style=for-the-badge)
27
- ![GitHub last commit](https://img.shields.io/github/last-commit/alperensert/capmonster_python?style=for-the-badge)
28
- ![GitHub Release](https://img.shields.io/github/v/release/alperensert/capmonster_python?style=for-the-badge)
29
- ![GitHub Repo stars](https://img.shields.io/github/stars/alperensert/capmonster_python?style=for-the-badge&color=rgb(255%2C%20255%2C%20143)&cacheSeconds=3600)
30
-
31
- A modern, strongly typed, async-friendly Python SDK for solving CAPTCHA challenges
32
- using [Capmonster.Cloud](https://capmonster.cloud/).
33
-
34
- Supports reCAPTCHA v2 & v3, Cloudflare Turnstile, GeeTest (v3 & v4) and [much more](#-supported-captcha-types).
35
-
36
- ---
37
-
38
- ## ✨ Features
39
-
40
- - ✅ Fully typed Pydantic v2 models
41
- - 🔁 Both sync and async API support
42
- - 🔐 Proxy and User-Agent configuration
43
- - 📦 Supports the most common CAPTCHA types
44
- - 📚 Intuitive API with powerful task building
45
-
46
- ---
47
-
48
- ## 🔧 Installation
49
-
50
- ```bash
51
- pip install capmonster_python
52
- ```
53
-
54
- > [!IMPORTANT]
55
- > You're viewing the documentation for **Capmonster Python v4**, which includes breaking changes. If you prefer the
56
- > old syntax used in versions prior to 4.x, you can continue using it by installing the legacy version:
57
- > ```pip install capmonster_python==3.2```
58
-
59
- ## 🚀 Quick Start
60
-
61
- ### Async Example
62
-
63
- ```python
64
- import asyncio
65
- from capmonster_python import CapmonsterClient, RecaptchaV3Task
66
-
67
-
68
- async def main():
69
- client = CapmonsterClient(api_key="YOUR_API_KEY")
70
-
71
- task = RecaptchaV3Task(
72
- websiteURL="https://example.com",
73
- websiteKey="SITE_KEY_HERE",
74
- minScore=0.5,
75
- pageAction="verify"
76
- )
77
-
78
- task_id = await client.create_task_async(task)
79
- result = await client.join_task_result_async(task_id)
80
- print(result)
81
-
82
-
83
- asyncio.run(main())
84
-
85
- ```
86
-
87
- ### Sync Example
88
-
89
- ```python
90
- from capmonster_python import CapmonsterClient, RecaptchaV2Task
91
-
92
- client = CapmonsterClient(api_key="<YOUR_API_KEY>")
93
-
94
- task = RecaptchaV2Task(
95
- websiteURL="https://example.com",
96
- websiteKey="SITE_KEY_HERE"
97
- )
98
-
99
- task_id = client.create_task(task)
100
- result = client.join_task_result(task_id)
101
- print(result)
102
- ```
103
-
104
- ---
105
-
106
- ## 🧠 Supported CAPTCHA Types
107
-
108
- Capmonster Python v4 supports a wide range of CAPTCHA formats — from mainstream challenges like reCAPTCHA and Turnstile
109
- to enterprise-grade shields like Imperva and DataDome. Each task supports full Pydantic validation ✅ and both sync and
110
- async clients 🔄 unless noted.
111
-
112
- | 🔖 Category | CAPTCHA Type | Class Name | Proxy Required | Notes |
113
- |---------------------------|--------------------------------|-------------------------------|----------------|----------------------------------------|
114
- | 🧩 reCAPTCHA | reCAPTCHA v2 | `RecaptchaV2Task` | Optional | Visible / Invisible supported ✅ 🔄 |
115
- | | reCAPTCHA v2 Enterprise | `RecaptchaV2EnterpriseTask` | Optional | `enterprisePayload` & `apiDomain` ✅ 🔄 |
116
- | | reCAPTCHA v3 | `RecaptchaV3Task` | ❌ No | Score-based, proxyless ✅ 🔄 |
117
- | 🛡️ Cloudflare | Turnstile (token) | `TurnstileTask` | ❌ No | Lightweight, async-ready ✅ 🔄 |
118
- | | Turnstile (cf_clearance) | `TurnstileCloudFlareTask` | ✅ Yes | Full HTML + proxy required ✅ 🔄 |
119
- | 📸 Image-based | Image-to-Text OCR | `ImageToTextTask` | ❌ No | Base64 image + module control ✅ 🔄 |
120
- | | Complex Image (Recaptcha-like) | `ComplexImageRecaptchaTask` | ❌ No | Grid-based, metadata aware ✅ 🔄 |
121
- | | Complex Image Recognition (AI) | `ComplexImageRecognitionTask` | ❌ No | Supports tasks like Shein, OOCL ✅ 🔄 |
122
- | 🧠 Human Behavior | GeeTest v3 | `GeeTestV3Task` | Optional | Challenge + `gt` key + freshness ✅ 🔄 |
123
- | | GeeTest v4 | `GeeTestV4Task` | Optional | `initParameters` supported ✅ 🔄 |
124
- | 🛡️ Enterprise Protection | DataDome | `DataDomeTask` | ✅ Recommended | Cookie & page context needed ✅ 🔄 |
125
- | | Imperva | `ImpervaTask` | ✅ Recommended | Incapsula + Reese84 logic ✅ 🔄 |
126
- | 🏦 Platform-Specific | Binance Login | `BinanceTask` | ✅ Yes | `validateId` for login flow ✅ 🔄 |
127
- | | Temu | `TemuTask` | ❌ No | Cookie-injected behavioral solver ✅ 🔄 |
128
- | | TenDI | `TenDITask` | ✅ Yes | Custom captchaAppId field ✅ 🔄 |
129
- | 🧪 Miscellaneous | Prosopo | `ProsopoTask` | Optional | Used in zk or crypto UIs ✅ 🔄 |
130
- | | Basilisk | `BasiliskTask` | ❌ No | Minimalist site-key puzzle ✅ 🔄 |
131
-
132
- ## 🧩 Advanced Usage
133
-
134
- - Callback URLs are supported during task creation.
135
- - Includes auto-retry loop for polling results (up to 120s)
136
-
137
- ## 💬 Community & Support
138
-
139
- Need help or have a question?
140
-
141
- - 📧 Contact: business@alperen.io
142
- - 🐛 Found a bug? [Open an issue](https://github.com/alperensert/capmonster_python/issues)
143
-
144
- > [!NOTE]
145
- > Community support is intended only for questions and issues related to this project. Custom usage scenarios,
146
- > integrations, or application-specific logic are outside the scope of support.
147
-
148
- ## 📄 License
149
-
150
- This project is licensed under the [MIT License](/LICENSE).
@@ -1,26 +0,0 @@
1
- capmonster_python/__init__.py,sha256=sTATIR3QFfnAK-VAxztAxNRkN5n1Z22My7K2jm8u5P0,768
2
- capmonster_python/client.py,sha256=KLb_CO29bAYyku4_ey0lvktrHg9OsURvv9hgnxH5avA,10714
3
- capmonster_python/exceptions.py,sha256=D6skz5LX6PEaKv7_ApcWjknAmskR_36cHg843CHL6EI,2019
4
- capmonster_python/methods.py,sha256=92oASUBo2y-mTyym8irAE7YDYMMtoknZuARjfOpM8JQ,1097
5
- capmonster_python/tasks/__init__.py,sha256=ecsxM396mEwjvNiW8WlWBL3ca1d6t1d2rGFVrqUiKKM,1362
6
- capmonster_python/tasks/basilisk.py,sha256=XrGTXEMUi0BPWK-uJ1fSdK7_SK3ep0nJojRipsue8Lc,1112
7
- capmonster_python/tasks/binance.py,sha256=hsqJEaQrMxFQ65nUairLVKbuCAGUmJdmk2qKojbiGU4,1495
8
- capmonster_python/tasks/complex_image_recaptcha.py,sha256=_6F6f3dX7IG4EuQezQtbihd0hiN8CcqapGhEbU9t8vc,3780
9
- capmonster_python/tasks/complex_image_recognition.py,sha256=2uSNfKYmEdo3jsqQm1gzD2wnIPEDDNcH0p_CRBgBsCU,1328
10
- capmonster_python/tasks/datadome.py,sha256=W7asQxAUqjWcDvRBPd_tCgJgwER4vfSn7whA0UQz37k,3014
11
- capmonster_python/tasks/geetest.py,sha256=praIdVDrqQUkGzRL9Htv6GI54tVc9Ce4amj8oWjbQS0,3853
12
- capmonster_python/tasks/image_to_text.py,sha256=HJ6XF8SDbmdunHqbNPYBf3J3ZsaD7-MusmqebW2iYII,2314
13
- capmonster_python/tasks/imperva.py,sha256=q_SciFNxMG48DjPmnW33NnTjCRHLU2wb-rBzoM3VgZo,2289
14
- capmonster_python/tasks/prosopo.py,sha256=-OzB3hU9KRfnN5UA80PbOVmPfqGpSejfmvVm00bh9ro,1004
15
- capmonster_python/tasks/recaptcha_v2.py,sha256=e9voTnf_Y_0BbtW0K9KakM8F4HUsVN_NEUlfqkf_0SI,2084
16
- capmonster_python/tasks/recaptcha_v2_enterprise.py,sha256=s1rdc-FTJE0yqpoyZRHfzJoJcrFcQGhbvcThqsLhkQ0,2220
17
- capmonster_python/tasks/recaptcha_v3.py,sha256=GJYkji35aJCQ6WBfzRruUrwzReugW_Xe1WGzKe8eya4,1508
18
- capmonster_python/tasks/task.py,sha256=gdfelG_WYCOuWQyd4xyWocfUFJxq8vYja68icwBSlNo,5481
19
- capmonster_python/tasks/temu.py,sha256=otf7CzPOeoaThXuBAkr2BFNw3sM8S26s0hSupQCgaU0,1247
20
- capmonster_python/tasks/tendi.py,sha256=3-tlAGTnwXvFRQW5rxze1Lhv3WWWY_pokX7nBgjbu4c,1302
21
- capmonster_python/tasks/turnstile.py,sha256=szQR8_JdQIeSfRXJgK01yq5STMCwC6Bl4XjZnwzoe6c,4079
22
- capmonster_python-4.0.0.dist-info/licenses/LICENSE,sha256=dsx0VlJZP5DI64ranPoTdQuDmNvrABI9QNm-PctMmM4,1055
23
- capmonster_python-4.0.0.dist-info/METADATA,sha256=wegkqahJq1jlg6Uaq8JDrPMXWFVJlqPohL8IgympQMU,7147
24
- capmonster_python-4.0.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
25
- capmonster_python-4.0.0.dist-info/top_level.txt,sha256=QW5VEUvOJfzDxYpD7fSJtGfUxhM3m7U7LFcZ-wRpU70,18
26
- capmonster_python-4.0.0.dist-info/RECORD,,