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 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. Whether you need to solve captcha challenges for a QA suite or for synthetic monitoring, the same token flow applies to both reCAPTCHA generations. 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:
- User experience: checkbox ("I'm not a robot") or image challenge
- Output: a response token
- Server check: token valid or invalid
- You must provide: websiteURL, websiteKey
reCAPTCHA v3:
- User experience: invisible, no interaction
- Output: a response token plus a risk score
- Server check: score (0.0-1.0) plus an action name
- You must provide: 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), following the standard two-step createTask/getTaskResult 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(
BASE + "/createTask",
json=dict(
clientKey=API_KEY,
task=dict(
type="RecaptchaV2TokenTask",
websiteURL=website_url,
websiteKey=website_key,
),
),
timeout=30,
).json()
if create.get("errorId") != 0:
raise RuntimeError("createTask failed: " + str(create.get("errorCode")) + " - " + str(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(
BASE + "/getTaskResult",
json=dict(clientKey=API_KEY, taskId=task_id),
timeout=30,
).json()
if result.get("errorId") != 0:
raise RuntimeError("getTaskResult failed: " + str(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 Python: alternative example (standard library only)
The same flow using only Python's built-in urllib module. No external dependencies required.
import json
import time
import urllib.request
API_KEY = "YOUR_API_KEY"
BASE = "https://api.omocaptcha.com/v2"
def post_json(path, body, timeout=30):
data = json.dumps(body).encode("utf-8")
headers = dict([("Content-Type", "application/json")])
req = urllib.request.Request(BASE + path, data=data, headers=headers, method="POST")
with urllib.request.urlopen(req, timeout=timeout) as resp:
return json.loads(resp.read().decode("utf-8"))
def solve_recaptcha_v2(website_url, website_key):
create = post_json("/createTask", dict(
clientKey=API_KEY,
task=dict(type="RecaptchaV2TokenTask", websiteURL=website_url, websiteKey=website_key),
))
if create.get("errorId") != 0:
raise RuntimeError("createTask failed: " + str(create.get("errorCode")) + " - " + str(create.get("errorDescription")))
task_id = create["taskId"]
delay = 3
for _ in range(20):
time.sleep(delay)
result = post_json("/getTaskResult", dict(clientKey=API_KEY, taskId=task_id))
if result.get("errorId") != 0:
raise RuntimeError("getTaskResult failed: " + str(result.get("errorCode")))
if result.get("status") == "ready":
return result["solution"]["gRecaptchaResponse"]
if result.get("status") == "fail":
raise RuntimeError("Task failed to solve")
delay = min(delay + 2, 10) # gentle backoff
raise TimeoutError("Timed out waiting for the captcha token")
token = solve_recaptcha_v2(
"https://example.com/login",
"6LxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYOUR_KEY",
)
print("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 = dict(
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 CAPTCHA API - like OMOCaptcha's 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. It is 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.
Signer le livre d'or