# Crawl

> Read an onion site page by page as one job, then read the job's status and pages.

`POST /v2/crawl` starts a job that reads a site page by page. It answers at once with the job’s `id`; you read the pages with the status route.

**curl**

```bash
curl -X POST https://api.darkcrawl.dev/v2/crawl \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice","limit":20}'
```

**Python**

```python
import os
import requests

resp = requests.post(
    "https://api.darkcrawl.dev/v2/crawl",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    json={
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
        "limit": 20,
    },
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/crawl", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
    "limit": 20
  }),
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

```json
{
  "success": true,
  "id": "01K0EXAMPLEJOB00000000000A",
  "url": "https://api.darkcrawl.dev/v2/crawl/01K0EXAMPLEJOB00000000000A"
}
```

## Read the status

`GET /v2/crawl/{job_id}` answers with the job’s `status` (`scraping`, `completed`, `failed` or `cancelled`), `completed` and `total` pages, `expiresAt` and `data`, a list of pages shaped like a [scrape](https://darkcrawl.dev/docs/endpoints/scrape/) reply. Poll it until `status` is no longer `scraping`.

**curl**

```bash
curl https://api.darkcrawl.dev/v2/crawl/JOB_ID \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY"
```

**Python**

```python
import os
import requests

resp = requests.get(
    "https://api.darkcrawl.dev/v2/crawl/JOB_ID",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/crawl/JOB_ID", {
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
  },
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

```json
{
  "success": true,
  "status": "completed",
  "completed": 2,
  "total": 2,
  "creditsUsed": 0,
  "expiresAt": "2026-12-26T10:00:00+00:00",
  "loginWalls": 0,
  "data": [
    {
      "markdown": "# Notice\n\nSample page text.\n\nContact: sales@example.invalid\n",
      "links": [
        "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about",
        "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/contact"
      ],
      "metadata": {
        "title": "Notice",
        "description": "",
        "language": "en",
        "sourceURL": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
        "statusCode": 200,
        "contentType": "text/html",
        "scrapeId": "01K0EXAMPLECAPTURE0000000A",
        "onion": {
          "host": "exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion",
          "valid": true,
          "version": 3
        },
        "evidence": {
          "captureId": "01K0EXAMPLECAPTURE0000000A",
          "fetchedAt": "2026-11-26T10:00:00+00:00",
          "sha256Raw": "9f2c000000000000000000000000000000000000000000000000000000000000"
        }
      },
      "indicators": [
        {
          "type": "email",
          "value": "sales@example.invalid",
          "count": 1
        }
      ],
      "resources": [
        {
          "category": "image",
          "element": "img",
          "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/logo.png",
          "label": "Logo",
          "title": "",
          "filename": "logo.png",
          "type": "image/png",
          "size": null,
          "download": {
            "status": "metadata_only"
          }
        }
      ]
    },
    {
      "markdown": "# About\n\nSample second page.\n",
      "links": [
        "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/"
      ],
      "metadata": {
        "title": "About",
        "description": "",
        "language": "en",
        "sourceURL": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about",
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/about",
        "statusCode": 200,
        "contentType": "text/html",
        "scrapeId": "01K0EXAMPLECAPTURE0000000B",
        "onion": {
          "host": "exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion",
          "valid": true,
          "version": 3
        },
        "evidence": {
          "captureId": "01K0EXAMPLECAPTURE0000000A",
          "fetchedAt": "2026-11-26T10:00:00+00:00",
          "sha256Raw": "9f2c000000000000000000000000000000000000000000000000000000000000"
        }
      },
      "indicators": [
        {
          "type": "email",
          "value": "sales@example.invalid",
          "count": 1
        }
      ],
      "resources": [
        {
          "category": "image",
          "element": "img",
          "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/logo.png",
          "label": "Logo",
          "title": "",
          "filename": "logo.png",
          "type": "image/png",
          "size": null,
          "download": {
            "status": "metadata_only"
          }
        }
      ]
    }
  ]
}
```

A reply holds at most 100 documents or about 10 MiB. When more are left, `next` is the address of the following part, and `?skip=&limit=` pages by hand. `expiresAt` says when the job’s listing expires.

## Cancel

`DELETE /v2/crawl/{job_id}` stops a job. An unknown job answers `404`, and a finished one `409`.

**curl**

```bash
curl -X DELETE https://api.darkcrawl.dev/v2/crawl/JOB_ID \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY"
```

**Python**

```python
import os
import requests

resp = requests.delete(
    "https://api.darkcrawl.dev/v2/crawl/JOB_ID",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/crawl/JOB_ID", {
  method: "DELETE",
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
  },
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

```json
{
  "status": "cancelled"
}
```

## Options

`url` is required. Everything else is optional.

| Option                                            | What it does                                                                                                |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `limit`                                           | The most pages to read. A plan can lower it, with a warning in the reply.                                   |
| `maxDiscoveryDepth`                               | How many links deep to follow.                                                                              |
| `includePaths`, `excludePaths`                    | Regular expressions on the path, or on the whole URL with `regexOnFullURL`.                                 |
| `crawlEntireDomain`, `allowSubdomains`            | Widen what counts as the same site.                                                                         |
| `allowExternalLinks`                              | Follow links to other onion hosts only. Each is still checked.                                              |
| `ignoreQueryParameters`, `deduplicateSimilarURLs` | Treat near-identical URLs as one.                                                                           |
| `delay`, `maxConcurrency`                         | Pace the reads.                                                                                             |
| `sitemap`                                         | `include`, `only` or `skip`.                                                                                |
| `ignoreRobotsTxt`                                 | Whether to ignore the site’s `robots.txt`.                                                                  |
| `maxPagesPerPattern`                              | DarkCrawl’s own. Caps how many pages one URL template may produce, so a crawler trap cannot use up the job. |
| `scrapeOptions`                                   | The [scrape](https://darkcrawl.dev/docs/endpoints/scrape/) options, applied to every page.                  |
| `webhook`                                         | Send the job’s events to your receiver. See [Webhooks](https://darkcrawl.dev/docs/api-reference/webhooks/). |

`prompt`, `robotsUserAgent` and `zeroDataRetention` are accepted and ignored, with a warning. In `scrapeOptions`, `maxAge` and `storeInCache` are ignored too: a crawl always reads fresh.

A crawl keeps going after a restart. A page that was in flight is read again, and each page is counted once.

`GET /v2/crawl/{job_id}/errors` lists the pages a job could not read, with a `code` and a short `error` for each, and the pages `robots.txt` told it to skip.

## Limits

Starting a crawl counts as one request and reserves its pages, up to `limit`. The pages it reads are charged when it ends and the rest is released. A crawl can reach the plan’s requests, pages, jobs running at once and pages per crawl. A status read is not a request, but it has a limit of its own. The values are on [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/).

## Reference

- [POST /v2/crawl](https://darkcrawl.dev/docs/api-reference/crawl/post-v2-crawl/)
- [`GET /v2/crawl/{job_id}`](https://darkcrawl.dev/docs/api-reference/crawl/get-v2-crawl-job-id/)
- [`DELETE /v2/crawl/{job_id}`](https://darkcrawl.dev/docs/api-reference/crawl/delete-v2-crawl-job-id/)
- [`GET /v2/crawl/{job_id}/errors`](https://darkcrawl.dev/docs/api-reference/crawl/get-v2-crawl-job-id-errors/)
- To read a list of pages as one job, use [POST /v2/batch/scrape](https://darkcrawl.dev/docs/api-reference/batch-scrape/post-v2-batch-scrape/).
