Batch Scraping
Submit up to 100 URLs in a single API call. Jobs are processed in parallel and you can poll for results or receive a webhook when the batch completes.
Async by Design
batch_id. Use it to poll status or configure a webhook for delivery.How It Works
Submit
POST an array of URLs to /api/v1/batch. Cost is pre-debited for the estimated total cost.
Process
Each URL becomes an individual job processed in parallel. The same tier escalation and anti-bot logic applies to every job.
Collect
Poll GET /api/v1/batch/{batch_id} for individual results, or receive a batch.completed webhook when all jobs finish.
Submit a Batch
/api/v1/batchSubmit a batch of URLs for asynchronous processing with optional webhook delivery. Returns 202 Accepted.
curl -X POST https://api.alterlab.io/api/v1/batch \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"urls": [
{ "url": "https://example.com/page-1" },
{ "url": "https://example.com/page-2", "mode": "js" },
{
"url": "https://example.com/page-3",
"formats": ["text", "markdown"],
"cost_controls": { "max_tier": "3" }
}
],
"webhook_url": "https://your-server.com/webhook"
}'Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| urls | array | Yes | Array of URL objects (1–100 items) |
| webhook_url | string | No | URL to receive a batch.completed event when all jobs finish |
Per-URL Options
Each item in the urls array accepts the same parameters as a single scrape request:
| Field | Default | Description |
|---|---|---|
| url | — | Target URL (required) |
| mode | "auto" | auto, html, js, pdf, ocr |
| formats | ["html", "json"] | Output formats: text, json, html, markdown |
| cost_controls | null | force_tier, max_tier, prefer_cost, prefer_speed, fail_fast |
| extraction_schema | null | JSON schema for structured extraction |
| extraction_prompt | null | Natural language extraction instructions (max 2,000 chars) |
| extraction_profile | "auto" | Pre-defined profile: auto, product, article, job_posting, faq, recipe, event |
| advanced | null | AdvancedOptions object (render_js, screenshot, ocr, etc.) |
| include_raw_html | false | Include raw HTML in the response |
| cache | false | Enable caching for this URL |
| timeout | 90 | Per-URL timeout in seconds (1–300) |
| wait_for | null | CSS selector to wait for before extracting |
Response (202 Accepted):
{
"batch_id": "batch_7a3b9c8d-4e2f-1a6b-8c5d-9e0f1a2b3c4d",
"total_urls": 3,
"status": "processing",
"estimated_credits": 45000,
"job_ids": [
"a1b2c3d4-...",
"e5f6g7h8-...",
"i9j0k1l2-..."
],
"jobs": [
{ "index": 0, "url": "https://example.com/page1", "status": "accepted", "job_id": "a1b2c3d4-...", "rejected": null },
{ "index": 1, "url": "https://example.com/page2", "status": "accepted", "job_id": "e5f6g7h8-...", "rejected": null },
{ "index": 2, "url": "https://example.com/page3", "status": "accepted", "job_id": "i9j0k1l2-...", "rejected": null }
]
}jobs has one entry per submitted URL, in the order you sent them. Pair job IDs with URLs through jobs. job_ids lists the accepted subset only and is not positional: it is shorter than your submission when any URL is rejected.
Partial acceptance: when a batch goes over your concurrency limit, the URLs that fit are accepted and the rest come back with status: "rejected" and a rejected object holding scope, reason and retry_after_seconds. Rejected URLs are not charged. If every URL is rejected, the response is a terminal 200 with no batch_id to poll. rejected_items carries the same detail as before. Wait for retry_after_seconds, then resubmit only the rejected URLs; the Node and Python SDKs provide resubmitRejected and resubmit_rejected for this.
URLs over your concurrency limit are queued by default. They appear in jobs with status: "queued", are charged up front, and start as your running jobs finish. A URL still queued after 15 minutes fails with queue_expired, is refunded, and carries retry_after_seconds. Set queue_over_limit: false to reject those URLs in rejected_items instead. URLs over the sustained rate limit (global_rate) are always rejected.
Poll Batch Status
/api/v1/batch/{batch_id}Returns the aggregate status and individual job results for a batch.
curl https://api.alterlab.io/api/v1/batch/batch_7a3b9c8d-... \
-H "X-API-Key: your_api_key"Status Response
{
"batch_id": "batch_7a3b9c8d-...",
"status": "completed",
"total": 3,
"completed": 2,
"failed": 1,
"pending": 0,
"items": [
{
"job_id": "a1b2c3d4-...",
"url": "https://example.com/page-1",
"status": "succeeded",
"result": { "text": "...", "metadata": { ... } }
},
{
"job_id": "e5f6g7h8-...",
"url": "https://example.com/page-2",
"status": "succeeded",
"result": { "text": "...", "metadata": { ... } }
},
{
"job_id": "i9j0k1l2-...",
"url": "https://example.com/page-3",
"status": "failed",
"error": "BLOCKED_BY_ANTIBOT"
}
],
"created_at": "2026-03-03T12:00:00Z"
}Batch status values:
| Status | Meaning |
|---|---|
| processing | Some jobs are still running |
| completed | All jobs succeeded |
| partial | All jobs done, some failed |
| failed | All jobs failed |
Webhook Delivery
If you provide a webhook_url, AlterLab sends a batch.completed POST when every job in the batch finishes (succeeded or failed).
{
"event": "batch.completed",
"timestamp": "2026-03-03T12:01:00Z",
"data": {
"batch_id": "batch_7a3b9c8d-...",
"status": "partial",
"total": 3,
"completed": 2,
"failed": 1
}
}Webhook is fire-once
Billing & Cost
- Cost is pre-debited when the batch is submitted, based on estimated per-URL cost.
- If a job fails, the worker automatically refunds the cost for that URL.
- BYOP (Bring Your Own Proxy) discounts apply per-URL if you have an active proxy integration.
- Check
estimated_creditsin the submit response to see the total debited.
Limits
Batch Limits
- Maximum 100 URLs per batch request
- Each URL counts as a separate scrape credit-wise
- Batch jobs are processed in parallel (no guaranteed order)
- Batch metadata expires after 2 hours — poll or use webhooks before then
Python Example
import alterlab
import time
client = alterlab.AlterLab(api_key="your_api_key")
# Submit batch
batch = client.batch_scrape(
urls=[
{"url": "https://example.com/page-1"},
{"url": "https://example.com/page-2", "mode": "js"},
{"url": "https://example.com/page-3", "formats": ["markdown"]},
],
webhook_url="https://your-server.com/webhook",
)
print(f"Batch ID: {batch['batch_id']}")
print(f"Estimated credits: {batch['estimated_credits']}")
# Poll until complete
while True:
status = client.get_batch_status(batch["batch_id"])
print(f"Status: {status['status']} — {status['completed']}/{status['total']} done")
if status["status"] != "processing":
break
time.sleep(2)
# Process results
for item in status["items"]:
if item["status"] == "succeeded":
print(f"✓ {item['url']}: {len(item['result'].get('text', ''))} chars")
else:
print(f"✗ {item['url']}: {item.get('error', 'unknown')}")Node.js Example
import AlterLab from "alterlab";
const client = new AlterLab({ apiKey: "your_api_key" });
// Submit batch
const batch = await client.batchScrape({
urls: [
{ url: "https://example.com/page-1" },
{ url: "https://example.com/page-2", mode: "js" },
{ url: "https://example.com/page-3", formats: ["markdown"] },
],
webhookUrl: "https://your-server.com/webhook",
});
console.log(`Batch ID: ${batch.batchId}`);
// Poll until complete
let status;
do {
await new Promise((r) => setTimeout(r, 2000));
status = await client.getBatchStatus(batch.batchId);
console.log(`${status.completed}/${status.total} done`);
} while (status.status === "processing");
// Process results
for (const item of status.items) {
if (item.status === "succeeded") {
console.log(`✓ ${item.url}`);
} else {
console.log(`✗ ${item.url}: ${item.error}`);
}
}All request parameters (POST /api/v1/batch)
| Name | Type | Default | Description |
|---|---|---|---|
| tag | string | Optional spend-attribution tag (^[a-z0-9][a-z0-9_.-]{0,63}$, max 20 active tags per organization). | |
| urls | object[] | List of URLs to scrape (max 100) | |
| session_id | string | BYOS session ID to apply to all URLs in the batch. | |
| dry_run | boolean | false | Return a free cost estimate (per-item predicted tier and cost, totals, predicted time, remaining-budget check) without dispatching, debiting or reserving anything. |
| approval_id | string | Approval for work above the key's `approval_above_usd` threshold. | |
| max_in_flight_per_domain | integer | Optional cap on this batch's concurrent jobs per registrable domain. | |
| queue_over_limit | boolean | true | When true and the over-limit queue is enabled for your account, items over your global or per-domain concurrency limit are queued (job status `queued`) and start as slots free, for up to 15 minutes. |
| webhook_url | string | Webhook URL to receive batch.completed event when all jobs finish | |
| export | object | Cloud storage export config — results uploaded on batch completion | |
| extraction_selectors | object | Deterministic field extraction: {field: {css|xpath, attr?, multiple?}} evaluated on the fetched HTML. | |
| extraction_schema | object | JSON Schema applied to all URLs that do not supply their own extraction_schema. | |
| extraction_prompt | string | Natural language extraction instruction applied to all URLs that do not supply their own extraction_prompt. | |
| extraction_provider | "openai" | "anthropic" | "openrouter" | "groq" | LLM provider to use for extraction. | |
| extraction_profile | "auto" | "product" | "article" | "job_posting" | "faq" | "recipe" | "event" | Pre-defined extraction profile applied to all URLs that do not supply their own extraction_profile. |