> ## Documentation Index
> Fetch the complete documentation index at: https://hyperbrowser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Authenticate REST, SDK, and CLI requests with the `x-api-key` header using the `HYPERBROWSER_API_KEY` environment variable (create keys at https://app.hyperbrowser.ai).
> Always stop browser sessions (`sessions.stop(id)` / `PUT /api/session/{id}/stop`) and sandboxes (`sandboxes.stop(id)` / `PUT /api/sandbox/{id}/stop`) in `try`/`finally` blocks to avoid idle billing.
> Choose the right surface: use Web API (`/api/web/fetch`, `batch-fetch`, `crawl`, `search`) for stateless reading and extraction (prefer it over legacy `/api/scrape`); Browser Sessions (`/api/session`) for interactive, authenticated, or Playwright/Puppeteer workflows; Cloud Agents (`/api/task/*`) for autonomous browser tasks; and Sandboxes (`/api/sandbox`) for isolated Linux or macOS code execution.
> Use `@hyperbrowser/sdk` for Node.js/TypeScript, `hyperbrowser` 1.0+ typed-dict request params for Python (avoid legacy Pydantic request classes), the unified `hx` CLI for terminal workflows, and hosted OAuth MCP at `https://mcp.hyperbrowser.ai/mcp/web` (web tools; use `https://mcp.hyperbrowser.ai/mcp` only when browser, sandbox, admin, and usage tools are needed).

# Web API (hx web)

> Fetch pages, crawl sites, search the web, and inspect web job history from the command line

Use `hx web` to run Hyperbrowser's Web API (`fetch`, `crawl`, `search`) and inspect aggregate job history (`jobs`) directly from your terminal. Fetch, crawl, and search run synchronously by default. For fetch and crawl, pass `--async` to enqueue a background job and poll it later; on search, `--async` is accepted for compatibility but still waits for the result.

***

## Fetch (`hx web fetch`)

Fetch a single URL in `markdown`, `html`, `links`, `screenshot`, or `branding` format using `--format` (for structured JSON extraction with a prompt or schema, pass `--json-body` or `--body`):

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
# Synchronous fetch (defaults to markdown)
hx web fetch https://example.com

# Request multiple formats and save outputs locally
hx web fetch https://example.com --format markdown --format links --output ./out.md
hx web fetch https://example.com --format screenshot --save-screenshot ./page.png

# Raw body / JSON body passthrough (for actions, JSON schema, browser/navigation options)
hx web fetch --json-body '{"url":"https://example.com","outputs":{"formats":["markdown","branding"]}}'

# Async job workflow
hx web fetch https://example.com --async
hx web fetch status <job-id>
hx web fetch wait <job-id> --poll-interval 2s --timeout 2m
hx web fetch get <job-id>
hx web fetch details <job-id>
hx web fetch list --status completed --page 1 --limit 20
hx web fetch stop <job-id>
```

### Verified `hx web fetch` Subcommands & Flags

* **Subcommands:** `fetch [url]`, `create [url]`, `status <job-id>`, `wait <job-id>`, `get <job-id>`, `details <job-id>`, `list` (`ls`), `stop <job-id>`.
* **`fetch [url]` flags:** `--format` (`markdown`, `html`, `links`, `screenshot`, `branding`), `--save-screenshot`, `--output`, `--raw`, `--async`, `--timeout`, `--body`, `--json-body`.
* **`create [url]` flags:** `--url`, `--body`, `--json-body`.
* **`wait <job-id>` flags:** `--poll-interval`, `--timeout`.
* **`list` (`ls`) flags:** `--url`, `--status`, `--since`, `--page`, `--limit`.

***

## Crawl (`hx web crawl`)

Crawl linked pages starting from a root URL:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
# Start and wait for a crawl synchronously
hx web crawl https://example.com \
  --max-pages 25 \
  --include-patterns '/docs/.*' \
  --exclude-patterns '/docs/archive/.*' \
  --follow-links

# Enqueue asynchronously and inspect results by page or batch
hx web crawl https://example.com --max-pages 50 --async
hx web crawl status <job-id>
hx web crawl wait <job-id> --poll-interval 2s --timeout 5m
hx web crawl get <job-id> --page 1 --batch-size 20
hx web crawl details <job-id>
hx web crawl page <job-id> <page-id>
hx web crawl list --page 1 --limit 10
hx web crawl stop <job-id>
```

### Verified `hx web crawl` Subcommands & Flags

* **Subcommands:** `crawl [url]`, `create [url]`, `status <job-id>`, `wait <job-id>`, `get <job-id>`, `details <job-id>`, `page <job-id> <page-id>`, `list` (`ls`), `stop <job-id>`.
* **`crawl [url]` flags:** `--max-pages`, `--include-patterns`, `--exclude-patterns`, `--follow-links`, `--ignore-sitemap`, `--timeout`, `--wait-timeout`, `--poll-interval`, `--async`, `--body`, `--json-body`.
* **`create [url]` flags:** `--url`, `--body`, `--json-body`.
* **`wait <job-id>` flags:** `--poll-interval`, `--timeout`, `--page`, `--batch-size`.
* **`get <job-id>` flags:** `--page`, `--batch-size`.
* **`list` (`ls`) flags:** `--page`, `--limit`.

***

## Search (`hx web search`)

Query the web and retrieve structured results:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
# Run a search synchronously
hx web search 'hyperbrowser browser automation'

# Escape a query that matches a subcommand name (e.g. "status", "list") with `--`
hx web search -- status

# Pass location/filters via --json-body
hx web search --json-body '{"query":"machine learning","location":{"country":"US"},"filters":{"site":"arxiv.org"}}'
hx web search status <job-id>
hx web search wait <job-id> --poll-interval 1s --timeout 30s
hx web search get <job-id>
hx web search list --page 1 --limit 20
hx web search stop <job-id>
```

### Verified `hx web search` Subcommands & Flags

* **Subcommands:** `search [query]`, `create [query]`, `status <job-id>`, `wait <job-id>`, `get <job-id>`, `list` (`ls`), `stop <job-id>`.
* **`search [query]` flags:** `--async`, `--body`, `--json-body`, `--poll-interval`, `--timeout`.
* **`create [query]` flags:** `--query`, `--body`, `--json-body`, `--timeout`.
* **`wait <job-id>` flags:** `--poll-interval`, `--timeout`.
* **`list` (`ls`) flags:** `--page`, `--limit`.

***

## Unified Web Job History (`hx web jobs`)

View recent web jobs across `fetch`, `web_crawl`, `scrape`, `extract`, and `web_search` in a single table sorted newest-first:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
hx web jobs
hx web jobs --limit 50
hx web jobs --kind fetch,web_crawl
hx web jobs --kind web_search --status completed
hx --json web jobs --page 1 --limit 100
```

Flags: `--kind`, `--status`, `--page`, `--limit`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.