Skip to main content
Glama
crawlapi

crawlapi

Official
by crawlapi-dev
README.md
# crawl

[Docs](https://docs.crawlapi.dev/cli) · [Hosted MCP](https://docs.crawlapi.dev/mcp) · [Website](https://crawlapi.dev) · [Privacy](https://crawlapi.dev/privacy) · [Security](https://crawlapi.dev/security#reporting-a-weakness) · [License](#license)

The standalone CLI and local MCP server for [crawlapi](https://crawlapi.dev). Read JavaScript-rendered web pages, PDFs, Office documents, CSV/JSON/RSS feeds, X posts, and YouTube videos as clean markdown or structured JSON from your terminal or coding agent.

One native Rust binary with no runtime dependencies. `stdout` carries only the page; receipts, progress, and errors go to `stderr`.

```bash
crawl example.com                          # markdown on stdout
crawl news.ycombinator.com -f json         # structured object, tables, JSON-LD, embedded state
crawl news.ycombinator.com --links         # page links, one per line
crawl news.ycombinator.com --links --json  # compact JSON with links and usage
crawl example.com --json | jq .usage       # full API response with credits and request id
crawl example.com -o pages/example.md      # write to a file (creates folders; -o - writes stdout)
crawl -i urls.txt -o pages/                # read a URL list; rerun to resume
cat urls.txt | crawl -i - --json           # one JSON line per page, then a summary
crawl site docs.example.com -o docs/       # crawl a same-host site breadth first
```

Global flags (`--json`, `-q`, `--no-color`) work before or after any command.

## Install

```bash
curl -fsSL https://crawlapi.dev/install.sh | sh     # macOS, Linux
brew install crawlapi-dev/tap/crawlapi              # macOS, Linux
npm i -g crawlapi                                   # or once: npx crawlapi example.com
irm https://crawlapi.dev/install.ps1 | iex          # Windows (PowerShell)
cargo install crawlapi --locked                     # from source (or: cargo binstall crawlapi)
```

The install scripts support resumable downloads, pin a single release before fetching, and verify the archive's SHA-256 checksum before unpacking. The install scripts, Homebrew, and npm also install the binary as `crawlapi` for systems where another `crawl` binary appears earlier on `PATH`. Run `crawl doctor` to verify your install, `PATH`, credentials, and API connectivity.

Every release publishes `SHA256SUMS` and a GitHub build provenance attestation; see [SECURITY.md](https://github.com/crawlapi-dev/crawl/blob/main/SECURITY.md) for verification commands.

## Sign in

```bash
crawl login                                         # approve in your browser; saves a CLI key
pbpaste | crawl login --key-stdin                   # store an existing key from stdin
export CRAWLAPI_API_KEY=...                         # shell override; wins over saved key
```

Credentials stay out of shell history and are saved locally in `credentials.toml` with owner-only permissions. `crawl login` mints a `cli`-scoped key for all commands including `crawl keys` and `crawl billing`; keys created in the dashboard or by `crawl keys create` are `scrape`-scoped (scrapes, `account`, `usage`, `requests`, and `doctor`). Run `crawl logout` to revoke this machine's key and remove it.

## AI agents and MCP

### Hosted MCP server (zero install)

Connect any MCP client directly to **`https://mcp.crawlapi.dev/mcp`** with browser OAuth sign-in and no API keys in config files:

```bash
claude mcp add --transport http --scope user crawlapi https://mcp.crawlapi.dev/mcp && claude mcp login crawlapi
codex mcp add crawlapi --url https://mcp.crawlapi.dev/mcp && codex mcp login crawlapi
opencode mcp add --global crawlapi --url https://mcp.crawlapi.dev/mcp && opencode mcp auth crawlapi
pi mcp add crawlapi --exposure direct --url https://mcp.crawlapi.dev/mcp && pi mcp login crawlapi
amp mcp add crawlapi https://mcp.crawlapi.dev/mcp
grok mcp add --transport http crawlapi https://mcp.crawlapi.dev/mcp && grok mcp login crawlapi
gemini extensions install https://github.com/crawlapi-dev/crawl
```

```json
{
  "mcpServers": {
    "crawlapi": {
      "url": "https://mcp.crawlapi.dev/mcp"
    }
  }
}
```

The hosted server exposes `scrape`, `site`, and `account` over OAuth 2.1 (or a `Bearer` API key). This repository also ships plugin manifests for Claude Code (`.claude-plugin/plugin.json`), Agent Plugins 1.0 / Codex / Antigravity (`plugin.json`, `mcp.json`, `mcp_config.json`), Cursor / Grok (`.cursor-plugin/plugin.json`), Gemini CLI (`gemini-extension.json`), and the Official MCP Registry (`server.json`). Page text is fenced as untrusted data before reaching your model, long pages paginate via `offset` / `next_offset`, and long `site` crawls return every page fetched so far if the time budget ends.

### Local MCP (`crawl mcp`) and agent skill

```bash
npx skills add crawlapi-dev/crawl                   # install the agent skill via skills.sh
crawl setup                                         # install the skill and print MCP commands
claude mcp add --transport stdio --scope user crawlapi -- crawl mcp   # Claude Code
codex mcp add crawlapi -- crawl mcp                 # Codex
pi mcp add crawlapi --exposure direct -- crawl mcp  # pi
opencode mcp add --global crawlapi -- crawl mcp     # OpenCode
amp mcp add crawlapi -- crawl mcp                   # Amp
grok mcp add crawlapi -- crawl mcp                  # Grok
gemini mcp add -s user crawlapi crawl mcp           # Gemini CLI
```

`crawl mcp` runs locally with four tools (`scrape`, `site`, `account`, `login`). It starts without a key and resolves credentials on every call — agents can invoke `login` from chat to show a browser approval link and finish sign-in automatically on the next tool call, while shell agents can use `crawl login --no-wait --json`. Page text is fenced as untrusted data, and large outputs spill to private temp files on disk. MCP configs carry only `{"command": "crawl", "args": ["mcp"]}`, never a key.

## Account commands

| Command | What it shows or does |
| --- | --- |
| `crawl account` | Balance, held credits, rate limits, active key, and key source |
| `crawl keys list` · `create --name NAME` · `revoke ID_OR_PREFIX` | Active keys with UTC timestamps; `create` prints a new key once; `revoke` takes id or prefix positionally (`--yes` for scripts) |
| `crawl usage [--days N \| --from D --to D] [--by-domain]` | Daily or per-domain request and credit totals |
| `crawl requests [--days N \| --from D --to D] [--limit 1-100]` | Latest requests, newest first |
| `crawl billing packs` · `buy PACK` · `purchases` · `auto-top-up` | Packs on sale, Stripe checkout link, purchase history, and auto top-up state |
| `crawl doctor` · `crawl completions SHELL` | Verify install/key/API; print shell completions (`bash`, `zsh`, `fish`, `powershell`, `elvish`) |

## Many pages and sites

`-i FILE` (or `-i -` for stdin) and multi-URL runs pace automatically to your account's rate and concurrency limits (`--concurrency N` lowers concurrency). With `-o FOLDER`, each page writes to `<host>/<path>.md` (or `.json`) alongside `.crawl-journal.jsonl`: rerunning skips completed pages and permanent failures, `--max-credits N` stops starting new pages at `N` credits, and Ctrl-C preserves everything already fetched.

`crawl site URL` reads the start page and follows links breadth first on the exact same **host and port**, bounded by `--max-pages` (`25`), `--max-depth` (`2`), and `--include` / `--exclude` path globs (such as `/docs/**`).

## Exit codes

| Code | Meaning | Next step |
| --- | --- | --- |
| `0` | Success (including sign-in walls with `metadata.login_required: true`) | Use the output |
| `1` | Unexpected CLI error | Report it |
| `2` | Invalid command or local path | Fix the arguments |
| `3` | Not signed in, key refused, or account suspended | Run `crawl login` (or contact support if suspended) |
| `4` | Out of credits, or `--max-credits` reached | Top up at [app.crawlapi.dev/billing](https://app.crawlapi.dev/billing), or raise `--max-credits` |
| `5` | Permanent page failure (`retryable: false`) | Do not retry |
| `6` | Temporary page failure (`retryable: true`) | Retry later |
| `7` | Network or service error | Retry with backoff |
| `8` | Partial batch failure | Rerun to retry the rest |
| `130` | Interrupted by Ctrl-C | Rerun to resume |

Run `crawl help exit-codes`, `crawl help formats`, `crawl help environment`, or `crawl help agents` for built-in reference topics. See [Credits and pricing](https://docs.crawlapi.dev/credits) for billing details.

## Security

- Credentials live in `CRAWLAPI_API_KEY` or a local `credentials.toml` file with owner-only permissions.
- Active keys are scrubbed from stdout, stderr, errors, debug logs, and MCP outputs (only `crawl keys create` prints a newly minted key once).
- Terminal and MCP outputs strip unsafe control sequences and fence fetched page text as untrusted data.
- Output paths stay strictly inside `-o`, and uncertain network drops report `Cost: unknown` instead of retrying silently.

Report security issues privately via [SECURITY.md](https://github.com/crawlapi-dev/crawl/blob/main/SECURITY.md).

## Building from source

```bash
cargo build --release
cargo test
```

## License

Licensed under either of:

- [Apache License, Version 2.0](https://github.com/crawlapi-dev/crawl/blob/main/LICENSE-APACHE)
- [MIT License](https://github.com/crawlapi-dev/crawl/blob/main/LICENSE-MIT)

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.