# Plain HTTP

> Call DarkCrawl with any HTTP client. One JSON envelope for every reply, and one for every error.

Any client that sends JSON works. Send your key as a bearer token in the `Authorization` header, and the body as `application/json`. The hosted API is `https://api.darkcrawl.dev`.

**curl**

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

**Python**

```python
import os
import requests

resp = requests.post(
    "https://api.darkcrawl.dev/v2/scrape",
    headers={"Authorization": "Bearer " + os.environ["DARKCRAWL_API_KEY"]},
    json={
        "url": "http://exampleonionq7x2mfk4lzr5w3ty6hbnc2jdu7avs4ekp5gw3xmlq2zr.onion/notice",
        "formats": ["markdown", "links"],
        "onlyMainContent": True,
        "timeout": 120000,
    },
    timeout=150,
)
print(resp.json())
```

**Node**

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

The samples read the key from `DARKCRAWL_API_KEY`. The [guides](https://darkcrawl.dev/docs/endpoints/scrape/) show a request for each endpoint, and the [API Reference](https://darkcrawl.dev/docs/api-reference/) lists every route.

## The envelope

A reply is JSON. A success holds `"success": true` and, for most routes, the result in `data`. Job routes answer with an `id`, and a status route answers with the job’s `status`.

An error uses Firecrawl’s envelope:

- `success` is `false`.
- `code` is a short code such as `UNAUTHORIZED` or `RATE_LIMITED`.
- `error` is one line of text.
- `details`, when there is one, holds fields such as `field` or `reason`.

Errors never include page content or stack traces. [Errors](https://darkcrawl.dev/docs/api-reference/errors/) lists the codes.

A request over a limit of your plan answers `429 RATE_LIMITED`, with a `Retry-After` header in seconds, or `402 QUOTA_EXCEEDED`. The limits are on [Rate limits](https://darkcrawl.dev/docs/api-reference/rate-limits/).

## Time

Every request goes over Tor, so a page can take a while to answer. Set your client’s timeout above the request’s own `timeout`. The samples add 30 seconds. [Working with onion sites](https://darkcrawl.dev/docs/onion-sites/) says what to expect.
