Async web scraping API: realtime calls, 202 jobs and when to use each

How an async web scraping API turns a busy realtime request into a 202 job: status and result URLs, webhooks, async_fallback=false, charging and batches.

Published
Reading time
9 min read
By
ExtractHub team
  • web scraping API
  • async jobs
  • webhooks
  • architecture
  • reference
On this page

A scraping request has two parts that you do not control: waiting for capacity, and the target page taking its time. A synchronous API hides both behind one long HTTP call, and when the wait runs out you get an error and nothing else. An async web scraping API gives you a second answer: “accepted, here is where the result will be”. This post covers how the ExtractHub extract API decides between the two, what the job endpoints return, and which mode fits which kind of caller.

If you want a ready-made polling client, the Python and Node.js guides on this blog include one. This post is about the lifecycle and the trade-offs, so you can pick the right setting before you write that code.

Three ways to run an extraction

Every extraction runs a pinned extractor version (@user/slug@1) on a URL. You can start one in three ways:

ModeYou sendYou getGood for
RealtimeGET or POST /api/extractor/extract200 with the resultOne URL, an answer now
Realtime that became a jobthe same request202 with job_id, then the result laterOne URL, an answer soon
BatchPOST /api/extractor/batch with many targets202 with a batch id, results as NDJSONMany URLs, no hurry

The first two are the same request. You do not ask for a job: the API makes one when a realtime request has waited too long. That is the part worth understanding.

How a realtime request becomes an async job

A realtime request that needs the scraping service (proxy or JavaScript rendering) waits in a queue for capacity. Realtime requests come first in that queue, ahead of pipeline steps and batch items. When capacity is free, the request goes straight through; the queue only matters when many requests arrive at once.

If the request is still waiting 30 seconds after it arrived, one of three things happens:

  1. It becomes a job (the default). The request is stored as a one-URL job and answered with 202. The job runs as soon as capacity frees up, with priority over pipelines and batches.
  2. It fails with 503 queue_timeout. This happens when you sent async_fallback=false, or when the credit hold for the job could not be reserved. The answer carries Retry-After.
  3. It never waited. Requests that use a plain fetch without the proxy (useProxy: false, no JavaScript) skip this queue entirely, so they never become jobs.

There is also a per-user cap on waiting requests: when too many of yours are already queued, a new one gets 429 too_many_queued with Retry-After before it starts waiting. All of these answers are free; nothing was fetched.

Two details make a job behave like the request you sent:

  • The version is frozen. A request for @acme/product-page@1 resolves to an exact version (say 1.4.0) when the job is created. The job runs that version even if 1.4.1 is released while it waits. The exact version is in the 202 body as extractor_version. A job for @draft stores the draft as it was, so later edits in the Studio do not change it.
  • The payment moves to a hold. A realtime request deducts the extractor’s price up front. When it becomes a job, that deduction is refunded and replaced by a credit hold for the job’s worst-case price (the JavaScript price if the extractor may escalate to JavaScript rendering). The hold is settled when the job finishes. This is why X-Credit-Balance on a 202 is already lower.

The 202 response

{
  "success": true,
  "result": {
    "job_id": "job_...",
    "status": "queued",
    "status_url": "https://api.extracthub.io/api/extractor/jobs/job_...",
    "result_url": "https://api.extracthub.io/api/extractor/jobs/job_.../result",
    "extractor_version": "1.4.0",
    "created_at": "2026-11-25T08:00:30.000Z"
  }
}

Headers: Location holds the status URL, Retry-After: 10 is the suggested polling interval, and X-Extractor-Version the exact version. Values here are an illustrative example.

Note the status code. Many HTTP clients treat every 2xx as “the data is here”. If your code reads result.extracted on any 2xx, a 202 gives you undefined instead of an error. Check for 202 explicitly.

Reading a job: status URL or result URL

There are two read endpoints, and they answer differently on purpose.

GET /api/extractor/jobs/{id} always answers 200 with the job:

{
  "success": true,
  "result": {
    "job_id": "job_...",
    "extractor_id": "@acme/product-page@1",
    "extractor_version": "1.4.0",
    "status": "completed",
    "url": "https://www.example.com/products/123",
    "cost": "...",
    "result": { "extracted": { "title": "...", "price": 19.99 }, "metadata": { "...": "..." } },
    "webhook_url": null,
    "created_at": "2026-11-25T08:00:30.000Z",
    "updated_at": "2026-11-25T08:00:41.000Z",
    "completed_at": "2026-11-25T08:00:41.000Z",
    "expires_at": "2026-12-02T08:00:41.000Z",
    "status_url": "...",
    "result_url": "..."
  }
}

(Illustrative example.) cost is the USD amount the job was charged; the price per tier is on the pricing section. status is one of:

  • queued: waiting for capacity. A job paused because your balance ran out also shows as queued.
  • running: being fetched and extracted.
  • completed: result holds exactly what a 200 from the extract endpoint would have held.
  • failed: error has a code and a message, with the same codes as realtime (target_error, upstream_error, required_fields_missing and so on, see web scraping API errors).
  • cancelled: cancelled before it started; error.code is cancelled.

While the job is queued or running, the response carries Retry-After.

GET /api/extractor/jobs/{id}/result answers in the shape of the extract endpoint, so code written for realtime calls can read it unchanged:

StatusMeaning
200Completed: { "success": true, "result": ... }, the same body as a realtime 200
202Still queued or running: the job status, with Retry-After
422Failed or cancelled: { "success": false, "error": "...", "details": { "code": "..." } }
410results_expired: the result was deleted
404job_not_found: wrong id, or a job of another account

Results are kept for 7 days after the job finishes (expires_at). After that the status stays readable without result. If you need the data longer, store it when you read it.

A job is retried for you in the background. Transient failures of the scraping service are retried, and a target-side error (a 5xx, 408 or 429 from the page) gets one more try. You are charged once for the job, whatever the number of attempts.

Cancelling

POST /api/extractor/jobs/{id}/cancel cancels a job that has not started: it becomes cancelled, is not charged, and its hold is released. A job that is already running finishes and is charged like any job; its status stays running until then. Cancelling a finished job changes nothing and returns its current status. No webhook is sent for a cancel.

Polling or a webhook

Polling is simple and fine for a worker: read status_url, wait for Retry-After, repeat until the status is final. Set your own upper limit on the total wait.

If you would rather be told, pass webhook_url (HTTPS, public host) with the extract request:

curl -G "https://api.extracthub.io/api/extractor/extract" \
  -H "X-API-Key: $EXTRACTHUB_API_KEY" \
  --data-urlencode "extractor_id=@acme/product-page@1" \
  --data-urlencode "target_url=https://www.example.com/products/123" \
  --data-urlencode "webhook_url=https://hooks.example.com/extracthub"

The webhook is only used if the request becomes a job; a request answered with 200 sends nothing. The URL is checked up front either way, so a bad one gets 400 invalid_webhook_url even when no job is created. Without webhook_url, your account default webhook (API keys page) is used if you enabled it with job events. The target is fixed when the job is created; changing the default later does not move jobs already queued.

The event is job.completed or job.failed:

{
  "id": "evt_...",
  "type": "job.completed",
  "created_at": "2026-11-25T08:00:41.000Z",
  "data": {
    "job_id": "job_...",
    "status": "completed",
    "counts": { "total": 1, "succeeded": 1, "failed": 0, "cancelled": 0, "pending": 0 },
    "cost": "...",
    "status_url": "...",
    "result_url": "...",
    "metadata": null
  }
}

The payload never contains the extracted data: your handler reads the result with your API key, from /api/extractor/jobs/{job_id}/result. That keeps result data out of webhook logs. Verify X-Webhook-Signature (HMAC-SHA256 over the timestamp and the raw body), and deduplicate on X-Webhook-Id, which stays the same across retries. The webhook signature guide has the code. Answer with a 2xx within 10 seconds and do the work after.

When to use async web scraping API jobs

The setting is per request, so decide it per caller, not per account.

Keep the default (jobs on) when the caller can wait. Cron jobs, queue workers and data syncs all handle “later” fine. A job is better than a 503 here: your request keeps its place, runs before pipelines and batches, and you do not have to rebuild retry logic around queue_timeout.

Turn it off when the caller must answer now. An HTTP handler serving a user, or a function with a hard time limit, cannot do much with a job id. With async_fallback=false (query string on GET, "async_fallback": false in the POST body) it gets 503 queue_timeout and Retry-After after 30 seconds, and can show “try again” or fall back to cached data. Nothing is charged for that 503.

Do not use jobs as a bulk API. Sending a thousand realtime requests and letting them turn into jobs fills the per-user queue cap (429 too_many_queued) and gives you a thousand ids to track. The Batch API is built for that: one call for many URLs, an Idempotency-Key header so a retried submit does not create a second batch, your own metadata, credit held chunk by chunk, and results streamed as NDJSON. Batches run after realtime requests and jobs, which is the right order for work nobody is waiting on.

AI agents over MCP get the same behaviour. The extract tool of the MCP server returns status: "queued" with a job_id when the request became a job, and the agent reads it later with get_job (free) or cancels it with cancel_job. The tool takes async_fallback and webhook_url too.

Read timeouts

With jobs on, a realtime request can hold the connection for up to 30 seconds of queue time plus the page fetch before it gets either the data or the 202. Set your HTTP client’s read timeout well above 30 seconds, or you will cut off requests that were about to succeed.

Test the job path without credit

A test key (exth_test_...) can simulate the queue deadline with sandbox_scenario=timeout_to_job:

curl -G "https://api.extracthub.io/api/extractor/extract" \
  -H "X-API-Key: exth_test_..." \
  --data-urlencode "extractor_id=@acme/product-page@1" \
  --data-urlencode "target_url=https://www.example.com/products/123" \
  --data-urlencode "sandbox_scenario=timeout_to_job"

You get a real 202 with a sandbox job ("sandbox": true). The job then completes with a sample result through the same status, result, cancel and webhook endpoints, and the webhook payload carries data.sandbox: true. Add async_fallback=false to the same call and you get the 503 queue_timeout instead. Nothing is fetched and no credit moves; the web scraping sandbox post covers the other scenarios.

Run both branches in your test suite. The 202 branch is the one that only shows up when traffic is high, which is the worst time to find out that your code reads undefined as an empty product. The full schemas of the job endpoints are in the API reference.

FAQ

What does a 202 from a web scraping API mean?

Your request waited 30 seconds for scraping capacity and was accepted as an async job instead of failing. The body has job_id, status_url and result_url; poll the status URL, or pass webhook_url to be notified when the job completes or fails.

How do I turn off the async job fallback?

Send async_fallback=false (a query parameter on GET, a boolean in the POST body). A request still waiting after 30 seconds then gets 503 queue_timeout with a Retry-After header instead of a 202.

Am I charged for an async scraping job?

A job is charged at the extractor's price when it completes, or when it fails after the page was fetched through the scraping service, the same rule as a realtime call. A job you cancel before it starts is not charged and its held credit is released.

How long are async job results kept?

Seven days after the job finishes, shown in expires_at. After that the status stays readable without the result, and the result URL answers 410 results_expired.

Should I use async jobs or the Batch API for many URLs?

Use the Batch API. A job is one realtime request that had to wait; a batch takes many URLs in one call, supports an idempotency key and metadata, and streams results as NDJSON.

All posts