Skip to content

feat: add Yandex SmartCaptcha Kaleidoscope support - #26

Merged
dariyaanis merged 5 commits into
mainfrom
feat/yandex-smartcaptcha-kaleidoscope
Nov 18, 2026
Merged

dariyaanis merged 5 commits into
mainfrom
feat/yandex-smartcaptcha-kaleidoscope

Conversation

@dariyaanis

@dariyaanis dariyaanis commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add YandexSmartCaptchaKaleidoscopeTask for the API v2 PazlCaptchaTask type
  • support the Kaleidoscope string solution containing the required slider-arrow click count in both sync and async clients
  • add required-field validation and sync/async solution tests
  • add runnable sync and async examples using the working puzzle steps and bundled sample image
  • document the task parameters, response type, examples, and supported CAPTCHA table

API

import base64

from captcha_solver_api import CaptchaClient
from captcha_solver_api.tasks import YandexSmartCaptchaKaleidoscopeTask

with open("examples/assets/yandex-smartcaptcha-kaleidoscope.jpg", "rb") as image_file:
    image = base64.b64encode(image_file.read()).decode("utf-8")

task = YandexSmartCaptchaKaleidoscopeTask(
    image=image,
    task="[15,24,4,13,10]",
)

clicks = CaptchaClient("YOUR_API_KEY").solve(task)
print(clicks)

The task is serialized as:

{
  "type": "PazlCaptchaTask",
  "image": "BASE64_IMAGE",
  "task": "[15,24,4,13,10]"
}

The API returns a string such as "8", representing the number of slider-arrow clicks required to solve the puzzle.

Examples

  • python examples/sync/yandex_smartcaptcha_kaleidoscope.py
  • python examples/async/yandex_smartcaptcha_kaleidoscope.py

Both examples use examples/assets/yandex-smartcaptcha-kaleidoscope.jpg and the full puzzle-step sequence from the working request.

Testing

  • python -m pytest -q -p no:cacheprovider — 127 passed
  • python -m ruff check . — passed
  • python -m compileall -q captcha_solver_api examples tests — passed
  • python -m build — wheel and source distribution built successfully

@dzmitry-duboyski

Copy link
Copy Markdown
Contributor

@dariyaanis Thanks for the PR! The new task type is well put together - tests, sync/async examples and docs are all there, and pytest, ruff and mypy pass locally. A few things to address before merging:

Required

1. solve() return type changed to Any - captcha_solver_api/client.py:248, captcha_solver_api/async_client.py:265

Changing the return type from Dict[str, Any] to Any removes type checking of the solve() result for every user, not just Kaleidoscope ones. Suggest Union[Dict[str, Any], str] instead - it keeps the types honest and makes it explicit that the result needs narrowing. Open to other ideas if you have a better option.

2. Empty string is accepted as a valid solution - captcha_solver_api/client.py:313, captcha_solver_api/async_client.py:335

If the API returns "solution": "", the isinstance(solution, (dict, str)) check lets it through and solve() returns "" as a successful result. Please treat an empty string as an invalid response and raise NetworkError, same as for other malformed solutions, and add a test for this case.

Optional (nit)

3. task accepts only a JSON string - captcha_solver_api/tasks.py:957

Users will likely pass a plain list ([15, 24, 4]), which would be sent to the API as an array instead of a string. Consider accepting Union[str, List[int]] and serializing lists with json.dumps, or raising ValidationError for non-string values.

Note

This PR conflicts with #27 (debug mode) in client.py and async_client.py. I suggest merging this one first and then rebasing #27 on top of it.

@dariyaanis
dariyaanis merged commit 44ec2b9 into main Nov 18, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants