# Search

> Search the onion pages DarkCrawl holds, and the stored captures by their text.

DarkCrawl searches onion services only, never the clear web. There are two routes: `POST /v2/search`, which is Firecrawl’s search, and `GET /darkcrawl/v1/search`, which searches the text of the pages DarkCrawl has already stored.

## Search onion services

`POST /v2/search` answers from the pages DarkCrawl has stored first, best match first. When they give fewer results than `limit` and the server is set up to ask Ahmia, it asks Ahmia for the rest. A page both found appears once, as the stored one.

**curl**

```bash
curl -X POST https://api.darkcrawl.dev/v2/search \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"debian mirror","limit":5}'
```

**Python**

```python
import os
import requests

resp = requests.post(
    "https://api.darkcrawl.dev/v2/search",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    json={
        "query": "debian mirror",
        "limit": 5,
    },
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/v2/search", {
  method: "POST",
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "query": "debian mirror",
    "limit": 5
  }),
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

```json
{
  "success": true,
  "data": {
    "web": [
      {
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/mirrors",
        "title": "Mirror list",
        "description": "A plainly fictional list of mirrors.",
        "position": 1,
        "captureId": "01K0EXAMPLECAPTURE0000000A",
        "fetchedAt": "2026-11-26T10:00:00+00:00"
      },
      {
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/forum/thread/1",
        "title": "Sample thread",
        "description": "Nothing real here.",
        "position": 2
      }
    ]
  }
}
```

Only a result from stored pages has `captureId` (the capture it was read from) and `fetchedAt`. A result from a site that has a category label also carries `category`, and one from a clone carries `cloneOf`.

Ahmia sees the search terms it is asked, not who you are. Searches are not stored.

| Option           | What it does                                                                                                                                                    |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `query`          | 1 to 500 characters. Required.                                                                                                                                  |
| `limit`          | 1 to 50, 5 by default.                                                                                                                                          |
| `sources`        | Only `["web"]`. `news` and `images` answer `400 BAD_REQUEST`.                                                                                                   |
| `timeout`        | Milliseconds, 1000 to 300000, 120000 by default.                                                                                                                |
| `scrapeOptions`  | Read each result as a [scrape](https://darkcrawl.dev/docs/endpoints/scrape/) does and return the page’s document. A page that fails comes back with an `error`. |
| `includeClones`  | DarkCrawl’s own. `true` keeps the results of clone sites that are folded away by default.                                                                       |
| `siteCategories` | DarkCrawl’s own. Keep only the stored results of sites with one of these labels, and leave Ahmia out.                                                           |

`tbs`, `location`, `country`, `categories`, `includeDomains`, `excludeDomains` and a few more are accepted and ignored, with a warning. Any other field is a `400`.

When Ahmia cannot answer and nothing stored matched, the search answers `503 SEARCH_UNAVAILABLE`, with `details.reason` saying why. When it cannot answer and something stored matched, the search succeeds with a warning.

## Search stored captures

`GET /darkcrawl/v1/search` searches the main-content text and title of every stored page and the text of every stored document. Nothing is fetched and nobody else sees the terms. It gives one result per page: the newest capture that holds the terms.

**curl**

```bash
curl 'https://api.darkcrawl.dev/darkcrawl/v1/search?q=debian+mirror&limit=10' \
  -H "Authorization: Bearer $DARKCRAWL_API_KEY"
```

**Python**

```python
import os
import requests

resp = requests.get(
    "https://api.darkcrawl.dev/darkcrawl/v1/search?q=debian+mirror&limit=10",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    timeout=330,
)
print(resp.json())
```

**Node**

```javascript
const resp = await fetch("https://api.darkcrawl.dev/darkcrawl/v1/search?q=debian+mirror&limit=10", {
  headers: {
    Authorization: "Bearer " + process.env.DARKCRAWL_API_KEY,
  },
  signal: AbortSignal.timeout(330000),
});
console.log(await resp.json());
```

```json
{
  "results": [
    {
      "captureId": "01K0EXAMPLECAPTURE0000000A",
      "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/mirrors",
      "title": "Mirror list",
      "snippet": "…a plainly fictional debian mirror list…",
      "host": "exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion",
      "fetchedAt": "2026-11-26T10:00:00+00:00",
      "jobId": null
    }
  ],
  "next": null,
  "truncated": false
}
```

- **Query.** `q` is 1 to 500 characters. Plain terms must all match, and `"a quoted phrase"` stays whole. There is no other syntax: `AND`, `OR`, `NOT`, `*` and `-` are plain text. Case and accents do not matter.
- **Filters.** `host` keeps one exact onion host, `since` keeps captures fetched at or after an ISO 8601 time with a zone, and `jobId` keeps the pages a crawl job read.
- **Paging.** `limit` is 1 to 50 (10 by default) and `offset` is 0 to 450. `next` is the next page’s offset, or `null` on the last page. `truncated: true` means the answer was cut: narrow the query.
- **Never indexed.** Files, gated pages, failed reads and downloaded text.

## Limits

Each search counts as one request. `POST /v2/search` with `scrapeOptions` also reserves pages, up to `limit`, and charges the pages it reads. A search can reach the plan’s requests a minute, requests a day and pages. The values are on [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/).

## Reference

- [POST /v2/search](https://darkcrawl.dev/docs/api-reference/search/post-v2-search/)
- [GET /darkcrawl/v1/search](https://darkcrawl.dev/docs/api-reference/stored-captures/get-darkcrawl-v1-search/)
