Code examples
This page contains minimal runnable examples for the official SDKs. Parameters for individual task types are documented under Captcha types.
Python SDK#
Install the package:
pip install captcha-solver-api
Set the CAPTCHA_API_KEY environment variable before running the example.
Synchronous example#
import os
from captcha_solver_api import CaptchaClient
from captcha_solver_api.tasks import RecaptchaV2TaskProxyless
task = RecaptchaV2TaskProxyless(
websiteURL="https://example.com/login",
websiteKey="YOUR_WEBSITE_KEY",
)
with CaptchaClient(os.environ["CAPTCHA_API_KEY"]) as client:
solution = client.solve(task)
print(solution["gRecaptchaResponse"])
Asynchronous example#
import asyncio
import os
from captcha_solver_api import AsyncCaptchaClient
from captcha_solver_api.tasks import RecaptchaV2TaskProxyless
async def main():
task = RecaptchaV2TaskProxyless(
websiteURL="https://example.com/login",
websiteKey="YOUR_WEBSITE_KEY",
)
async with AsyncCaptchaClient(os.environ["CAPTCHA_API_KEY"]) as client:
solution = await client.solve(task)
print(solution["gRecaptchaResponse"])
asyncio.run(main())
All Python SDK examples on GitHub
JavaScript SDK#
Install the published package from npm:
npm install @captcha-solver-api/javascript-sdk
Set the CAPTCHA_API_KEY environment variable before running the example.
import { CaptchaClient, Tasks } from "@captcha-solver-api/javascript-sdk";
const client = new CaptchaClient({
clientKey: process.env.CAPTCHA_API_KEY,
});
const task = new Tasks.RecaptchaV2Proxyless({
websiteURL: "https://example.com/login",
websiteKey: "YOUR_WEBSITE_KEY",
});
try {
const solution = await client.solve(task);
console.log(solution.gRecaptchaResponse);
} catch (error) {
console.error(error);
}
All JavaScript SDK examples on GitHub
Other captcha types#
Replace the task class and its parameters in the examples above. Available classes and required parameters are listed under Captcha types.