ScraperFlyAI-ready Web Data API

request control

Scraping API error handling that leads to clear next actions

A failed scrape should tell the team what to do next. ScraperFly helps developers separate bad inputs, account limits, target-side access failures, rate limits, rendering problems, empty responses, oversized captures, and output mistakes so every retry has a reason.

Evidence-first recovery

Fix the cause before repeating the request

Scraping errors become expensive when every failure gets the same answer: retry harder. A bad URL, an invalid key, a target 403, a 429 limit, a render timeout, an empty HTML shell, and an oversized response are different problems with different fixes.

ScraperFly gives teams the request evidence they need to choose the next step deliberately. Inspect the status, final URL, response size, content type, output format, render behavior, and target signals before adding browser execution, sessions, headers, country routing, or premium delivery.

diagnoseretry with backoffescalate with evidence
Team reviewing scraping API error categories and next actions on a dashboard

What does scraping API error handling need to answer?

Good error handling does more than say a request failed. It should answer whether the problem came from the request, the account, the target, the network path, the browser render, the selected output, or the downstream parser. That classification decides whether the next action is correction, retry, wait, escalation, or a smaller capture.

This is why a reliable scraping workflow should log both the visible error and the surrounding evidence. A 200 response with a tiny HTML body may be less useful than a clear 403. A successful screenshot of an error page is still a target failure. A PDF timeout may be an output-scope issue rather than a proxy problem.

Practical takeaway: treat every failure as a routing decision for the next request, not as a command to repeat the same profile.

Which scraping errors should be fixed instead of retried?

Some failures should stop the workflow immediately because another identical request cannot succeed. Missing URLs, malformed URLs, unsupported formats, invalid API keys, paused keys, incompatible file options, and impossible output combinations are configuration problems. They need validation and better feedback, not backoff.

Fix-first errors are where API discipline saves money. If the request is invalid, spending credits on rendering, premium routing, or repeated attempts only hides the real issue. Validate the request shape early, then send production batches only after the baseline request is correct.

Error groupCommon signalBetter next action
Input validationMissing URL, invalid URL, unsupported parameterCorrect the request before retrying
AuthenticationMissing, invalid, disabled, or paused API keyFix account or key configuration
Output choiceUnsupported format, incompatible screenshot or PDF optionChoose a supported response format
Scope problemOversized response or file captureNarrow the capture or use a lighter output

Which failures deserve controlled retries?

Temporary failures can be retried, but the retry policy should be bounded. Network timeouts, transient upstream 5xx responses, and selected 429 rate limits may recover after backoff. Repeating them immediately at higher concurrency usually makes the workflow less stable.

A strong retry policy records the reason, waits before the next attempt, caps total retries, and changes the request only when the evidence supports a change. For example, a target-side 403 error may need access-context analysis, not a generic retry loop. An empty HTML response may need a raw-versus-rendered comparison before any routing change.

FailureRetry postureEvidence to inspect
TimeoutRetry with a limit and backoffDuration, target stability, render time, response start
5xx upstream responseRetry if temporary pattern is plausibleStatus history, final URL, response body size
429 rate limitSlow down before increasing pressureConcurrency, request cadence, account limits, target tolerance
403 target responseDiagnose before retryingHeaders, region, cookies, rendering, route behavior

When should rendering, waits, or routing be escalated?

Escalation should follow proof. Enable JavaScript rendering when the useful public content is missing from source HTML and appears after browser execution. Add render waits when the browser opens the page but the content loads later. Consider headers, cookies, sessions, country targeting, or premium routing when the response evidence points to context, continuity, geography, or target-side access behavior.

The key is not to turn every target into the heaviest request. Use rendering for pages that need browser execution, review render timeout evidence when browser work fails, and inspect response-too-large cases before scaling the same profile.

Practical takeaway: escalate one control at a time so the team learns what actually fixed the response.

How does ScraperFly make recovery decisions practical?

ScraperFly helps developers build recovery around observable request evidence: status, final URL, content type, response size, output format, render behavior, and routing profile. That makes it easier to keep simple targets light while giving harder targets a clean path to rendering, sessions, headers, country targeting, premium routing, screenshots, or PDFs when they are justified.

Use the API Builder to reproduce the target request, compare output formats, and test the next control before wiring a retry policy into code. Then use pricing and the web scraping API credit cost calculator to keep recovery experiments aligned with the real workload.

Failure diagnosis

Match the recovery path to the target behavior

Error handling gets easier when teams know whether the target is static, JavaScript-heavy, regional, stateful, rate-limited, oversized, blocked, or returning a temporary upstream failure. ScraperFly helps turn that evidence into the next useful request instead of a louder retry.

Raw HTML response mapped to visible page data
01

Raw HTML availability

Check whether the fields you need are already present in the first HTML response.

Best first test for simple pages, articles, docs, listings, and product details.

Before and after JavaScript rendering comparison
02

JavaScript dependency

Compare raw HTML with the rendered DOM or screenshot before turning on browser rendering.

Use rendering when raw HTML is only a shell and scripts create the useful content.

Cookies, consent, session and access context for scraping
03

State & access context

Identify whether cookies, consent, login boundaries, pagination, or the same visitor state affect the response.

Use sessions and headers when continuity changes the data you receive.

Regional content variations across countries and routes
04

Geo/content variation

Test whether country, language, currency, inventory, SERP, ads, or route reputation changes the result.

Use geo or premium routing only when the target proves the response varies by route.

Checks before choosing the recovery strategy

Where is the target field?

Find whether the field exists in raw HTML, rendered DOM, an API call, structured data, a file, or a later interaction state.

What changes the response?

Sample a few URLs and compare status, final URL, content length, redirects, empty states, and visible result differences.

What context is required?

Mark any dependency on consent, locale, cookies, headers, authentication boundary, pagination, filters, or previous requests.

What does failure look like?

Define the signals for blocked, partial, stale, redirected, empty, timed-out, or region-mismatched responses before scaling.

Map the target behavior before changing controls

Fetch mode

Raw HTML availability decides whether the first request can stay simple or needs rendering, waits, screenshots, or extraction.

Request context

State requirements decide whether to add headers, cookies, sessions, consent handling, or a stable visitor profile.

Routing choice

Geo and reputation findings decide whether standard routing is enough or a country/premium route is justified.

Validation rules

Known failure states become checks for retries, escalation, QA review, and deciding when a lighter profile is still complete.

Recovery request builder

Build the next request from response evidence

Use status, final URL, response size, content type, error category, and output evidence to decide whether the next run needs validation, rendering, waits, headers, sessions, country targeting, premium routing, or a smaller capture scope.

CFG
Setup

Fix bad inputs before spending on retries

Missing URLs, invalid keys, unsupported formats, and incompatible file options are configuration work, not delivery work.

missing_urlinvalid_key
NET
Delivery

Treat target and network failures differently

Timeouts, 5xx responses, redirects, rate limits, and blocked pages point to different recovery paths.

timeout403429
OUT
Output

Check the response shape before changing parser code

Empty HTML, oversized responses, PDFs, screenshots, and rendered output need evidence before parser rules change.

empty htmlpdfscreenshot

Signals that guide scraping error recovery

status

HTTP result or ScraperFly error category.

final_url

The URL after redirects and target handling.

size

Response size that hints at empty, blocked, or oversized output.

format

The output shape where the failure appeared.

cURL example

Generate Markdown with the same request shape you can move into production

curl "https://scraperfly.com/api/v1?url=https%3A%2F%2Fexample.com&format=markdown" \
  -H "apikey: YOUR_API_KEY"

Recovery cost control

Keep retries affordable by fixing the cause, not repeating the same request

Blind retries turn small failures into expensive batches. Targeted recovery keeps credits focused on the next useful experiment: correct bad inputs, slow down rate-limited jobs, render only when the source is incomplete, and escalate routing only when target evidence supports it.

A lightweight HTML request returning a simple response
01

Basic fetch

Use a basic fetch when public HTML already contains the fields you need.

Lightest request profile; keep it when the response is complete.

JavaScript rendering producing a complete DOM
02

Rendering

Use rendering when raw HTML is a shell and JavaScript completes the page.

Heavier profile; use it only when browser output changes the result.

Several requests preserving cookies and visitor state
03

Stateful session

Use sessions when cookies, consent, locale, or pagination change the response.

Heavier state profile; preserve it only when continuity matters.

Request routing through geo and higher quality routes
04

Premium routing & geo

Use premium routing or geo only when origin, country, reputation, or regional content changes the result.

Heaviest routing profile; apply it only to targets that prove they need it.

What makes error recovery heavier

More infrastructure work

Browser rendering, routing choices, and longer waits mean the platform has to do more than return a simple response.

More target uncertainty

Redirects, empty states, rate limits, and challenge pages often require stronger delivery options or retries.

More state to preserve

Cookies, sessions, consent, and multi-page flows add moving parts that a plain stateless fetch does not have.

More evidence to return

Screenshots, PDFs, rendered output, and richer response artifacts are useful, but they are heavier than plain HTML.

How to keep recovery runs predictable

Sample before scale

Test a small URL set first and group targets by the lightest profile that returns complete data.

Do not render by default

Inspect raw HTML before turning on rendering. Many public pages already contain the data you need.

Escalate by evidence

Move up only when the response shows missing content, state dependency, geo variance, or routing problems.

Measure useful results

Optimize around valid records delivered, not raw request volume. A lighter profile is best only when it stays complete.

Error FAQ

Common questions about failed scraping requests

Quick answers for teams evaluating web scraping API behavior: request formats, JavaScript rendering, proxy routing, credits, files, security, and billing.

Quick answers
SETUP

Fix first

Some errors are request or account configuration issues.

Which errors should stop immediately?

Malformed URLs, missing URLs, unsupported formats, invalid keys, and incompatible output options should be corrected before another request is sent.

Why does validation matter before scaling?

Validation prevents teams from spending credits on requests that cannot succeed because the request shape is wrong.

RETRY

Retry carefully

Temporary failures need limits and backoff.

Which failures can be retried?

Timeouts, selected upstream 5xx responses, and some rate limits may be retried with bounded backoff and clear logging.

Why not retry everything?

Retries do not fix bad inputs, unsupported formats, blocked target behavior, empty app shells, or oversized captures.

ESCALATE

Change controls

Add heavier controls when evidence proves they help.

When should rendering be enabled?

Enable rendering when source HTML does not contain the useful public content and the rendered page does.

When should routing change?

Change routing when status, region, access behavior, or repeated delivery evidence shows the default path is not enough.

OUTPUT

Check shape

The response format can change the failure mode.

Can output format cause errors?

Yes. Screenshots, PDFs, JSON, text, Markdown, and HTML each have different size, rendering, and downstream validation concerns.

What if the response is too large?

Treat oversized responses as a scope problem first. Narrow the capture or choose a lighter output before scaling the same request profile.