> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapengine.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Batch Scrape

> Scrape many URLs as one job, with a per-URL time budget

## Overview

Submit up to 5,000 URLs and get a job id back immediately. Each URL becomes its own pipeline job
with its own trace id and its own time budget.

That per-URL budget is the reason to use this rather than fanning out from your own client: client
side parallelism queues every request against one deadline, so the requests that wait longest are
the ones that get dropped. Here a slow URL cannot consume another URL's time, and the job as a whole
has no response deadline.

## Parameters

**urls** `string[]` *required*

URLs to scrape, 1 to 5,000. Duplicates are removed before anything is charged or fetched.

**render** `boolean` (default: false)

Render each URL in a browser. Leave this off unless the pages genuinely need it. The browser tier
runs roughly ten concurrent jobs across the whole fleet where the cheap path runs hundreds, so a
rendered batch is both far slower and far smaller.

**format** `string` (default: markdown)

`raw`, `json` or `markdown`.

**onlyMainContent** `boolean` (default: true)

Strip page furniture when `format` is `markdown`.

**country** `string`

Two-letter country code for the proxy exit, for example `us`.

**concurrency** `integer`

How many URLs to have in flight at once, 1 to 50. Defaults by destination, because the two fetch
paths have very different ceilings: **4** for browser-bound batches, **20** otherwise. Raising it
past the browser pool does not go faster, it just means jobs wait and then exceed their budget.

**outputFormat** `string` (default: jsonl)

Artifact format for the combined download: `json`, `jsonl` or `csv`.

**Idempotency-Key** `string`

Replay protection. If a request carrying this key has already created a job, the original job id
is returned with `replayed: true` and nothing new is created or charged. Keys are scoped to your
API key and kept for 24 hours. Use it whenever you retry a submission you did not get an answer
to — otherwise a retry creates a second job and charges a second time.

## Credits

One credit per unique URL, deducted when the batch is accepted. The request is rejected with `402`
if your balance will not cover it.

## Example Request

```bash cURL theme={null}
curl -X POST "https://api.scrapengine.io/api/v1/batch/scrape" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 9f1c2e40-batch-001" \
  -d '{
    "urls": ["https://example.com/a", "https://example.com/b"],
    "format": "markdown",
    "onlyMainContent": true,
    "country": "us"
  }'
```

```javascript JavaScript theme={null}
const response = await fetch("https://api.scrapengine.io/api/v1/batch/scrape", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
    "Idempotency-Key": "9f1c2e40-batch-001",
  },
  body: JSON.stringify({
    urls: ["https://example.com/a", "https://example.com/b"],
    format: "markdown",
  }),
});
const { jobId } = await response.json();
```

```python Python theme={null}
import requests

r = requests.post(
    "https://api.scrapengine.io/api/v1/batch/scrape",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Idempotency-Key": "9f1c2e40-batch-001",
    },
    json={"urls": ["https://example.com/a", "https://example.com/b"], "format": "markdown"},
)
job_id = r.json()["jobId"]
```

## Response

```json theme={null}
{
  "jobId": "c6ba9310-2c3a-4d43-ba4e-d815aac5d2ce",
  "status": "pending",
  "urls": 2
}
```

A replay of an earlier `Idempotency-Key` returns the same shape plus `"replayed": true`.

## Then

* `GET /batch/scrape/{id}` for progress
* `GET /batch/scrape/{id}/items` for the per-URL outcome, including `errorCode` on failures
* `GET /batch/scrape/{id}/download` for the combined artifact
* `POST /batch/scrape/{id}/cancel` to stop it

## Note on concurrency and the target site

`concurrency` is global to the job, not per host. A list of 1,000 URLs spread over three domains at
the default 20 means roughly seven requests in flight against each site continuously, which is how
you get rate limited or escalated against. If your URLs are concentrated on a few hosts, submit one
batch per host and size `concurrency` for that host.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.