ScraperFlyAI-ready Web Data API

developer api

Node.js Web Scraping API for public page capture

Use ScraperFly as the capture layer for Node.js scraping workflows: test a public URL, choose HTML, text, Markdown, JSON metadata, screenshot, or PDF output, add rendering, sessions, headers, or routing only when the target needs them, then move the response through workers, queues, agents, or backend services.

Backend workflow

Keep Node.js focused on orchestration while ScraperFly handles capture

Node.js is a natural place for backend jobs, queues, API routes, agents, dashboards, and event-driven workflows. It should not have to become a custom browser platform before your team knows whether the public page response is usable.

ScraperFly gives Node.js services a clean capture layer: fetch a public URL, choose HTML, text, Markdown, JSON metadata, screenshot, or PDF output, and add rendering, sessions, headers, country routing, waits, or stronger delivery only when the target proves those controls improve the result.

fetch or axiosworkersqueues
Developer running a Node.js backend workflow with web scraping API requests, queue jobs, and response logs

How does a Node.js web scraping API work?

A Node.js web scraping API workflow sends a public target URL and request options from a backend service to a hosted capture layer. The API retrieves the page, applies rendering or routing controls when needed, and returns a response your Node.js application can process. Your code stays responsible for parsing, validation, queue behavior, storage, alerting, and product logic.

That boundary keeps the backend easier to maintain. Instead of mixing browser automation, proxy handling, retries, response conversion, and field extraction into one service, the Node.js app can call one request surface and keep the rest of the pipeline explicit. A worker can capture a page, inspect status and metadata, parse the fields it needs, and push the result into a database or downstream system.

Practical takeaway: use ScraperFly for reliable public page capture, and let Node.js own the application-specific workflow around the response.

What should the first Node.js scraping request prove?

The first request should prove the target page and response format before the code becomes reusable. Send one representative URL, keep the request profile light, and inspect the result. Check the final URL, status, content type, response size, body, and whether the fields your parser needs are present. If the source HTML already contains the useful content, the backend can stay simple. If the page is an app shell or missing important fields, compare rendered output before turning every job into a browser request.

This matters because Node.js teams often move quickly from a successful test into a queue or worker. If the first request is overloaded with rendering, premium routing, long waits, or visual output, that expensive profile can become the default before anyone knows which option actually mattered. A better workflow proves one page type at a time and keeps each control tied to evidence.

Backend check What it proves What the Node.js job should do next
Source response Whether raw HTML contains the useful fields Keep the job lightweight when source capture is enough.
Rendered response Whether JavaScript changes the content Enable rendering only for templates that need browser execution.
Response metadata Status, final URL, content type, size, and request evidence Store it with job logs before parsing or retrying.
Output format Whether the downstream consumer needs markup, readable content, metadata, or visual proof Choose the response shape before building converters.
Failure type Whether the issue is input, auth, target behavior, rate limit, network, or rendering Fix configuration, retry with backoff, or escalate deliberately.

Which response format should Node.js request?

The best format is the one your backend can use without extra cleanup. HTML is useful when the parser needs DOM structure, links, attributes, tables, or embedded metadata. Rendered HTML is useful when browser execution creates the final DOM. Text and Markdown are better when the workflow needs readable content for search, summaries, agent context, RAG ingestion, or content review. JSON metadata is useful for logs and operational decisions. Screenshots and PDFs are better for QA, approvals, monitoring, archives, or visual proof.

Do not choose HTML everywhere just because it is familiar. A Node.js service that feeds an LLM may benefit from Markdown. A monitoring worker may need metadata plus a screenshot. A parser may need raw HTML for selectors. A compliance archive may need PDF output. Test the response shape early so the service does not grow a converter layer that the API can avoid.

For the deeper format decision, use the web scraping API response formats guide before hardcoding your backend model.

Node.js consumer Format to test Why it fits Watch out for
Parser service HTML or rendered HTML Preserves selectors, links, attributes, and DOM relationships Requires target-specific extraction and validation.
Search or AI worker Text or Markdown Cleaner readable content with less layout noise May not preserve enough structure for precise field extraction.
Queue monitoring JSON metadata Makes status, final URL, response size, and content type visible Does not replace parsing the target data itself.
QA or approvals Screenshot Shows what the rendered public page looked like Heavier than machine-readable output.
Archive or review record PDF Creates a portable visual document Less convenient for automated parsing.

When should a Node.js service enable rendering, sessions, headers, or routing?

Enable controls when target evidence shows a real need. Use JavaScript rendering when source HTML is incomplete and useful content appears after browser execution. Use headers when a public target expects legitimate request context such as language, accepted content type, or referer behavior. Use sessions when related requests depend on shared cookies or state. Use country routing when public content changes by region, currency, language, availability, or redirect behavior. Use stronger routing when repeated samples show the simple path cannot retrieve a usable response.

These options should not live as silent defaults in a shared helper. A backend queue can process many page types, and not all of them deserve the same request profile. Keep profiles explicit: static pages, JavaScript-heavy pages, regional pages, stateful flows, and visual-proof jobs should be separate enough that cost and failures remain understandable.

For browser-built pages, review the JavaScript rendering API. For shared state, use the sessions API. For request context, see custom headers. For delivery path decisions, compare the rotating proxy scraping API page.

How should Node.js workers handle scraping failures?

Node.js workers need failures that can be acted on. A malformed URL, invalid key, unsupported format, or incompatible file option should stop the job and point to configuration. A timeout, rate limit, upstream 5xx, connection issue, redirect surprise, thin HTML shell, or render timeout should be logged with the request profile and handled with a bounded retry or a different capture test. Treat every failure as evidence, not just an exception string.

This is especially important in queues. A single bad profile can multiply across hundreds of jobs if retry logic is too broad. Store response metadata beside each job result: status, final URL, content type, response size, output format, rendering choice, routing choice, wait timing, and retry count. When failures cluster by target type, the team can fix the profile instead of guessing inside application code.

The reusable error-handling section below expands those groups, but the backend rule is simple: stop configuration mistakes, retry temporary failures carefully, and escalate only when repeated samples justify the heavier request.

How can Node.js scraping queues stay predictable?

Predictable queues start with page classification. Separate simple HTML jobs from rendered pages, session-dependent flows, regional targets, premium routing cases, screenshot captures, and PDF archives. Each class should have its own request profile, concurrency expectation, retry behavior, and logging. That keeps a small scrape from inheriting the cost of the heaviest target in the system.

ScraperFly's credit model supports that style of work because teams can test small, keep uneven projects on pay-as-you-go credits, and move recurring workloads to monthly credits when volume becomes clear. The important step is to know which profiles your real targets require before increasing concurrency.

Use pricing after sampling real URLs, not before. The right estimate depends on whether your jobs are mostly raw HTML, rendered HTML, session-based flows, premium routes, visual files, or a mix.

What should Node.js own after capture?

Node.js should own the workflow that is unique to your product: queues, workers, retries, parser modules, validation rules, deduplication, storage, webhooks, alerts, dashboards, and downstream integrations. ScraperFly should own the public page capture layer: request delivery, rendering when needed, sessions, headers, routing, response formats, screenshots, PDFs, and response evidence.

This boundary gives the backend a stable contract. If parsing breaks, inspect the captured response and update selectors. If capture breaks, adjust the request profile. If the queue grows, tune concurrency and job classes without rewriting browser infrastructure. The service stays boring in the best sense: clear inputs, clear outputs, and fewer hidden moving parts.

Where should a Node.js team start?

Start with one real public target in the API Builder or cURL, then move the proven request into Node.js. Test raw HTML first, compare rendered output when content is missing, choose the response format your backend can use, and log enough metadata to explain future failures.

After the first page type works, add batches deliberately. Keep request profiles visible in code, avoid one global "heavy scrape" helper, and let the queue scale around evidence from real responses.

Node.js workflow

Build a ScraperFly request that moves cleanly into a Node.js backend

Start from one proven API request, then carry the same URL, format, rendering, routing, headers, and session choices into a Node.js service without rewriting the scraping workflow from scratch.

JS
Backend-ready

Prototype the request before adding application code

Use the API Builder or cURL first, then move the exact request shape into fetch, Axios, queues, or workers.

fetchaxiosworkers
OUT
Useful output

Return the format your Node.js pipeline expects

Choose HTML for parsing, text or Markdown for content systems, JSON metadata for structured handling, or visual files for review.

htmltextmarkdownjson
OPS
Production controls

Keep delivery choices visible in code

Rendering, sessions, headers, country routing, premium routing, waits, and retries stay explicit, so debugging stays practical.

rendersessionsretries

Node.js request controls to keep explicit

url

The public target page passed from your Node.js job.

format

The output shape your parser, queue, agent, or data pipeline expects.

render

Browser rendering for frontend-built content.

premium

Stronger routing when simple delivery does not return a usable response.

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"

Before coding

Map target behavior before hardcoding a Node.js scraping profile

A reliable Node.js scraper starts with target evidence: raw HTML availability, JavaScript rendering, redirects, response size, headers, sessions, country differences, and output requirements.

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 writing integration code

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.

How target evidence changes the Node.js request

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.

Error handling

Turn scraping failures into fixes

Every web data workflow eventually meets a bad response: a missing URL, an invalid key, an empty HTML shell, a target 403, a rate limit, a render timeout, a broken PDF capture, or a JSON payload that does not contain the fields your product expected. ScraperFly is built to make those moments diagnosable. You inspect the HTTP status, the stable error code, the request profile, and the returned artifact, then choose the cheapest useful next move: fix the request, add credits, slow down, retry with backoff, enable rendering, change country, use premium routing, preserve headers, or validate the output before scaling.

Stable error shapeRetry decisionsCost-aware escalationOutput validation
Developer reviewing code and API request parameters on a laptop

01 / Request setup and access

Fix request mistakes first

Some failures are not target problems at all. They happen before ScraperFly can make a meaningful delivery attempt: a missing or malformed URL, an unsupported output format, an incompatible visual file type, a missing API key, an invalid key, or a key that has been paused or disabled. These errors are configuration signals, not retry signals: stop the workflow, point the developer to the exact field that needs correction, and keep credits focused on real target tests instead of repeated bad inputs.

missing_urlinvalid_urlunsupported_formatinvalid_api_key
  • Validate the URL and encoding before sending a batch.
  • Use supported outputs: HTML, text, Markdown, JSON, screenshot, or PDF.
  • Match screenshot file types to image output and PDF file type to PDF output.
  • Treat missing or invalid API keys as configuration work, not retry work.
Business dashboard with charts, documents and usage planning on a desk

02 / Credits, limits and concurrency

Separate limits from failures

A workload can fail because the account has no usable credits, the monthly plan limit has been reached, or concurrency is too aggressive for the current plan and target mix. ScraperFly makes those limits visible as operating signals, not mysterious scrape failures. That keeps the buying decision practical: start free, test the target, buy pay-as-you-go credits for uneven jobs, move to monthly credits when volume becomes predictable, and use backoff when request pressure is the real issue.

usage_limit_reachedrate_limitedcreditsbackoff
  • Use account status to check remaining credits before large runs.
  • Retry rate limits with backoff instead of immediately increasing pressure.
  • Keep one-off projects on pay-as-you-go when volume is uneven.
  • Move predictable recurring work to monthly credits when the pattern is proven.
Server room representing delivery paths, routing and network infrastructure

03 / Target delivery and network

Find delivery failures first

Many scraping platforms collapse delivery issues into a vague request failure. In production, that is not enough. The team needs to know whether the request timed out, the upstream target returned a temporary server error, the connection failed, the response was too large, redirects went somewhere unexpected, or the page came back as tiny HTML with no useful content. ScraperFly turns those failures into delivery evidence: try the light profile first, compare status and response size, then decide whether the next request needs backoff, another route, premium proxy, country targeting, or a narrower capture.

timeout5xxredirectsresponse_too_large
  • Retry temporary network and upstream failures with a controlled backoff policy.
  • Compare final URL, status, content type and response size across samples.
  • Escalate routing only when the response proves the simple path is unstable.
  • Treat oversized responses as a scope problem before scaling the same profile.
Digital security screen representing anti-bot and protected access signals

04 / Anti-bot, geo and access blocks

Read blocks before escalation

A target 403, 401, 429, CAPTCHA screen, WAF challenge, login wall, consent loop, or region-specific mismatch is not just an error; it is a clue about what the site expects from the visitor. Competitors often push teams toward a heavier default profile, but that can burn budget without proving the fix. ScraperFly's better path is evidence-based escalation: preserve realistic headers when context matters, use sessions when continuity changes the response, enable rendering when the useful content is browser-built, and choose premium or country routing when reputation or geography changes the result.

403429CAPTCHAcountry mismatch
  • Use premium routing when IP reputation is the proven bottleneck.
  • Use country targeting when language, currency, inventory or search results change by market.
  • Use headers, cookies and sessions when visitor state changes the response.
  • Reduce concurrency and add backoff when repeated requests trigger target throttling.
Developer preparing code and output artifacts on a laptop

05 / Rendering and output quality

Ship usable artifacts

A 200 status is not the same thing as a usable scrape. The raw HTML can be an empty app shell, Markdown can miss the main article, JSON can lack expected metadata, text can include noise, screenshots can be blank, and PDF or image output can fail if the browser step times out. ScraperFly is valuable because the same API request can move from raw HTML to rendered DOM, clean text, Markdown, JSON, screenshot or PDF, then be checked against the artifact your product actually needs. That reduces glue code, failed imports, and expensive batch runs that only discover bad output after the fact.

render_timeoutbrowser_render_failedJSON fieldsPDF/image output
  • Enable rendering when raw HTML is only a shell and the useful content appears after JavaScript.
  • Validate text, Markdown and JSON against expected fields before batching.
  • Use screenshot or PDF output when visual proof or audit evidence matters.
  • Treat blank or partial artifacts as quality failures even when HTTP status is successful.
ScraperFly fit

Cleaner error recovery

ScraperFly helps teams decide what to fix, what to retry, and what to escalate without turning every scrape into the most expensive request profile.

Stable error shape

Use HTTP status and error code together so application logic can choose between fixing input, refreshing credentials, slowing down, retrying, or escalating delivery.

Retry only when it helps

Network failures, rate limits, and temporary server errors can use backoff. Invalid URLs, unsupported formats, and bad keys should be corrected once.

Cost-aware escalation

Start with the light request profile, then add rendering, premium routing, country, sessions, headers, waits, or visual capture only when the failure proves it.

Validate output before scale

Confirm the real artifact your product needs: HTML, text, Markdown, JSON, screenshot, or PDF, before copying the same profile across a large URL set.

Cost-aware workers

Keep Node.js scraping queues efficient by starting with the lightest working request

Queue volume can magnify small request choices. Validate the simple profile first, then add browser rendering, premium routing, sessions, or visual output only where they improve results.

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 Node.js scraping jobs 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 backend jobs 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.

Node.js questions

Common questions about Node.js web scraping with ScraperFly

Practical answers for backend teams deciding how to call ScraperFly from Node.js, choose response formats, control rendering, and keep queues predictable.

Node FAQ
Backend

Calling the API

Node.js can treat ScraperFly as a stable public page capture service.

Can I use ScraperFly from Node.js?

Yes. Node.js backends can call ScraperFly with fetch, Axios, or another HTTP client and process the response in application code.

Should I start in code or API Builder?

Start with API Builder or cURL when possible. Once the response is proven, move the same request profile into Node.js.

Formats

Choosing output

The best format depends on the backend consumer.

Which formats can Node.js workflows request?

Node.js workflows can request HTML, rendered HTML, text, Markdown, JSON metadata, screenshots, or PDFs depending on the downstream use case.

Does ScraperFly replace my parser code?

No. ScraperFly captures public pages and formats responses. Field parsing, validation, storage, and business logic remain in your Node.js app.

Controls

Rendering and context

Use heavier controls only when target evidence supports them.

Can Node.js requests enable rendering?

Yes. Enable rendering when public page content is built by JavaScript and missing from raw HTML.

Can I use sessions and headers?

Yes. Use sessions for shared state and headers for legitimate request context when the target response depends on them.

Queues

Production jobs

Backend queues need request profiles that stay visible and testable.

How should a Node.js worker retry failed requests?

Retry temporary limits, network errors, and upstream failures with bounded backoff. Stop and fix malformed URLs, unsupported formats, or authentication problems.

How do I keep queue cost predictable?

Classify page types and keep raw HTML, rendered pages, sessions, routing, screenshots, and PDFs on separate request profiles instead of one heavy default.