# Working with onion sites

> What to expect from Tor, stored copies, redaction and the injection check, and what DarkCrawl never fetches.

Works with Tor

An onion site is not an ordinary web server. DarkCrawl reaches it over Tor, and what it will and will not fetch is fixed in code.

## Tor timing

A request to an onion site goes through Tor, so a page can take longer to answer than on the open web, and a site can be down when you ask.

- **Timeout.** `timeout` is in milliseconds and defaults to 120000. It starts when the request arrives and covers the wait for a free fetch slot, the fetch and every retry. A request with less than 2 seconds left cannot reach an onion service and answers `408 SCRAPE_TIMEOUT` without fetching.
- **A site that does not answer.** The request fails with `502 ONION_UNREACHABLE`. A page behind an anti-DDoS queue or a CAPTCHA fails with `502 GATED`. Ask again later.
- **Tor itself.** When Tor is down, a scrape answers `503 TOR_NOT_READY`. That is not counted against the site.
- **SDK retries.** The Firecrawl SDKs send a request again when they get a 502, up to 3 times by default. To send it once, create the client with `max_retries=1` (Python) or `maxRetries: 1` (JavaScript).
- **Python.** The Python SDK sets no HTTP timeout of its own. DarkCrawl ends every scrape by its `timeout`.

Plan for a slow answer: allow more time per request than you would for a site on the open web, and check each result before you rely on its content.

## Stored copies

A scrape fetches the page fresh unless you ask for a stored copy. Set `maxAge` in milliseconds and DarkCrawl serves the newest stored capture of the same URL that is no older than that, and fetches only when there is none. The reply’s `metadata.cacheState` says `hit` or `miss`, and `metadata.cachedAt` says when the content was fetched.

The Python SDK sends `maxAge` of 4 hours unless you set `max_age`. The JavaScript SDK sends no default. Pass `max_age=0` (Python) or `maxAge: 0` (JavaScript) for a fresh page.

A host blocked after a copy was stored is never served from it.

## Redacting personal data

`redactPII` masks personal data in the text a scrape returns. It is off unless you ask. `true` masks every entity, in mode `accurate`, written as a tag such as `<EMAIL>`. An object chooses the `mode`, the `entities` and the `replaceStyle`.

- **Entities.** `PERSON`, `EMAIL`, `PHONE`, `LOCATION`, `FINANCIAL` and `SECRET`, in upper case.
- **Modes.** `accurate` masks what the rules are sure of. `aggressive` also masks any separated number of 7 to 15 digits that is not a date, an IP address, a version, an amount or a list of years. `fast` uses the `accurate` rules and makes no model call, so names and places are not masked.
- **Styles.** `tag` writes `<EMAIL>`, `mask` writes one `*` for each character, and `remove` deletes the text.
- **Names and places.** A model finds them, not rules.

`html`, `rawHtml`, `links` and the other raw formats come back unmasked, and the reply carries a warning that says so. A URL field is never masked. A value DarkCrawl does not recognise is a `400 BAD_REQUEST` that names the field.

## Checking for prompt injection

`checkPromptInjection` refuses a page that holds text written to hijack an AI that reads it. It is a JSON boolean and off unless you send `true`. It first scans the text a reader does not see, such as HTML comments and hidden elements, for fixed phrases, then, when the request already sends the page to a model, asks the model.

A refused page comes back as `403 SCRAPE_PROMPT_INJECTION_DETECTED` with no content. The reply’s `details.captureId` names the stored capture.

## What DarkCrawl never fetches

- **The clear web.** Only valid v3 `.onion` addresses are fetched. Any other URL is refused with `400 POLICY_FORBIDDEN`.
- **Blocked hosts.** A host on a blocklist is refused, and a page from one is never served from a stored copy.
- **Anything that changes a site.** DarkCrawl sends no forms and no logins. It sends `GET` and `HEAD` requests, and a page drawn in the browser may send small background `POST` requests of its own to its own site. Pages are parsed in a sandbox, apart from the API.

## Limits

A request can also reach a limit of your plan, such as calls in a minute, pages or running jobs. They are named, with their values, on [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/).

## Onion addresses in the docs

Addresses on these pages are text, never links. A made-up address stands in for a real one in every example. Copy a real address into your request, not into a browser.
