# The Toolkit

Everything Crawl4AI does is a tool. You find one, read what it takes and returns, and run it. Three calls, one key, and every reply has the same shape.

## Find, read, run

1. **Find** a tool: `GET https://api.crawl4ai.com/tools?q=video+transcript`. Free, no key.
2. **Read** it: `GET https://api.crawl4ai.com/tools/youtube-captions`. Its inputs, what comes back, its cost. Free, no key.
3. **Run** it: `POST https://api.crawl4ai.com/tools/youtube-captions` with your key. You pay only when it returns something.

## Try it here

The same search the directory uses, on this page. Type what you need.

Search the tools: `GET https://api.crawl4ai.com/tools?q=<words>` (free, no key).

## Find a tool

`GET /tools` lists the tools, ranked for your words. No key is needed and nothing is charged. `HEAD` works on every read address too.

curl:

```bash
curl "https://api.crawl4ai.com/tools?q=amazon+price"
curl "https://api.crawl4ai.com/tools?kind=sites&q=reviews"
curl "https://api.crawl4ai.com/tools?source=linkedin"
curl "https://api.crawl4ai.com/tools?essential=true"
```



| name | type | default | description |
|---|---|---|---|
| q | string | - | Words or a sentence. Other names, small typos and a tool's own id are understood. The answer is the nearest tools, best first, with `match`: `strong` (the first tool holds every word and leads clearly: run it), `possible` (several fit, or a word is in no tool: `unmatched` lists it; read the lines and decide), `none`. |
| kind | string | - | `pages` (read pages), `search`, `people` (people and companies) or `sites` (data tools, one site each). |
| source | string | - | A site id, e.g. `amazon`, `linkedin`, `youtube`. |
| status | string | - | `verified`, `beta` or `failing`. |
| essential | bool | - | `true`: only the 11 fundamental tools, the tools that work on any website. |
| limit · cursor | int · string | 50 | Tools on a page, at most 200; `next_cursor` from the last answer gives the next page. |

The answer is `{tools, total, counts, next_cursor, version}`. Each tool comes back as `{id, name: [lead, rest], source, kind, summary, cost, typical, status, essential, beta}`.

## Read a tool

`GET /tools/{id}` gives one tool in full: its `inputs` (name, type, required, help, example), `examples`, `output.fields` (name and meaning), `cost`, `status` and `input_schema` (a JSON Schema of its inputs). Free, no key. An unknown id answers `404 tool_not_found` with `did_you_mean`, the three closest ids. `GET /tools/{id}/status` answers `{tool, status}` alone.

curl:

```bash
curl "https://api.crawl4ai.com/tools/amazon-product"
```

The status: a fundamental tool is always `verified`. A data tool is `verified` while its checks pass in this region, `failing` after its checks fail, and `beta` otherwise.

## Run a tool

`POST /tools/{id}` takes the tool's inputs as the JSON body (at most 8 MB) and runs it on your key, at the price of the tool's older address. The inputs have the same names and the same defaults as there.

curl:

```bash
curl -X POST https://api.crawl4ai.com/tools/scrape \
  -H "Authorization: Bearer $CRAWL4AI_API_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}'
```

Python:

```python
import os, requests

r = requests.post("https://api.crawl4ai.com/tools/scrape",
                  headers={"Authorization": f"Bearer {os.environ['CRAWL4AI_API_KEY']}"},
                  json={"url": "https://example.com"}, timeout=120)
print(r.json()["data"]["markdown"])
```

Node:

```javascript
const r = await fetch("https://api.crawl4ai.com/tools/scrape", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.CRAWL4AI_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com" }),
});
console.log((await r.json()).data.markdown);
```

## One reply shape

Every reply has the same shape:

```json
{ "tool": "amazon-product", "request_id": "req_9f41c7d0a1b2c3d4", "took_ms": 1412,
  "usage": { "credits": 1.0 },
  "rows": [ { "asin": "B0F5HSNDXF", "title": "…", "price": 39.99 } ],
  "data": { … the rest of the tool's answer … } }
```

A tool that returns records puts them under `rows`; everything else of its answer is under `data`. A part that is empty is left out.

| Tool | Answers under |
|---|---|
| search, serp, extract, scan, price, every data tool | `rows` |
| lead with `find` `people`, `companies` or `industries` | `rows` |
| verify with `check` `email` | `rows` (the one address is `rows[0]`) |
| scrape | `data` (the page is `data.markdown`) |
| answer | `data` |
| site, verify with `check` `list`, a job-only data tool | `data` (a job: `data.job_id` and `data.poll`) |
| watch | `data` (the new watch) |
| lead with `find` `enrich`, `email`, `phone` or `company` | `data` |

These headers come back with every run:

| Header | What it holds |
|---|---|
| `x-c4-cost` | What this call cost, in credits (the same figure as `usage.credits`). |
| `x-c4-balance` | Your credit after this call. |
| `x-c4-allowance-left` | Credits left under this month's allowance (Free, Starter). |
| `x-c4-request-id` | The call's id, the same as `request_id`. Quote it when you write to us. |
| `retry-after` | Seconds to wait, on a `429` or a `503`. |
| `x-c4-watch-changes` | How many changes on your watches you have not read yet. |

## Options

Options that apply to every tool go in headers, so the body stays the tool's inputs:

| name | type | default | description |
|---|---|---|---|
| Crawl4AI-Fresh | header | - | `true`: skip our cache and fetch live, at the live price. `?fresh=1` on the address does the same. Watch, lead and verify have no cache. |
| Idempotency-Key | header | - | Sent with the call as it is. Scrape jobs (`POST /tools/batch` with `scrape`) honour it: a retry with the same key returns the same job. Other tools do not deduplicate yet. |

There is no region option. `api.crawl4ai.com` picks the nearest region; to pin one, call its host: `eu-gate.crawl4ai.com`, `sin-gate.crawl4ai.com` or `us-gate.crawl4ai.com`. Every host serves `/tools`. See [Regions](https://crawl4ai.com/docs/regions).

## Estimate

`POST /tools/{id}/estimate` with the same body says what a run would cost, before it runs. Free. The answer is in the same envelope, under `data`: for `scrape`, `extract`, `search` and `answer` a range from real traffic (`min`, `max`, `text`); for every other tool the tool's cost rule (`data.text`, `data.rule`).

curl:

```bash
curl -X POST https://api.crawl4ai.com/tools/scrape/estimate \
  -H "Authorization: Bearer $CRAWL4AI_API_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://news.ycombinator.com"}'
```

## Batch

`POST /tools/batch` takes `{tool, inputs: [...], stream?}`: many inputs of one tool.

- `scrape` with many inputs starts one job of up to 10,000 pages. Each input's `url` is fetched; the first input's other options (`format`, `proxy`, `country`, `parse`) apply to all. The answer carries `data.job_id` and `data.poll`; follow it under [Jobs](#jobs).
- `scrape` with `"stream": true` takes up to 50 pages and answers them in the same call, as NDJSON: one JSON line per page as it finishes (with its `cost` in credits), then a last `{"summary": {...}}` line with the whole batch's cost.
- A data tool that runs as a job takes one input and starts that job.

Any other tool answers `422 invalid_input`. `Crawl4AI-Fresh` applies to a batch as to a run.

job:

```bash
curl -X POST https://api.crawl4ai.com/tools/batch \
  -H "Authorization: Bearer $CRAWL4AI_API_KEY" -H "Content-Type: application/json" \
  -d '{"tool":"scrape","inputs":[{"url":"https://a.com","format":"md"},{"url":"https://b.com"}]}'
# → {"tool":"scrape", ..., "data":{"job_id":"j_eu-…","poll":"/tools/jobs/j_eu-…", ...}}
```

stream:

```bash
# -N prints each line as it arrives
curl -N -X POST https://api.crawl4ai.com/tools/batch \
  -H "Authorization: Bearer $CRAWL4AI_API_KEY" -H "Content-Type: application/json" \
  -d '{"tool":"scrape","stream":true,"inputs":[{"url":"https://a.com"},{"url":"https://b.com"}]}'
```

## Jobs

A run that takes long is a job. Its answer carries `data.job_id` and `data.poll`, the address to follow it: `"/tools/jobs/<job_id>"`. Every job kind is followed here: a scrape batch, a site crawl, a data tool's job and a verify list.

| Route | Does |
|---|---|
| `GET /tools/jobs/{job_id}` | The state: `pending`, `running`, `done`, or `paused` with a `paused_reason`; the counts and the job's cost. A verify list holds its answers here. |
| `GET /tools/jobs/{job_id}/results` | The rows, one JSON object per line (NDJSON), each with a `seq` number. Page with `?after=N` (500 a page). |
| `POST /tools/jobs/{job_id}/retry` | Run the failed pages again. |
| `DELETE /tools/jobs/{job_id}` | Stop the job. It ends as `paused`. |

Reading a job, its rows and stopping it cost nothing, so an empty balance never locks you out of a job you already paid for. Results are kept 3 days after the job ends.

Which tools answer with a job:

- `site` is always a job.
- `verify` with `check: "list"` is a job; its answers are in its state.
- A data tool that runs only as a job (for example `linkedin-company-people`) answers with a job.
- A data tool that runs both ways answers in the same call, waiting up to 300 s; send it to `POST /tools/batch` to run it as a job.

curl:

```bash
JOB=$(curl -s -X POST https://api.crawl4ai.com/tools/site \
  -H "Authorization: Bearer $CRAWL4AI_API_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://docs.crawl4ai.com/","max_pages":20}' | jq -r .data.job_id)

# a new job is pending, then running: wait for done or paused
while true; do
  S=$(curl -s https://api.crawl4ai.com/tools/jobs/$JOB -H "Authorization: Bearer $CRAWL4AI_API_KEY" | jq -r .status)
  case "$S" in done|paused) break;; esac; sleep 5
done

curl -s "https://api.crawl4ai.com/tools/jobs/$JOB/results?after=0" -H "Authorization: Bearer $CRAWL4AI_API_KEY"
```

## Which tool

Scrape reads one page. Extract gives rows from a page. Crawl (`site`) does a whole site. For a named site, use its data tool first: it is cheaper and needs no parsing. The 11 fundamental tools work on any website; each links to its page.

| id | what you get | a minimal body |
|---|---|---|
| [scrape](https://crawl4ai.com/tools/scrape) | Any URL in, clean Markdown out | `{"url": "https://example.com"}` |
| [extract](https://crawl4ai.com/tools/extract) | Typed rows from plain words | `{"url": "https://books.toscrape.com", "instruction": "title, price and availability of every book"}` |
| [site](https://crawl4ai.com/tools/site) | Every page of a site as Markdown, as one job | `{"url": "https://docs.crawl4ai.com/", "max_pages": 10}` |
| [scan](https://crawl4ai.com/tools/scan) | Every URL of a site, without crawling | `{"domain": "docs.crawl4ai.com"}` |
| [price](https://crawl4ai.com/tools/price) | Every plan and price on a pricing page | `{"sites": ["hubspot.com", "canva.com"], "country": "gb"}` |
| [watch](https://crawl4ai.com/tools/watch) | An alert when a page changes your way | `{"url": "https://example.com/pricing", "watch": "a plan gets more expensive", "email": "you@example.com"}` |
| [search](https://crawl4ai.com/tools/search) | Ranked web results, pages read on request | `{"q": "rust programming language"}` |
| [serp](https://crawl4ai.com/tools/serp) | Google's results page as data | `{"q": "best crm software", "country": "us"}` |
| [answer](https://crawl4ai.com/tools/answer) | A written answer with its sources | `{"q": "capital of france"}` |
| [lead](https://crawl4ai.com/tools/lead) | People and companies with checked emails | `{"find": "people", "where": {"company": {"industry": "Dentists", "country": ["at"]}}}` |
| [verify](https://crawl4ai.com/tools/verify) | Valid, invalid, accept_all or unknown | `{"check": "email", "email": "hello@crawl4ai.com"}` |

`lead` picks its search with `find` (`people`, `companies`, `enrich`, `email`, `phone`, `company`, `industries`); `verify` with `check` (`email`, `list`, `domain`). The 98 [data tools](https://crawl4ai.com/tools?group=data) are found with `GET /tools?kind=sites`.

## Errors

Every error answers `{error, message, tool?, request_id?}`, with its own fields next to them.

| status | reason | meaning | billed |
|---|---|---|---|
| 401 | unauthorized | No key, or not a valid one, on a run: send `Authorization: Bearer <your key>`. | free |
| 404 | tool_not_found | No tool with that id; `did_you_mean` lists the three closest. | free |
| 422 | invalid_input | The body is not a JSON object of the tool's inputs, or a required input is missing; `message` and `details[].problem` say which. | free |
| 402 | no_credit · spend_cap · plan_cap | Out of credit, over your own cap, or over your plan's allowance, as at the older addresses; `actions` says what to do. | free |
| 405 | method_not_allowed | A method the address does not take; `message` lists the routes. | free |
| 429 | public_rate_limit | Too many calls without a key from one address. Only keyless calls (finding and reading tools) meet it; a keyed run meets your plan's limits. | free |
| 503 | tool_failing | The tool's daily check is failing; it was not run. | free |
| 503 | toolkit_unavailable | The tool catalog is not on this host yet; the older addresses work. | free |
| 502 | source_failed | The tool did not answer. | free |
| 504 | timeout | The tool did not answer in time. | free |

Any other error is the tool's own, as its older address answers it, with `tool` and `request_id` added. A failed run costs nothing.

> **Note: Private tools**
>
> An organization's private tools are not in `/tools` yet. Run them at their data tool address, `POST /recipes/{name}`, which checks who owns them.

## Older addresses (still supported)

`POST /scrape`, `GET /serp`, `POST /recipes/amazon-product` and every other older address work as before, at the same price. Use `POST /tools/{id}` for new code. [Older addresses](https://crawl4ai.com/docs/older) lists each one and what differs.

---
Source: https://crawl4ai.com/docs/toolkit
