Control¶
To import this module:
from python3_capsolver.control import Control
- class python3_capsolver.control.Control(api_key: str)¶
The class is used to work with Capsolver control methods.
- Parameters:
api_key (str) – Capsolver API key
Notes
https://docs.capsolver.com/en/guide/api-getbalance/
https://docs.capsolver.com/en/guide/api-gettaskresult/
- get_balance() dict ¶
Synchronous method to view the balance
Examples
>>> from python3_capsolver.control import Control >>> Control(api_key="CAI-1324...").get_balance() {'balance': 48.6361, 'errorId': 0, 'packages': []}
- Returns:
Dict with full server response
- Return type:
dict
Notes
Check class docstring for more info
- async aio_get_balance() dict ¶
Asynchronous method to view the balance
Examples
>>> import asyncio >>> from python3_capsolver.control import Control >>> asyncio.run(Control(api_key="CAI-1324...").aio_get_balance()) {'balance': 48.6361, 'errorId': 0, 'packages': []}
- Returns:
Dict with full server response
- Return type:
dict
Notes
Check class docstring for more info
- create_task(task_payload: Dict) dict ¶
Synchronous method to send custom
createTask
request.This is the custom analog for prepared captcha solving classes. With this method u can create task with custom type and get response with task solution or task ID (depends on task type). The main difference with
captcha_handler
methods - there is no retries logic and other sugar.- Parameters:
task_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikewebsiteURL
,image
,proxyPassword
,websiteKey
and etc. more info in service docs
Examples
>>> from python3_capsolver.control import Control >>> Control(api_key="CAI-1324...").get_task_result( ... task_payload={ ... "type": "VisionEngine", ... "image": "base64_image_body", ... "question": "click on the object", ... "module": "space_detection", ... } ... ) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "userAgent": "xxx", "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- async aio_create_task(task_payload: Dict) dict ¶
Asynchronous method to send custom
createTask
request.This is the custom analog for prepared captcha solving classes. With this method u can create task with custom type and get response with task solution or task ID (depends on task type). The main difference with
captcha_handler
methods - there is no retries logic and other sugar.- Parameters:
task_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikewebsiteURL
,image
,proxyPassword
,websiteKey
and etc. more info in service docs
Examples
>>> import asyncio >>> from python3_capsolver.control import Control >>> asyncio.run(Control(api_key="CAI-1324...") ... .aio_create_task( ... task_payload={ ... "type": "VisionEngine", ... "image": "base64_image_body", ... "question": "click on the unique object", ... "module": "space_detection", ... } ... )) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "userAgent": "xxx", "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- get_task_result(task_id: str) dict ¶
Synchronous method to send
getTaskResult
request- Parameters:
task_id (str) – Task ID
Examples
>>> from python3_capsolver.control import Control >>> Control(api_key="CAI-1324...").get_task_result(task_id="db0a3153-xxxx") { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "userAgent": "xxx", "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- async aio_get_task_result(task_id: str) dict ¶
Synchronous method to send
getTaskResult
request- Parameters:
task_id (str) – Task ID
Examples
>>> import asyncio >>> from python3_capsolver.control import Control >>> asyncio.run(Control(api_key="CAI-1324...") ... .aio_get_task_result(task_id="db0a3153-xxxx")) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "userAgent": "xxx", "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- get_token(task_payload: Dict) dict ¶
Synchronous method to send custom
getToken
request.- Parameters:
task_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikewebsiteURL
,image
,proxyPassword
,websiteKey
and etc. more info in service docs
Examples
>>> from python3_capsolver.control import Control >>> Control(api_key="CAI-1324...").get_token( ... task_payload={ ... "type": "ReCaptchaV3TaskProxyLess", ... "websiteURL": "https://demo.com/", ... "websiteKey": "6LcpsXsnAAAbbAcxxxx" ... } ... ) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- async aio_get_token(task_payload: Dict) dict ¶
Asynchronous method to send custom
getToken
request.- Parameters:
task_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
task
key. LikewebsiteURL
,image
,proxyPassword
,websiteKey
and etc. more info in service docs
Examples
>>> import asyncio >>> from python3_capsolver.control import Control >>> asyncio.run(Control(api_key="CAI-1324...") ... .aio_get_token( ... task_payload={ ... "type": "ReCaptchaV3TaskProxyLess", ... "websiteURL": "https://demo.com/", ... "websiteKey": "6LcpsXsnAAAbbAcxxxx" ... } ... )) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "taskId": "db0a3153-xxxx", "status":"ready", "solution": { "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW-xxxx" }, }
- Returns:
Dict with full server response
- Return type:
dict
- feedback_task(task_id: str, result_payload: Dict) dict ¶
Synchronous method to send custom
feedbackTask
request.- Parameters:
task_id (str) – Task ID to report
result_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
result
key. Likeinvalid
,code
,message
and etc. more info in service docs
Examples
>>> from python3_capsolver.control import Control >>> Control(api_key="CAI-1324...").feedback_task( ... task_id="db0a3153-xxxx", ... result_payload={ ... "invalid": True, ... "code": 1001, ... "message": "invalid token" ... } ... ) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "message": "okay" }
- Returns:
Dict with full server response
- Return type:
dict
- async aio_feedback_task(task_id: str, result_payload: Dict) dict ¶
Asynchronous method to send custom
feedbackTask
request.- Parameters:
task_id (str) – Task ID to report
result_payload (Dict) – Some additional parameters that will be used in creating the task and will be passed to the payload under
result
key. Likeinvalid
,code
,message
and etc. more info in service docs
Examples
>>> import asyncio >>> from python3_capsolver.control import Control >>> asyncio.run(Control(api_key="CAI-1324...") ... .aio_feedback_task( ... task_id="db0a3153-xxxx", ... result_payload={ ... "invalid": True, ... "code": 1001, ... "message": "invalid token" ... } ... )) { "errorId": 0, "errorCode":"None", "errorDescription":"None", "message": "okay" }
- Returns:
Dict with full server response
- Return type:
dict