All posts

Captcha solver API for scraping: Playwright guide

How does a captcha solver API for scraping work? You send the type, URL and sitekey, get a token back, and apply it once. Get the Playwright code and limits.

  • captcha solver api
  • web scraping
  • playwright
  • recaptcha
  • cloudflare turnstile
On this page

A captcha solver API for scraping takes a task (captcha type, page URL, sitekey) and returns a token or text, which you apply to the page before submitting. Fix browser identity and exit consistency first so fewer captchas appear, then solve what remains. Per Wayfern’s pricing, POST /api/captcha/solve costs 1 credit per successful solve; failed solves cost nothing.

This is for developers whose Playwright or Puppeteer scrapers stall mid-run when a reCAPTCHA or Cloudflare Turnstile widget replaces the expected page. The selector never appears, the timeout fires, and the queue stops moving.

Afterward you can run a detect, solve, apply, submit loop in a live browser session over CDP, model rate limits and cost per solve, and decide when a standalone specialist fits better.

Key Takeaways

  • Apply a token once, before it expires, from a consistent exit.
  • Per Wayfern’s limits docs, the captcha rate limit is 20 requests a minute, so 20 solves a minute is your ceiling.
  • At 1 credit per successful solve and $0.0125 per credit on Wayfern’s pricing, 1,000 solves are 1,000 credits, or $12.50.
  • Page time and retries count toward cost per page even when failed solves are free.

Why do captchas appear while scraping, and how do you see fewer?

A captcha appears when a site’s anti-bot system rates a request as risky, and three signals drive that rating: the exit IP, the request pattern, and the browser identity.

A robotic arm solves a puzzle wall, allowing data to flow from a complex digital structure to a server stack.

  • Exit: a datacenter range that has already sent automated traffic starts with a weaker reputation than a residential address.
  • Pattern: hundreds of page loads a minute from one address, with no gaps and no pauses, looks like a script because it is one.
  • Identity: values that contradict each other get flagged, such as a window.outerWidth that doesn’t match screen.width.

Cookies and IPs have to match as well. Our anti-detect browser sessions page says a cookie issued to one IP and replayed from another is, in our team’s words, “an easy signal for a site to read.”

Some rejections show no widget at all. Google’s reCAPTCHA v3 documentation says it “returns a score for each request without user friction.” The site decides what a low score means, so your scraper may get an empty page, a missing price or a redirect instead of a puzzle.

Every captcha you avoid is a solve you don’t pay for, so we run the browser first and the solver last. Wayfern applies the browser identity inside its own Chromium build, and nothing is injected into your pages.

Per Wayfern’s API reference, setting width and height on the /ws URL resizes the real window, so “nothing is emulated and no script runs in your pages.” A sticky session id holds one residential IP for a whole flow, so cookies and exit stay paired.

These fixes lower how often you meet a captcha and guarantee nothing. When one still appears, a captcha solver API for scraping handles it on the same wf_ token and credit balance.

Which captcha solver API task type fits each captcha?

Match the task type to the widget: reCAPTCHA, hCaptcha, Cloudflare Turnstile, FunCaptcha and GeeTest are solved by getting a response from the solver and submitting it, and only image-to-text returns text.

CaptchaInputs besides page URLSolver returnsApply it to
reCAPTCHA v2sitekeytoken stringg-recaptcha-response field or widget callback
reCAPTCHA v2 Enterprisesitekey, plus Enterprise fields in /docs/apitoken stringg-recaptcha-response field or callback
reCAPTCHA v3sitekey, action, minimum scoretoken stringg-recaptcha-response in the request your page sends
hCaptchasitekeytoken stringh-captcha-response field or callback
Cloudflare Turnstilesitekey, plus optional fields in /docs/apitoken stringcf-turnstile-response field
FunCaptchasee /docs/apisee /docs/apisee /docs/api
GeeTestsee /docs/apisee /docs/apisee /docs/api
Image-to-textthe imagetextthe page’s image answer input

Anti-captcha-style APIs share one request pattern. Public examples such as captcha-solver.com show a POST /createTask call, and Anti-Captcha’s documentation pairs it with a getTaskResult method that you call with the returned task id until the solution is ready.

Wayfern exposes the same task shapes at POST /api/captcha/solve with a captcha-scoped wf_ token, and the API reference at /docs/api carries the request fields, response format and error format. The task type for each row is the string you put in the request’s task object; copy its exact spelling from the reference, because a misspelled type fails the request.

For the first five rows, the token is the whole product. Google’s reCAPTCHA verification docs name g-recaptcha-response as the field that carries the user’s response token, and hCaptcha’s developer guide uses h-captcha-response.

Cloudflare’s server-side validation docs use cf-turnstile-response. Your scraper writes the token into that field, or calls the widget’s callback, and then submits the form. The site’s server verifies the token with the vendor.

reCAPTCHA v3 has no checkbox, so two inputs matter. Google’s v3 docs say it “returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot)”, and the action you send must match the action the site checks.

Read the action from the page’s grecaptcha.execute call. A token minted for a different action can fail verification even when it is fresh.

Image-to-text is the only row where a captcha solver API for scraping hands you a plain string. Capture the image, send it, and type the returned text into the answer input the way a user would.

Every task you send to a captcha solver API for scraping needs the sitekey. Read it from the widget’s data-sitekey attribute or the script URL before you create the task.

How do you use a captcha solver API for scraping in Playwright?

A captcha solver API for scraping works in Playwright when you detect the widget, read its sitekey from the DOM, POST a task, and write the returned token into the page before you submit.

import { chromium } from "playwright";

const browser = await chromium.connectOverCDP(
  "wss://api.wayfern.com/ws?token=LINK_TOKEN",
  { timeout: 120000 },
);
const page = await browser.contexts()[0].newPage();
await page.goto("https://example.com/form");

const sitekey = await page
  .locator("[data-sitekey]")
  .first()
  .getAttribute("data-sitekey");

const res = await fetch("https://api.wayfern.com/api/captcha/solve", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WF_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    task: {
      type: "RecaptchaV2TaskProxyless",
      websiteURL: page.url(),
      websiteKey: sitekey,
    },
  }),
});
const token = (await res.json()).solution.gRecaptchaResponse;

await page.evaluate((t) => {
  document.querySelector("#g-recaptcha-response").value = t;
  const cb = document.querySelector("[data-sitekey]").dataset.callback;
  if (cb) window[cb](t);
}, token);

await page.locator("form [type=submit]").click();
  1. Connect with the link token. connectOverCDP() opens the socket, and a cold browser takes a while to start, so raise the connect timeout as shown. LINK_TOKEN opens the browser, and WF_TOKEN is the captcha-scoped token read from an environment variable. Both draw on one credit balance.
  2. Read the sitekey. Wait for the widget, then take data-sitekey from its container. If the selector never matches, the page may use a different captcha, so check the task type table before you send anything.
  3. Send the task. Take the task type and response field names from the API reference and match them to your widget. Send the URL the page is actually on, not the one you requested.

The remaining steps happen inside the page.

  1. Apply the token. Setting the g-recaptcha-response textarea only helps when the form posts that field. If the widget declares data-callback, the page waits on that function and a changed textarea does nothing; calling window[cb](token) inside page.evaluate runs it.
  2. Submit once. Click the submit control right away, because tokens are single-use and expire. Success means the next page loads instead of the widget returning.

A callback registered in script has no attribute to read. Expose a Node function with page.exposeFunction and you can pass tokens in from the page side.

In Puppeteer, puppeteer.connect({ browserWSEndpoint: "wss://api.wayfern.com/ws?token=LINK_TOKEN" }) replaces the connect call. Reading the sitekey and applying the token both go through page.evaluate, with the same arguments.

If your scraper logs in first, our page on scraping behind logins and bot walls covers holding one sticky exit across the flow. To run this script against your own form, create a captcha-scoped token and a link token, then run it on the same credit balance.

Why does a solved captcha token get rejected?

A solved captcha token is rejected when it has expired, was already used, or fails the site’s checks on action, score or IP, so apply each token immediately and only once.

Google’s verification docs say: “Each reCAPTCHA user response token is valid for two minutes, and can only be verified once to prevent replay attacks.” A token that sat in a queue or a cache fails on age alone.

Turnstile tokens are single-use with their own expiry. Cloudflare’s siteverify returns the error code timeout-or-duplicate for a Turnstile token that is too old or was already validated.

hCaptcha’s docs also have your server verify the response token before the site trusts it.

reCAPTCHA v3 adds the score and the action check. Pass the action name from the page’s own grecaptcha.execute call in the task, because a fresh token solved for the wrong action can still fail.

The exit matters too. Google’s verify call accepts an optional remoteip parameter, so a site can compare the IP that solved with the IP that submits. A ProxyLess task solves from the solver’s network while your scraper submits from its own exit, and that mismatch is the case to avoid.

These mechanics set the design rules for any captcha solver API for scraping:

  • Solve late: request the token only when the page is ready to submit.
  • Apply at once: write it into the page and submit in the same step.
  • Never cache or pool tokens, since each one works a single time.
  • Keep one exit per flow: on Wayfern, a sticky session id lets you hold one sticky residential exit. The solver task type and proxy options are in the API reference.

How do you run a captcha solver API for scraping in production?

A captcha solver API runs well in production when you treat three numbers as fixed: a published rate limit, a per-solve credit rate, and a browser meter that keeps running while you wait.

  1. Use one blocking call per solve. Wayfern’s POST /api/captcha/solve is a single request, per /docs/api, so there’s no task ID to poll. Your worker waits on the response while the page stays open and metered.
  2. Set a per-call timeout shorter than the token lifetime. A token that arrives after you’ve given up, or sits in a queue, may expire before you submit it. Cancel the call, release the page, and decide whether a retry is worth it.
  3. Bound your retries. Retry timeouts, 429s and 5xx responses two or three times with jittered backoff. A malformed task or a refused token fails the same way on every retry, so don’t resend it. Sort errors into those two groups using the error format in the API reference.

A captcha solver API for scraping also has to fit your throughput and budget. The remaining steps cover both.

  1. Plan around 20 solves a minute. The captcha endpoint is limited to 20 requests a minute per /docs/limits, so the derived ceiling is 20 solves a minute and 1,200 an hour.
  2. Queue with a token bucket and back off on 429. Refill the bucket at the published rate and let workers wait for a token. When a 429 arrives anyway, slow down instead of adding workers: the default limit is counted per client IP, so extra workers behind one IP share the same budget.
  3. Model cost per page, including failures. Use pages x solves per page x 1 credit, plus browser time, plus retries. Per Wayfern’s pricing, browser time is 8 credits per open-page hour, metered per second with a 60-second minimum per page. A failed solve costs no credits, but the page keeps its meter running while you wait and retry.
  4. Know when to move to a specialist. If you need far more than 1,200 solves an hour, a standalone solver service fits better than this endpoint. Watch your balance as well: calls are refused at zero credits, and auto top-up is off by default.

If 1,000 checkout pages each show one captcha, solving them takes 1,000 credits. At the $0.0125 list credit rate on Wayfern’s pricing page, that’s $12.50, plus browser time for every page you held open.

If 100 of those solves fail and you retry once, the retries cost nothing extra in solve credits, but the 100 pages stay open longer. At 20 solves a minute, the batch needs about 50 minutes, so a 1,000-page run is limited by the rate limit, not by credits.

Solver service, your own OCR, simulated behavior or avoidance: which fits?

Use a solving service for token captchas, your own OCR only for plain image-to-text, and consistent identity and behavior to cut how many challenges you meet in the first place.

OptionWhat it handlesUpkeepHow it fails
Solving serviceToken captchas and image-to-textVendor account, balance, retriesToken expires, is reused, or is rejected
Own OCR or MLSimple image-to-text onlyRetrain when the challenge changesAccuracy drops after a redesign
Simulated behaviorScore-based checks such as v3Ongoing tuningLow score, no guarantee
Avoiding the challengeAny captcha you never triggerConsistent identity and exitChallenge still appears

A captcha solver API for scraping fits pages that use token captchas when you can accept a vendor dependency. It costs credit per solve and ties you to one vendor, and it can’t fix a token that’s stale or submitted from a different IP.

Own OCR has no path for token captchas. The site’s server checks the token with the vendor, so there is no image text for a model to read. OCR fits one stable image-to-text challenge you control.

Simulated behavior targets reCAPTCHA v3’s score. Because the score comes from how a session behaves, scripted behavior needs continuing tuning, and nothing guarantees a pass. Use it as a supplement for score-based checks.

Avoidance means keeping browser identity and exit consistent so fewer captchas appear. It reduces volume without promising anything. It belongs first in every pipeline, before any captcha solver API for scraping.

If captcha volume is the whole job, a standalone solver specialist may fit better than a browser-plus-solver stack. For the wider tool picture, see our comparison of web scraping tools.

Using a captcha solver API for scraping can be lawful for public-data collection, testing and authorized automation, but whether your job qualifies depends on the target’s terms and local law. This is not legal advice.

Fitting uses include:

  • Public data: pages anyone can load without logging in. CapSolver’s homepage describes its API as enabling “secure and scalable collection of publicly available web data for automation workflows.”
  • Testing your own or authorized properties, such as end-to-end tests against a staging site you operate.
  • Authorized automation, research and monitoring, such as price or availability checks you have permission to run.

Out of bounds:

  • Credential stuffing, account abuse and fraud.
  • Collection that ignores a site’s terms or the law.

RFC 9309 defines the Robots Exclusion Protocol, the format a site uses to publish crawl rules in robots.txt. The RFC says these rules are “not a form of access authorization.” Following them is good practice, but a permissive robots.txt doesn’t grant you access.

A site’s terms of service are a separate constraint, and they can restrict automated access even where robots.txt allows crawling. Read both for every target, and run Wayfern only for lawful work: public-data collection, testing, research, monitoring and agents.

Frequently asked questions

What does a captcha solver API return?

A captcha solver API takes a task with the captcha type, page URL and sitekey, and returns the answer. For token captchas that’s a response token you place in the page’s response field or pass to its callback, then submit. Image captchas return the recognized text.

Does a captcha solver work with Playwright and Puppeteer?

It works with both, because the solver is an HTTP call and your script applies the result. Read the sitekey from the DOM, POST the task, then write the token into the response field or call the callback before you submit the form.

How much does a solve cost, and are failed solves billed?

Per Wayfern’s pricing, Wayfern charges 1 credit per successful solve, and a failed solve isn’t charged. Measure your own success rate on your targets before you budget retries.

Why does my captcha token keep failing?

The token is usually expired or already used. Per Google’s verification docs, reCAPTCHA response tokens are valid for two minutes and verify once, so apply each token right away and request a new one for every submission. Keep the solve and the submit on one exit.

What should you do next with a captcha solver API for scraping?

Today: Pick one target and note which captcha appears. Check the signals you control (exit, request pacing and identity consistency) and fix those before you pay for a captcha solver API.

This week: Wire detect, solve, apply and submit into one Playwright flow over connectOverCDP(). Use a captcha-scoped wf_ token, a timeout on the solve call and a fixed number of retries.

Before you scale: Size the pipeline against 20 solves a minute, per Wayfern’s limits, and against the per-page credit model. One wf_ token model and one credit balance cover the browser and the captcha endpoint.

Create a Wayfern token, run the example against a target you’re permitted to automate, then read the Wayfern docs for the full reference.

Sources

Pricing - Credits for Browsers & the Web Data API | Wayfern · Limits | Wayfern docs · Anti-detect browser sessions | Wayfern · reCAPTCHA v3 | Google for Developers · API Reference - CDP, Web Data & Search | Wayfern · Verifying the user’s response | reCAPTCHA · hCaptcha Developer Guide · Server-side validation | Cloudflare Turnstile docs. Every other source is linked where the article cites it.

See us more often in Google

One click marks Wayfern as a preferred source in Google, so our posts can show up more often in your Top Stories, AI Mode and AI Overviews.