# POST /v2/batch/scrape

> Scrape many onion pages as one job, with the same options for each.

POST `/v2/batch/scrape`

**Authentication:** your key as a [bearer token](https://darkcrawl.dev/docs/api-reference/authentication/).

## Body

| Field                  | Type                                                                                                                                                                                                                                | Required | Default        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------- |
| `urls`                 | `string[]`                                                                                                                                                                                                                          | Required |                |
| `checkPromptInjection` | `boolean \| null`                                                                                                                                                                                                                   | Optional |                |
| `excludeTags`          | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `formats`              | `(string \| object)[]`                                                                                                                                                                                                              | Optional | `["markdown"]` |
| `formats[].type`       | `string`                                                                                                                                                                                                                            | Required |                |
| `headers`              | `object`                                                                                                                                                                                                                            | Optional | `{}`           |
| `ignoreInvalidURLs`    | `boolean`                                                                                                                                                                                                                           | Optional | `true`         |
| `includeTags`          | `string[]`                                                                                                                                                                                                                          | Optional | `[]`           |
| `maxAge`               | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `maxConcurrency`       | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `maxTextBytes`         | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `onlyMainContent`      | `boolean`                                                                                                                                                                                                                           | Optional | `true`         |
| `parsers`              | `(string \| object)[]`                                                                                                                                                                                                              | Optional |                |
| `redactPII`            | `boolean \| object`                                                                                                                                                                                                                 | Optional |                |
| `render`               | `string` Values: `auto`, `never`, `always`                                                                                                                                                                                          | Optional | `"auto"`       |
| `skipTlsVerification`  | `boolean`                                                                                                                                                                                                                           | Optional | `false`        |
| `storeInCache`         | `boolean \| null`                                                                                                                                                                                                                   | Optional |                |
| `timeout`              | `integer \| null`                                                                                                                                                                                                                   | Optional |                |
| `waitFor`              | `integer`                                                                                                                                                                                                                           | Optional | `0`            |
| `webhook`              | `string \| object \| null`                                                                                                                                                                                                          | Optional |                |
| `webhook.url`          | `string`                                                                                                                                                                                                                            | Required |                |
| `webhook.events`       | `string[] \| null` Values: `started`, `page`, `completed`, `failed`, `crawl.started`, `crawl.page`, `crawl.completed`, `crawl.failed`, `batch_scrape.started`, `batch_scrape.page`, `batch_scrape.completed`, `batch_scrape.failed` | Optional |                |
| `webhook.headers`      | `object \| null`                                                                                                                                                                                                                    | Optional |                |
| `webhook.metadata`     | `object \| null`                                                                                                                                                                                                                    | Optional |                |

Firecrawl compatibility fields

Firecrawl fields DarkCrawl does not offer. It takes them so the Firecrawl SDKs keep working, then ignores or refuses each one as the table says.

| Field                | What DarkCrawl does                                   |
| -------------------- | ----------------------------------------------------- |
| `actions`            | Answers 400 NOT_IMPLEMENTED when not empty.           |
| `appendToId`         | Answers 400 NOT_IMPLEMENTED when set.                 |
| `auditMetadata`      | Accepted and ignored.                                 |
| `blockAds`           | Ignored, with a warning when not Firecrawl's default. |
| `domainTools`        | Accepted and ignored.                                 |
| `fastMode`           | Ignored, with a warning when not Firecrawl's default. |
| `integration`        | Accepted and ignored.                                 |
| `location`           | Ignored, with a warning when not Firecrawl's default. |
| `lockdown`           | Answers 400 BAD_REQUEST when true.                    |
| `minAge`             | Answers 400 BAD_REQUEST when set.                     |
| `mobile`             | Ignored, with a warning when not Firecrawl's default. |
| `onlyCleanContent`   | Ignored, with a warning when not Firecrawl's default. |
| `origin`             | Accepted and ignored.                                 |
| `profile`            | Ignored, with a warning when not Firecrawl's default. |
| `proxy`              | Ignored, with a warning when not Firecrawl's default. |
| `removeBase64Images` | Accepted and ignored.                                 |
| `safeMode`           | Ignored, with a warning when not Firecrawl's default. |
| `threatProtection`   | Accepted and ignored.                                 |
| `toolDetail`         | Accepted and ignored.                                 |
| `useMock`            | Accepted and ignored.                                 |
| `zeroDataRetention`  | Ignored, with a warning when not Firecrawl's default. |

## Request

**curl**

```bash
curl -X POST https://api.darkcrawl.dev/v2/batch/scrape \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls":["http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice","http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about"],"formats":["markdown","links"],"maxConcurrency":2}'
```

**Python**

```python
import os
import requests

resp = requests.post(
    "https://api.darkcrawl.dev/v2/batch/scrape",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    json={
        "urls": ["http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice", "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about"],
        "formats": ["markdown", "links"],
        "maxConcurrency": 2,
    },
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/batch/scrape", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "urls": [
      "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
      "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about"
    ],
    "formats": [
      "markdown",
      "links"
    ],
    "maxConcurrency": 2
  }),
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

## Response

Status `200`.

```json
{
  "success": true,
  "id": "01K0EXAMPLEBATCH0000000000A",
  "url": "https://api.darkcrawl.dev/v2/batch/scrape/01K0EXAMPLEBATCH0000000000A",
  "invalidURLs": []
}
```

## Errors

| Code                    | Status |
| ----------------------- | ------ |
| `BAD_REQUEST`           | 400    |
| `INVALID_ONION`         | 400    |
| `POLICY_FORBIDDEN`      | 400    |
| `BLOCKLISTED`           | 403    |
| `BLOCKLIST_UNAVAILABLE` | 503    |
| `SECRETS_UNAVAILABLE`   | 503    |
| `AI_UNAVAILABLE`        | 503    |
| `QUOTA_EXCEEDED`        | 402    |
| `RATE_LIMITED`          | 429    |
| `NOT_IMPLEMENTED`       | 400    |

What each code means, and what to do about it: [Errors](https://darkcrawl.dev/docs/api-reference/errors/).

## Notes

- `urls` holds up to 1000 addresses. One that a scrape would refuse is left out and listed in `invalidURLs`. With `ignoreInvalidURLs` set to `false`, any such address refuses the whole batch with `400 BAD_REQUEST`, and `details.invalidURLs` lists them.
- A batch reserves a page for each address, all or nothing: fewer pages left than addresses is `402 QUOTA_EXCEEDED`.
- The scrape options go at the top level, as on [scrape](https://darkcrawl.dev/docs/api-reference/scrape/post-v2-scrape/). Links are never followed.
- The call reserves the job's pages before it stores anything, and charges the pages the job read when it ends. [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/) has what can refuse it.
- A `webhook` sends the job's events to your receiver, which must be `https`. See [Webhooks](https://darkcrawl.dev/docs/api-reference/webhooks/).
