DEV Community

Gloria
Gloria

Posted on

A Guide to Using SolveCaptcha

1. What is SolveCaptcha

  • SolveCaptcha is a hybrid human + AI CAPTCHA-solving service: simple CAPTCHAs may be solved via automated algorithms, and harder ones are handled by human workers.
  • It supports many CAPTCHA types: image/text CAPTCHAs, reCAPTCHA v2 / v3, FunCaptcha, Cloudflare Turnstile, Amazon WAF, etc.
  • You integrate via their API: you upload a CAPTCHA task, poll (or use a callback) until solved, then retrieve the result.

2. Basic Workflow / API Steps

Here’s the general flow:

1. Obtain API Key — after registering on SolveCaptcha, you get an API key.
2. Create a Task — send a request describing the CAPTCHA (site URL, sitekey, image, etc.).
3. Poll for Result (or use callback/webhook) — repeatedly check if the CAPTCHA is solved.
4. Receive Solution — once solved, get the answer (text, token, coordinates, etc.).

  1. Use / Submit that solution in your automation or web flow.
  2. (Optional) Report whether the solution was correct (for quality feedback).

The API uses endpoints like /api/createTask and /api/getTaskResult (or equivalents) — see docs for precise URLs.

3. API: CreateTask & GetTaskResult — JSON API

Below is a synthesized example based on SolveCaptcha’s documentation structure. (Note: official docs use solvecaptcha.net in places too.)
solvecaptcha.net

3.1. createTask (POST)

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

  • Request body (“task” object describes CAPTCHA type):

Example – solving a reCAPTCHA V2:

{
"task": {
"method": "RecaptchaV2Task",
"page_url": "https://example.com/page-with-recaptcha",
"site_key": "your_recaptcha_site_key"
},
"affiliate_id": 0
}

  • Response:

{
"error_id": 0,
"task_id": 1234567
}

Or, on error:

{
"error_id": 1,
"error_code": "ERROR_KEY_DOES_NOT_EXIST",
"error_description": "Account authorization key not found"
}

3.2. getTaskResult (POST)

- Endpoint: https://solvecaptcha.net/api/getTaskResult
- Method: POST
- Headers:

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

- Request body:

{
"task_id": 1234567
}

- Possible responses:

If still being solved:

{
"error_id": 0,
"status": "processing",
"request": "CAPCHA_NOT_READY"
}

  • When solved:

{
"error_id": 0,
"status": "ready",
"request": {
"solution": "the_captcha_answer"
}
}

  • On error:

{
"error_id": 1,
"error_code": "...",
"error_description": "..."
}

4. Code Examples

Here are sample integrations in a few languages, demonstrating how to create a task and poll for the result.

*4.1 Python (using official solvecaptcha-python SDK) *

`from solvecaptcha import Solvecaptcha
import time

API_KEY = "YOUR_API_KEY"
solver = Solvecaptcha(API_KEY)

def solve_recaptcha_v2(site_key: str, page_url: str):
# Submit a reCAPTCHA V2 solving task
result = solver.recaptcha(sitekey=site_key, url=page_url)
# result is the solved token (string)
return result

def solve_image_captcha(image_path: str):
result = solver.normal(image_path)
return result # text answer

if name == "main":
site_key = "6Le…your_site_key…"
url = "https://example.com/with/recaptcha"
try:
token = solve_recaptcha_v2(site_key, url)
print("reCAPTCHA token:", token)
except Exception as exc:
print("Error solving:", exc)`

If you don’t use the convenience methods, you could use solver.send() + solver.get_result():

`task = {
"method": "RecaptchaV2Task",
"page_url": url,
"site_key": site_key
}
response = solver.send(task)
task_id = response["task_id"]

Poll:

while True:
time.sleep(5)
res = solver.get_result(task_id)
if res.get("status") == "ready":
solution = res["request"]["solution"]
print("Solved:", solution)
break`

4.2 JavaScript / Node.js (using HTTP requests)
`const axios = require("axios");

const API_KEY = "YOUR_API_KEY";

async function createTask(taskPayload) {
const url = "https://solvecaptcha.net/api/createTask";
const resp = await axios.post(url, {
task: taskPayload
}, {
headers: {
"Content-Type": "application/json",
"Authorization": Bearer ${API_KEY}
}
});
return resp.data;
}

async function getTaskResult(task_id) {
const url = "https://solvecaptcha.net/api/getTaskResult";
const resp = await axios.post(url, {
task_id: task_id
}, {
headers: {
"Content-Type": "application/json",
"Authorization": Bearer ${API_KEY}
}
});
return resp.data;
}

async function solveRecaptchaV2(site_key, page_url) {
const create = await createTask({
method: "RecaptchaV2Task",
page_url: page_url,
site_key: site_key
});
if (create.error_id !== 0) {
throw new Error("Create task failed: " + create.error_description);
}
const task_id = create.task_id;

while (true) {
await new Promise(r => setTimeout(r, 5000));
const result = await getTaskResult(task_id);
if (result.error_id !== 0) {
throw new Error("Error in getTaskResult: " + result.error_description);
}
if (result.status === "ready") {
return result.request.solution;
}
// else status = "processing", continue looping
}
}

// Usage:
solveRecaptchaV2("SITE_KEY_HERE", "https://example.com").then(token => {
console.log("Got token:", token);
}).catch(err => {
console.error("Failed:", err);
});`

4.3 Java (using solvecaptcha-java library)

`import com.solvecaptcha.Solvecaptcha;

public class RecaptchaSolver {
public static void main(String[] args) throws Exception {
String apiKey = "YOUR_API_KEY";
Solvecaptcha solver = new Solvecaptcha(apiKey);
solver.setHost("solvecaptcha.com");
solver.setDefaultTimeout(120);
solver.setRecaptchaTimeout(600);
solver.setPollingInterval(10);

    String siteKey = "6Le…your_site_key…";
    String pageUrl = "https://example.com/with/recaptcha";

    // Solve reCAPTCHA v2
    String token = solver.recaptcha(siteKey, pageUrl);
    System.out.println("Got reCAPTCHA token: " + token);
}
Enter fullscreen mode Exit fullscreen mode

}`

  1. Special / Advanced Use Cases & Tips

- Callback / Webhook mode: Instead of continuously polling getTaskResult, you can set up a callback URL. When you define callback in your solver configuration, methods return immediately with just the task_id and the service sends the result to your server later.

- Extended response: For more complex captchas (e.g. ClickCaptcha, hCaptcha), you may set extendedResponse = True (or 1) to receive extra metadata (e.g. coordinates, user agent, etc.).

- Timeouts / polling interval: Don’t poll too frequently (e.g. every second); typical polling intervals are 5–10 seconds. Also set per-captcha timeouts to avoid hanging forever.

- Error handling / retries: Always check for error_id != 0 and handle issues like invalid API key, CAPTCHA type mismatch, or “no slot available.”

- Proxies, user agents: Some CAPTCHA types require you to pass proxy or user agent data to simulate the correct client environment.

- Rate / cost awareness: Each CAPTCHA type has its own rate (cost) per 1,000 solves (image, reCAPTCHA, etc.).
solvecaptcha.com

- Respect terms: Use the service ethically and in compliance with all websites’ terms of service, laws, and regulations.

6. Example: reCAPTCHA + Selenium + SolveCaptcha (Python)

Here’s a more integrated example using Selenium to navigate a page, detect a reCAPTCHA, solve via SolveCaptcha, and inject the token.

`from selenium import webdriver
from selenium.webdriver.common.by import By
from solvecaptcha import Solvecaptcha
import time

API_KEY = "YOUR_API_KEY"
solver = Solvecaptcha(API_KEY)

driver = webdriver.Chrome()

try:
driver.get("https://example.com/page-with-recaptcha")
# Locate the site key (inspect page HTML)
site_key = driver.find_element(By.CSS_SELECTOR, "div.g-recaptcha").get_attribute("data-sitekey")

# Create solve task
token = solver.recaptcha(sitekey=site_key, url=driver.current_url)

# Inject token into page (hidden textarea or form field)
driver.execute_script(f"document.getElementById('g-recaptcha-response').innerHTML = '{token}';")
# Optionally trigger any callback
driver.execute_script("___grecaptcha_cfg.clients[0].Z.Z.callback('" + token + "');")

# Submit form
driver.find_element(By.CSS_SELECTOR, "form").submit()

time.sleep(5)
print("Submitted form, current URL:", driver.current_url)
Enter fullscreen mode Exit fullscreen mode

finally:
driver.quit()`

Top comments (0)