Web scraping API errors: what each status means, who caused it and whether you pay

Web scraping API errors sorted by cause: request, balance, capacity, scraping service or target page. Which failures are charged and which to retry.

Published
Reading time
9 min read
By
ExtractHub team
  • web scraping API
  • error handling
  • retries
  • billing
  • reference
On this page

Every scraping integration ends up with an error handler, and most of them start as if (!resp.ok) retry(). That works until a retry loop spends credit on a page that answers 404 every time, or gives up on a busy queue that would have answered in a few seconds. Web scraping API errors come from five different places, and the place decides what your code should do: fix the request, wait, top up, or stop calling that URL.

This post sorts the ExtractHub extract API’s errors by cause, says which ones are charged, and lists what the API already retries before you see an error. If you want a client to copy, the Python and Node.js guides build one; this is the reference those clients are based on.

Two body shapes, one field to branch on

Request, billing, capacity and fetch errors share one body:

{
  "success": false,
  "error": "The target page returned HTTP 404",
  "errors": [{ "code": "target_error", "message": "The target page returned HTTP 404" }],
  "requestId": "3f0c..."
}

error repeats the first message for older clients. Items in errors can also carry path (the request field that was wrong), hint (what to do next) and fields (for missing required fields). A 402 adds a top-level top_up_url.

Errors about the extractor id itself (missing pin, unknown version, yanked version) use a second shape, with the code under details:

{
  "success": false,
  "error": "...",
  "details": { "code": "pin_required", "majors": [1, 2] }
}

Your handler should read errors[0].code, fall back to details.code, and branch on that. Never branch on the message: messages are written for people and change; codes are the contract. Log requestId with the failure when the body has one, so you can find the exact request later.

Web scraping API errors grouped by cause

The same HTTP status can mean different things (there are two 502s and two 422s), so the table groups by where the request stopped.

1. The request itself was wrong

StatusCodeMeaning
400validation_errorA parameter is missing or malformed; path names it.
400pin_required, invalid_pinThe extractor_id has no version pin, or a pin that is not @1, @1.2.3 or @draft. details.majors lists the released majors.
400ambiguous_credentialsX-API-Key and Authorization: Bearer carry two different keys.
400invalid_targetThe URL (or a redirect) points to a private, internal or non-http(s) host. This only applies to direct fetches.
401unauthorizedNo key, an unknown key or an expired key.
403draft_owner_onlyOnly the owner can run @draft.
404not_found, version_not_foundUnknown extractor, or a major with no released version.
410version_yankedThe exact version you pinned was withdrawn by its owner. A major pin such as @1 skips yanked versions.

Nothing in this group reached a scraping service, so nothing is charged. Nothing here gets better on a retry either: fix the request.

A deprecated major is not an error. The call is answered as usual, with Deprecation and Sunset headers and, when the owner wrote one, X-Deprecation-Message. Calls keep working after the sunset date, so treat the headers as a reminder to move to the next major, and alert on them instead of failing.

2. Your account cannot run it right now

StatusCodeMeaning
402insufficient_balanceThe balance cannot cover the request’s worst-case price. The message says how much is needed and what the balance holds; top_up_url opens the Add Funds dialog.
429rate_limitedYour per-account requests-per-minute limit is used up.

Both are free. A 402 is checked against the worst case: an extractor that may escalate to JavaScript rendering needs a balance that covers the JavaScript tier, even if most requests end up cheaper. Don’t loop on a 402. Alert a person, or stop the job until someone tops up.

The per-minute 429 has no Retry-After header, so back off yourself (a few seconds, growing). Repeated requests with a missing or invalid key from one IP address also get a 429 for about a minute: if you see rate_limited together with key errors, fix the key before retrying.

3. Scraping capacity is busy

StatusCodeMeaning
202(not an error)Your request waited 30 seconds for capacity and became an async job: job_id, status_url, result_url.
429too_many_queuedToo many of your requests are already waiting for capacity.
503queue_timeoutNo capacity within 30 seconds and you sent async_fallback=false.
503no_provider_availableNo scraping route can serve this request right now.

All free. too_many_queued and queue_timeout send Retry-After; no_provider_available does not, so back off yourself. A job’s status_url also answers with Retry-After while the job is queued or running, which is your polling interval. This group is where retries pay off: wait, then send the same request again.

If your code cannot handle a 202, pass async_fallback=false; you then get the 503 above instead of a job. Requests that use a plain fetch without the proxy never wait in this queue at all, so they never become jobs.

4. The scraping service failed

StatusCodeMeaningCharged
502upstream_errorThe scraping service failed or could not be reached before the page was fetched.No
504upstream_timeoutThe scraping service did not answer in time.Yes

The difference in charging is deliberate. An upstream_error means no billable work happened, so the request is refunded. A timeout usually means the work was done and the answer did not arrive in time, so it is charged. Retry upstream_error freely with backoff. Retry upstream_timeout once, later, and count it against your budget.

5. The target page or its content was the problem

StatusCodeMeaningCharged
502target_errorThe page was fetched, but answered with an error status (403, 404, 500, …) or was too large.Yes, through the proxy; no on a direct fetch
422required_fields_missingThe page came back, but a required top-level field was empty; fields lists them.Yes, through the proxy; no on a direct fetch
422browser_action_unavailableThe extractor scrolls inside an element and no route can run that for this site right now.No

This is the group where blind retries cost money. A target_error on a 404 will be a 404 again. A required_fields_missing usually means a bot check, a consent page or a new layout, and the same page will probably come back. Retry once at most, and if it fails again, record the URL as failed and move on. The required fields post shows how to choose which fields should fail a request.

A direct fetch (an extractor version with the proxy off) that the target refuses with 403, 429 or 503 also answers target_error, with a hint: the site blocks plain requests, so the extractor owner should switch the version to the proxy. That failure is free, because no scraping service was called.

Which failures are charged, in one rule

A request that fails after a scraping service was called is charged in full. A request that fails before any billable work is free. You never have to work out which case you are in: a charged error body says so.

{
  "success": false,
  "error": "The target page returned HTTP 403",
  "errors": [{ "code": "target_error", "message": "The target page returned HTTP 403" }],
  "requestId": "9a1e...",
  "charged": true,
  "cost": …,
  "note": "The scraping provider was called for this request, so it was charged even though it failed."
}

This is an illustrative example; cost (elided here) is the USD charged, which depends on the extractor’s tier. If the extractor allows JavaScript escalation and the failed request was escalated, it is charged at the JavaScript tier, like a successful escalated request. With a live key, X-Credit-Balance on extract responses holds your balance after this request (a charged failure is already included), so you can see the charge without another call.

A retry policy that follows from this:

if code in (rate_limited, too_many_queued, queue_timeout,
            no_provider_available, upstream_error):
    wait Retry-After (or back off), retry, up to N times      # free
elif charged and code in (target_error, required_fields_missing,
                          upstream_timeout):
    retry at most once, later; then mark the URL as failed     # each try is charged
elif code == insufficient_balance:
    stop and alert                                             # free, needs a person
else:
    fix the request or the extractor id; do not retry          # free

What the API retries before you see an error

Some failures never reach you, which is one reason a client should not add its own aggressive retries on top.

  • Another scraping route. When the service that took a realtime request fails on its side, the request can be moved to another route before the API answers. Each attempt takes its own capacity token, so this can add waiting time but needs nothing from you.
  • JavaScript escalation. When an extractor allows it and a plain fetch comes back blocked or empty, the API retries that page once with JavaScript rendering. A successful escalated result carries metadata.escalated: true and is charged at the JavaScript tier.
  • No target retries in realtime. A realtime request does not retry a target error or a missing required field. You get the answer, and the decision, right away.

The same errors in batches, jobs, pipelines and MCP

The codes follow the work wherever it runs, with small differences.

Async jobs. A job that fails has status: "failed" and an error object with code and message, using the same codes as realtime. It is charged under the same rule.

Batch items. Each item in a batch retries on its own: transient failures on the scraping service side up to a few attempts, and target-side failures (a 5xx, 408 or 429 from the site, or missing required fields) once. Waiting for capacity never counts as an attempt. Failed items in the NDJSON results carry error.code; target errors are reported with the status, as http_404 or http_503, and other codes include upstream_error, upstream_timeout, required_fields_missing and max_attempts_exceeded. An item is charged at most once, however many attempts it took. See batch web scraping for the results format.

Pipelines. A step retries a target-side status once inside the step and lets the workflow retry free failures on the scraping service side. A step pays for a URL at most once, succeeded or failed, so retries never charge the same URL twice.

MCP tools. An agent calling the extract tool over MCP gets a tool error with the same code, the HTTP status, the message, request_id (when the body had one), retry_after_seconds when the API sent Retry-After, and a hint per code (for example, that an upstream_error was not charged and can be retried). Agents can follow the same policy as your code.

Test every branch without spending credit

A test key (exth_test_...) never fetches a page and never moves credit, and accepts a sandbox_scenario parameter that forces the answer:

for s in success failed timeout_to_job insufficient_credit; do
  curl -s -o /dev/null -w "$s %{http_code}\n" \
    -H "X-API-Key: $EXTRACTHUB_API_KEY" \
    "https://api.extracthub.io/api/extractor/extract?target_url=https%3A%2F%2Fwww.example.com%2Fp%2F1&extractor_id=%40you%2Fexample-product%401&sandbox_scenario=$s"
done

failed answers 502 upstream_error, timeout_to_job answers 202 with a sandbox job, and insufficient_credit answers 402. The full list of status codes per endpoint is in the API reference.

FAQ

Why did my web scraping API request fail with 502?

A 502 is either target_error (the page was fetched but answered with an error status, such as 403 or 404) or upstream_error (the scraping service failed before it could fetch the page). Read the code in errors[0].code: target_error is charged when the page was fetched through the proxy, upstream_error is free.

Am I charged for failed scraping requests?

Only when the failure happened after the page was fetched through the scraping service, for example a target_error, an upstream_timeout or a required_fields_missing on a proxied request. Such error bodies carry charged: true, the cost and a note. Validation errors, 402, 429, queue timeouts and upstream_error are free.

Which web scraping API errors should I retry?

Retry 429, 503 and upstream_error after the Retry-After header (or your own backoff when it is missing). Do not retry 400, 401, 402, 404 or 410 as they are. Retry a target_error or required_fields_missing at most once, after checking the URL, because each try through the proxy is charged again.

Does the API retry failed requests by itself?

Partly. A realtime request can be moved to another scraping route when the service fails, and a blocked plain fetch can be retried once with JavaScript rendering when the extractor allows it. Batch items and pipeline steps also retry transient and target-side failures for you; a realtime request never retries a target error.

All posts