# API Reference

> Every route of the DarkCrawl API, with its fields, an example request and reply, and its errors.

The DarkCrawl API reads `.onion` sites over Tor and answers in JSON. Every route is under `https://api.darkcrawl.dev`. The routes that start with `/v2` follow Firecrawl’s v2 API, so the Firecrawl SDKs reach them. The routes that start with `/darkcrawl/v1` are DarkCrawl’s own. The routes that start with `/api` read your own company: its plan, usage and activity. `GET /api/plans` lists the plans on offer.

Start with these four pages. Each answers a question you will have on your first call.

| Page                                                                       | What it covers                                                                     |
| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| [Authentication](https://darkcrawl.dev/docs/api-reference/authentication/) | How to send your key, and what a refused key looks like.                           |
| [Errors](https://darkcrawl.dev/docs/api-reference/errors/)                 | The shape of an error, every code, and what to do about each.                      |
| [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/)       | What your plan allows, what counts against it, and what a refused call looks like. |
| [Webhooks](https://darkcrawl.dev/docs/api-reference/webhooks/)             | The events a crawl, a batch or a monitor sends to your receiver.                   |

Only valid v3 onion addresses are read. A clear-web address is refused with `400 POLICY_FORBIDDEN`, and a malformed onion address with `400 INVALID_ONION`.

## Routes

Each route has a page with its fields, a request in curl, Python and Node, an example reply, and the errors it can answer. `GET /health` needs no key and is on [its own page](https://darkcrawl.dev/docs/api-reference/health/).

### Scrape

- [`POST /v2/scrape`](https://darkcrawl.dev/docs/api-reference/scrape/post-v2-scrape/): Read one onion page and get Markdown, links, metadata, indicators and an evidence record.

### Crawl

- [`POST /v2/crawl`](https://darkcrawl.dev/docs/api-reference/crawl/post-v2-crawl/): Start a crawl of one onion site. It returns a job id to read.
- [`GET /v2/crawl/{job_id}`](https://darkcrawl.dev/docs/api-reference/crawl/get-v2-crawl-job-id/): Read a crawl: its status, and the pages it has read so far.
- [`DELETE /v2/crawl/{job_id}`](https://darkcrawl.dev/docs/api-reference/crawl/delete-v2-crawl-job-id/): Cancel a crawl. Pages already read stay.
- [`GET /v2/crawl/{job_id}/errors`](https://darkcrawl.dev/docs/api-reference/crawl/get-v2-crawl-job-id-errors/): List the pages of a crawl that failed or were skipped.

### Batch scrape

- [`POST /v2/batch/scrape`](https://darkcrawl.dev/docs/api-reference/batch-scrape/post-v2-batch-scrape/): Scrape many onion pages as one job, with the same options for each.
- [`GET /v2/batch/scrape/{job_id}`](https://darkcrawl.dev/docs/api-reference/batch-scrape/get-v2-batch-scrape-job-id/): Read a batch: its status, and the pages it has read so far.
- [`DELETE /v2/batch/scrape/{job_id}`](https://darkcrawl.dev/docs/api-reference/batch-scrape/delete-v2-batch-scrape-job-id/): Cancel a batch. Pages already read stay.
- [`GET /v2/batch/scrape/{job_id}/errors`](https://darkcrawl.dev/docs/api-reference/batch-scrape/get-v2-batch-scrape-job-id-errors/): List the pages of a batch that failed or were skipped.

### Map

- [`POST /v2/map`](https://darkcrawl.dev/docs/api-reference/map/post-v2-map/): List the pages of one onion site, found by a short crawl of its links.

### Search

- [`POST /v2/search`](https://darkcrawl.dev/docs/api-reference/search/post-v2-search/): Search the pages DarkCrawl has stored, and Ahmia for what is missing when the server is set up to ask it.

### Stored captures

- [`GET /darkcrawl/v1/search`](https://darkcrawl.dev/docs/api-reference/stored-captures/get-darkcrawl-v1-search/): Search the text of the captures DarkCrawl has stored.

### Parse

- [`POST /v2/parse`](https://darkcrawl.dev/docs/api-reference/parse/post-v2-parse/): Upload a PDF, an Office file or an image and get its text back. An image is read by OCR, only with the image parser on.
- [`GET /v2/parse/formats`](https://darkcrawl.dev/docs/api-reference/parse/get-v2-parse-formats/): List the file types parse reads.

### Extract

- [`POST /v2/extract`](https://darkcrawl.dev/docs/api-reference/extract/post-v2-extract/): Not offered: Firecrawl deprecated extract. This route always refuses.
- [`GET /v2/extract/{extract_id}`](https://darkcrawl.dev/docs/api-reference/extract/get-v2-extract-extract-id/): Not offered: Firecrawl deprecated extract. This route always refuses.

### Agent

- [`POST /v2/agent`](https://darkcrawl.dev/docs/api-reference/agent/post-v2-agent/): Start an agent run: it reads pages to answer a prompt, and cites them.
- [`GET /v2/agent/{job_id}`](https://darkcrawl.dev/docs/api-reference/agent/get-v2-agent-job-id/): Read an agent run: its status, its answer and the pages it cites.
- [`DELETE /v2/agent/{job_id}`](https://darkcrawl.dev/docs/api-reference/agent/delete-v2-agent-job-id/): Cancel an agent run.
- [`GET /v2/agent/threads/{thread_id}`](https://darkcrawl.dev/docs/api-reference/agent/get-v2-agent-threads-thread-id/): Read a thread: the runs asked in it, oldest first.

### Monitor

- [`GET /v2/monitor`](https://darkcrawl.dev/docs/api-reference/monitor/get-v2-monitor/): List your monitors, newest first.
- [`POST /v2/monitor`](https://darkcrawl.dev/docs/api-reference/monitor/post-v2-monitor/): Create a monitor: targets to read on a schedule, and a report of what changed.
- [`GET /v2/monitor/{monitor_id}`](https://darkcrawl.dev/docs/api-reference/monitor/get-v2-monitor-monitor-id/): Read one monitor.
- [`PATCH /v2/monitor/{monitor_id}`](https://darkcrawl.dev/docs/api-reference/monitor/patch-v2-monitor-monitor-id/): Change a monitor. Only the fields you send change.
- [`DELETE /v2/monitor/{monitor_id}`](https://darkcrawl.dev/docs/api-reference/monitor/delete-v2-monitor-monitor-id/): Delete a monitor and its checks. The captures it made stay.
- [`GET /v2/monitor/{monitor_id}/checks`](https://darkcrawl.dev/docs/api-reference/monitor/get-v2-monitor-monitor-id-checks/): List the checks of a monitor, newest first.
- [`GET /v2/monitor/{monitor_id}/checks/{check_id}`](https://darkcrawl.dev/docs/api-reference/monitor/get-v2-monitor-monitor-id-checks-check-id/): Read one check with its pages, and for a changed page its diff.
- [`POST /v2/monitor/{monitor_id}/run`](https://darkcrawl.dev/docs/api-reference/monitor/post-v2-monitor-monitor-id-run/): Run a check now, outside the schedule.

### Leak library

- [`GET /darkcrawl/v1/leaks/check`](https://darkcrawl.dev/docs/api-reference/leak-library/get-darkcrawl-v1-leaks-check/): Is a company or a domain listed on a ransomware leak site?
- [`GET /darkcrawl/v1/leaks/countdowns`](https://darkcrawl.dev/docs/api-reference/leak-library/get-darkcrawl-v1-leaks-countdowns/): Which listings reach their deadline soon?
- [`GET /darkcrawl/v1/leaks/recent`](https://darkcrawl.dev/docs/api-reference/leak-library/get-darkcrawl-v1-leaks-recent/): What was posted on the leak sites lately?
- [`GET /darkcrawl/v1/leaks/sites`](https://darkcrawl.dev/docs/api-reference/leak-library/get-darkcrawl-v1-leaks-sites/): Which leak sites does a group have, and are they up?

### Watches

- [`GET /darkcrawl/v1/watches`](https://darkcrawl.dev/docs/api-reference/watches/get-darkcrawl-v1-watches/): List your watches, oldest first.
- [`POST /darkcrawl/v1/watches`](https://darkcrawl.dev/docs/api-reference/watches/post-darkcrawl-v1-watches/): Create a watch: words to look for in new pages, and the channels to tell.
- [`GET /darkcrawl/v1/watches/{watch_id}`](https://darkcrawl.dev/docs/api-reference/watches/get-darkcrawl-v1-watches-watch-id/): Read one watch.
- [`PATCH /darkcrawl/v1/watches/{watch_id}`](https://darkcrawl.dev/docs/api-reference/watches/patch-darkcrawl-v1-watches-watch-id/): Change a watch: its name, terms, channels or state.
- [`DELETE /darkcrawl/v1/watches/{watch_id}`](https://darkcrawl.dev/docs/api-reference/watches/delete-darkcrawl-v1-watches-watch-id/): Delete a watch with its hits and alerts.
- [`GET /darkcrawl/v1/watches/{watch_id}/hits`](https://darkcrawl.dev/docs/api-reference/watches/get-darkcrawl-v1-watches-watch-id-hits/): List the pages a watch matched, newest first.

### Alert channels

- [`GET /darkcrawl/v1/channels`](https://darkcrawl.dev/docs/api-reference/alert-channels/get-darkcrawl-v1-channels/): List your alert channels.
- [`POST /darkcrawl/v1/channels`](https://darkcrawl.dev/docs/api-reference/alert-channels/post-darkcrawl-v1-channels/): Create an alert channel: a webhook, a Slack address or an email list.
- [`GET /darkcrawl/v1/channels/{channel_id}`](https://darkcrawl.dev/docs/api-reference/alert-channels/get-darkcrawl-v1-channels-channel-id/): Read one alert channel.
- [`PATCH /darkcrawl/v1/channels/{channel_id}`](https://darkcrawl.dev/docs/api-reference/alert-channels/patch-darkcrawl-v1-channels-channel-id/): Change a channel. Only the fields you send change.
- [`DELETE /darkcrawl/v1/channels/{channel_id}`](https://darkcrawl.dev/docs/api-reference/alert-channels/delete-darkcrawl-v1-channels-channel-id/): Delete a channel and its deliveries.
- [`POST /darkcrawl/v1/channels/{channel_id}/secret`](https://darkcrawl.dev/docs/api-reference/alert-channels/post-darkcrawl-v1-channels-channel-id-secret/): Make a new signing secret for a webhook channel.
- [`POST /darkcrawl/v1/channels/{channel_id}/test`](https://darkcrawl.dev/docs/api-reference/alert-channels/post-darkcrawl-v1-channels-channel-id-test/): Send a test alert to a channel now.

### Alerts

- [`GET /darkcrawl/v1/alerts`](https://darkcrawl.dev/docs/api-reference/alerts/get-darkcrawl-v1-alerts/): List the alerts raised for your monitors and watches, newest first.
- [`GET /darkcrawl/v1/alerts/{alert_id}`](https://darkcrawl.dev/docs/api-reference/alerts/get-darkcrawl-v1-alerts-alert-id/): Read one alert.

### Your company

- [`GET /api/org`](https://darkcrawl.dev/docs/api-reference/your-company/get-api-org/): Your company: its plan, its limits and what it has used today.
- [`GET /api/org/activity`](https://darkcrawl.dev/docs/api-reference/your-company/get-api-org-activity/): Your company's calls, newest first.
- [`GET /api/org/usage`](https://darkcrawl.dev/docs/api-reference/your-company/get-api-org-usage/): What your company used, by day and by route.
- [`GET /api/plans`](https://darkcrawl.dev/docs/api-reference/your-company/get-api-plans/): The plans DarkCrawl offers, with the limits of each.
