How to Solve reCAPTCHA v2 and v3 via API
If you need to know how to solve reCAPTCHA in your automation, the short answer is: you send the target page's site key and URL to a recaptcha solver API, wait for a solved token, then inject that token into the page's g-recaptcha-response field and submit the form. This guide shows the exact token flow for both reCAPTCHA v2 and reCAPTCHA v3, with complete, copy-paste Python and Node.js examples against the OMOCaptcha API V2.
This is a developer tutorial for legitimate automation only QA and regression testing of your own forms, accessibility workflows, monitoring, and authorized data collection. Always respect the target site's robots.txt, Terms of Service, and rate limits.
reCAPTCHA v2 vs v3: what's the difference?
Google reCAPTCHA comes in two families, and the way you solve each differs.
- reCAPTCHA v2 - reCAPTCHA v3
User experience - Checkbox ("I'm not a robot") or image challenge - Invisible, no interaction
Output - A response token - A response token + risk score
Server check - Token valid / invalid - Score (0.0 1.0) plus an action name
You must provide - websiteURL, websiteKey - websiteURL, websiteKey, pageAction, minScore
For reCAPTCHA v2 (https://developers.google.com/recaptcha/docs/display) you get a token that the backend verifies as valid or not. For v3, Google returns a risk score together with the action that was fired; your backend decides a threshold (commonly minScore 0.3 0.7). Both cases resolve to a token solving them programmatically is the same createTask/getTaskResult pattern.
The token flow, step by step
1. Read the site key. Inspect the target page and find the data-sitekey attribute on the reCAPTCHA element that becomes websiteKey. The page URL becomes websiteURL.
2. Create a task. POST /createTask with your clientKey, the task type, and those two fields. You get back a taskId.
3. Poll for the result. POST /getTaskResult with the taskId until status is ready (or fail). Poll politely with backoff.
4. Inject and submit. Take the returned token from solution.gRecaptchaResponse, place it in the page's hidden g-recaptcha-response textarea, and submit the form (or pass it to your backend verification call).
The API always returns HTTP 200 success or failure is decided by errorId (0 means success), an AntiCaptcha-compatible envelope. A task is locked to the API key that created it, so poll with the same clientKey.
Solve reCAPTCHA v2 in Python
Here is a complete example to solve reCAPTCHA v2 using requests. It creates the task, polls with backoff, and returns the token. This is also the cleanest way to handle a bypass reCAPTCHA python workflow in your own test suite.
import time
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.omocaptcha.com/v2"
def solve_recaptcha_v2(website_url: str, website_key: str) -> str:
# 1. Create the task
create = requests.post(
f"(BASE)/createTask",
json=(
"clientKey": API_KEY,
"task": (
"type": "RecaptchaV2TokenTask",
"websiteURL": website_url,
"websiteKey": website_key,
),
),
timeout=30,
).json()
if create.get("errorId") != 0:
raise RuntimeError(f"createTask failed: (create.get('errorCode')) - (create.get('errorDescription'))")
task_id = create["taskId"]
# 2. Poll for the result with backoff
delay = 3
for _ in range(20):
time.sleep(delay)
result = requests.post(
f"(BASE)/getTaskResult",
json=("clientKey": API_KEY, "taskId": task_id),
timeout=30,
).json()
if result.get("errorId") != 0:
raise RuntimeError(f"getTaskResult failed: (result.get('errorCode'))")
status = result.get("status")
if status == "ready":
return result["solution"]["gRecaptchaResponse"]
if status == "fail":
raise RuntimeError("Task failed to solve")
delay = min(delay + 2, 10) # gentle backoff
raise TimeoutError("Timed out waiting for the captcha token")
if __name__ == "__main__":
token = solve_recaptcha_v2(
"https://example.com/login",
"6LxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYOUR_KEY",
)
print("g-recaptcha-response:", token)
Solve reCAPTCHA v2 in Node.js
The same flow with native fetch (Node.js 18+). No external dependencies required.
const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.omocaptcha.com/v2";
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function post(path, body) (
const controller = new AbortController();
const t = setTimeout(() => controller.abort(), 30000);
try (
const res = await fetch(`$(BASE)$(path)`, (
method: "POST",
headers: ( "Content-Type": "application/json" ),
body: JSON.stringify(body),
signal: controller.signal,
));
return await res.json();
) finally (
clearTimeout(t);
)
)
async function solveRecaptchaV2(websiteURL, websiteKey) (
const create = await post("/createTask", (
clientKey: API_KEY,
task: ( type: "RecaptchaV2TokenTask", websiteURL, websiteKey ),
));
if (create.errorId !== 0) (
throw new Error(`createTask failed: $(create.errorCode) - $(create.errorDescription)`);
)
const taskId = create.taskId;
let delay = 3000;
for (let i = 0; i < 20; i++) (
await sleep(delay);
const result = await post("/getTaskResult", ( clientKey: API_KEY, taskId ));
if (result.errorId !== 0) throw new Error(`getTaskResult failed: $(result.errorCode)`);
if (result.status === "ready") return result.solution.gRecaptchaResponse;
if (result.status === "fail") throw new Error("Task failed to solve");
delay = Math.min(delay + 2000, 10000);
)
throw new Error("Timed out waiting for the captcha token");
)
solveRecaptchaV2(
"https://example.com/login",
"6LxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYOUR_KEY"
).then((token) => console.log("g-recaptcha-response:", token));
Once you have the token, inject it into the page:
document.querySelector('textarea[name="g-recaptcha-response"]').value = token;
// then submit the form your backend expects
How to solve reCAPTCHA v3 (action + minScore)
To solve reCAPTCHA v3 you use the same createTask/getTaskResult flow, but v3 is score-based, so you pass the action that the page fires and a minScore threshold. Use a v3 task type and read the token from the solution:
"task": (
"type": "RecaptchaV3TokenTask",
"websiteURL": "https://example.com/checkout",
"websiteKey": "6LxxxxxxxxxxxxxxxxxxxxxxxYOUR_V3_KEY",
"pageAction": "checkout", # must match the action the site uses
"minScore": 0.7 # 0.3 / 0.5 / 0.7 are common
)
Note: RecaptchaV3TokenTask and its field names should be confirmed against the current OMOCaptcha API docs before production use. The v2 flow above (RecaptchaV2TokenTask solution.gRecaptchaResponse) is the confirmed contract.
A higher minScore costs a little more effort but returns a token that passes stricter backend checks. Match the pageAction exactly to what the target site declares, or the score will be discounted server-side.
Why use a recaptcha solver API instead of rolling your own
Building an in-house solver means maintaining models for every captcha variant. A dedicated recaptcha solver API gives you one endpoint and predictable pricing. OMOCaptcha solves reCAPTCHA and 13 other captcha systems through the same API, with a 0.42s average solve time and up to 99% accuracy AI-only, so there is no human-farm queue delay.
Pricing starts from $0.27 per 1000 for reCAPTCHA v2, and reCAPTCHA v3 is supported through the same flow. See the full captcha solver API pricing (https://blog.omocaptcha.com/captcha-solver-api-pricing) breakdown, or compare providers in our best captcha solving service 2026 (https://blog.omocaptcha.com/best-captcha-solving-service-2026) roundup. New to the API? Start with the captcha solver API quickstart (https://blog.omocaptcha.com/captcha-solver-api-quickstart).
Solving other captcha types uses the identical pattern see how to solve hCaptcha (https://blog.omocaptcha.com/how-to-solve-hcaptcha) or the Cloudflare Turnstile solver (https://blog.omocaptcha.com/cloudflare-turnstile-solver) guide.
Responsible use
Solve captchas only on systems you own or are authorized to automate: your own QA and regression suites, accessibility tooling, uptime monitoring, load testing, and contracted data collection. Honor robots.txt, ToS, and rate limits. Do not use captcha automation for fraud, mass fake-account creation, or ban evasion.
FAQ
How do I find the reCAPTCHA site key?
Open the target page, inspect the reCAPTCHA element, and read the data-sitekey attribute (v3 keys are also visible in the grecaptcha.execute call). That value is your websiteKey; the page address is your websiteURL.
How long does it take to solve a reCAPTCHA token?
With OMOCaptcha the average solve time is 0.42 seconds. Because the API is fully AI-driven there is no human worker queue, so polling with a 3-second initial interval and gentle backoff is usually enough.
Can I solve reCAPTCHA v3 with the same API?
Yes. reCAPTCHA v3 uses the same createTask/getTaskResult flow; you additionally pass the pageAction and a minScore threshold, then read the returned token from the solution object.
Which languages are supported?
OMOCaptcha ships six SDKs Python, JavaScript/Node.js, PHP, Java, .NET, and Go but any language that can make an HTTPS POST works, as shown in the examples above.
Is my data kept private?
Yes. OMOCaptcha uses end-to-end encryption and does not store captcha content or log customer data. Tasks are also key-bound, so only the API key that created a task can read its result.
Get started with 1000 free solves
Ready to solve reCAPTCHA in your own automation? Create an account and get 1000 free solves to test the token flow end to end. If your success rate ever drops below 95%, you get a full refund. Explore the OMOCaptcha platform (https://omocaptcha.com/en?utm_source=blog&utm_medium=organic) or jump straight to pricing (https://omocaptcha.com/en#pricing).
Questions about integration? Email us any time at support@omocaptcha.com support is available 24/7. |