YandexCaptcha: solving Yandex SmartCaptcha
TIP
Create the task with the createTask method and get the result with the getTaskResult method.
The task type types
that we support:
YandexCaptchaTaskProxyLess
Create Task
Create a recognition task with the createTask method.
Task Object Structure
Properties | Type | Required | Description |
---|---|---|---|
type | String | Required | YandexCaptchaTaskProxyLess |
websiteURL | String | Required | The page address, where the Yandex SmartCaptcha is solved |
websiteKey | String | Required | website key |
Example Request
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "YandexCaptchaTaskProxyLess",
"websiteURL": "https://www.yourtarget.com/",
"websiteKey": "ysc1_bFdbbET5WBnPTvoE5jTXYrvdbT60MdQ31nhVV5wUa8027fe5"
}
}
After you submit the task to us, you should receive in the response a ‘taskId’ if it’s successful. Please read errorCode: full list of errors if you didn’t receive the task id.
Example Response
{
"errorId": 0,
"errorDescription": "",
"status": "idle",
"taskId": "e33d4a64-a048-4da8-9f92-5d2d0c013075"
}
Getting Results
After you have the taskId, you need to submit the taskId to retrieve the solution. Response structure is explained in getTaskResult.
Example Request
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"taskId": "e33d4a64-a048-4da8-9f92-5d2d0c013075"
}
Example Response
{
"errorId": 0,
"taskId": "e33d4a64-a048-4da8-9f92-5d2d0c013075",
"status": "ready",
"solution": {
"token": "dD0xNzMzMjc0MjkzO2k9NDUuMy41OS41NztEPTVCRUNDQzUxNT..."
}
}
Sample Code
# pip install requests
import requests
import time
# TODO: set your config
api_key = "YOUR_API_KEY" # your api key of capsolver
site_key = "ysc1_bFdbbET5WBnPTvoE5jTXYrvdbT60MdQ31nhVV5wUa8027fe5" # site key of your target site
site_url = "https://www.yourtarget.com" # page url of your target site
def capsolver():
payload = {
"clientKey": api_key,
"task": {
"type": 'YandexCaptchaTaskProxyLess',
"websiteKey": site_key,
"websiteURL": site_url
}
}
res = requests.post("https://api.capsolver.com/createTask", json=payload)
resp = res.json()
task_id = resp.get("taskId")
if not task_id:
print("Failed to create task:", res.text)
return
print(f"Got taskId: {task_id} / Getting result...")
while True:
time.sleep(1) # delay
payload = {"clientKey": api_key, "taskId": task_id}
res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
resp = res.json()
status = resp.get("status")
if status == "ready":
return resp.get("solution", {}).get('token')
if status == "failed" or resp.get("errorId"):
print("Solve failed! response:", res.text)
return
token = capsolver()
print(token)