# webfetch > Give your agents access to the web. One request returns clean content from any URL — markdown, HTML, text, links, images, metadata, structured JSON, or a screenshot — rendered by a real browser with bot challenges handled. Failed, blocked, or empty fetches are not charged, and the response says why. Base URL: https://webfetch.run/ This is the expanded companion to [llms.txt](https://webfetch.run/llms.txt). The compact machine contract is [elements.txt](https://webfetch.run/elements.txt); the full field-level contract is [elements-full.txt](https://webfetch.run/elements-full.txt); the parseable JSON is [agent.json](https://webfetch.run/agent.json); the OpenAPI 3.1 document is [openapi.json](https://webfetch.run/openapi.json). Human docs: [https://webfetch.run/docs](https://webfetch.run/docs). webfetch is a hosted fetch API and MCP server. It fetches one public URL at a time. It does not offer crawl, map, or site-search tools. ## What it does - Fetches a public `http(s)` URL from the country specified in `location.country`. - Returns only the formats you asked for (14 formats; default is `markdown`). - Handles bot challenges where it can. When it cannot, the response says so and is not charged. - Offers egress `direct`, `datacenter`, or `residential` at the same per-fetch price. - Can target an exit country and browser language via `location`. - Can reuse a cleared `metadata.session` as `session` on later calls to the same host (docs report repeat queries going from about 38s to about 6–8s). - On Google results pages, `ai_overview` can return the generated-answer card as markdown plus a PNG. `present` is false when the page has no such card, including every non-Google URL. - Interactive sessions let you keep a real browser open and run Playwright-style JavaScript against persistent `page` / `context` state. ## Connect: MCP Endpoint: `https://mcp.webfetch.run/mcp` (Streamable HTTP). Official registry name: `run.webfetch/webfetch`. Auth: `X-API-Key` on the client, or OAuth. The protected-resource metadata lists `https://clerk.webfetch.run` as the authorization server, with scopes `openid`, `profile`, `email`, `offline_access`, and bearer tokens in the header. Claude Code: ``` claude mcp add --transport http webfetch https://mcp.webfetch.run/mcp \ --header "X-API-Key: YOUR_KEY" ``` Server card (recommended discovery document): https://webfetch.run/server-card AI catalog: https://webfetch.run/.well-known/ai-catalog.json ### Tools - `fetch` — Fetch a URL and return clean content. Same work as `POST /v1/scrape`. - `check_coverage` — Preflight only: says whether a URL is public and `http(s)`. Makes no request, costs nothing. - `session_open` — Open an interactive browser session. One per account; five-minute maximum; 60-second idle close. - `session_list` — List open sessions and the account concurrency limit. - `session_execute` — Run JavaScript in an isolated Playwright-style REPL against an open session. Each run is capped at 30 seconds. Code has access to `page` and `context`. Callback functions are limited to page-context evaluation so code cannot execute in the shared fleet process. - `session_close` — Close a session and settle its browser-time charge. Unused reserved time is returned. ## Connect: REST Base: `https://api.webfetch.run` Auth header: `X-API-Key: sk_live_...` The OpenAPI document lists these paths: - `POST /v1/scrape` — Fetch one URL and return it in the requested formats. - `POST /v1/scrape/demo` — The same work, authenticated by a session cookie. This is the sandbox, not the API-key path. - `GET /v1/sessions` — List open interactive browser sessions. - `POST /v1/sessions` — Open a persistent interactive browser session. - `POST /v1/sessions/{id}/execute` — Execute JavaScript in an open session. - `DELETE /v1/sessions/{id}` — Close a session and settle the charge. - `GET /v1/me` — Account, credit balance, plan, and what the plan unlocks. - `GET /health` — Liveness. No auth. Minimal scrape call: ``` POST https://api.webfetch.run/v1/scrape X-API-Key: YOUR_KEY Content-Type: application/json {"url": "https://www.allbirds.com/products/mens-wool-runners", "formats": ["markdown"]} ``` Documented scrape body fields (from the live docs): - `url` (string, required) — The page to fetch. Must be public `http(s)`. - `formats` (string[]) — Defaults to `["markdown"]`. Names are case-insensitive; an unknown name is a 400 that lists the valid ones. - `egress` — `"direct"` | `"datacenter"` | `"residential"`. Defaults to `residential`. - `location` — `{country, languages?}`. Uses direct egress when the fleet already exits in that country, otherwise country-targeted residential egress at the normal per-fetch price. - `onlyMainContent` (boolean) — Defaults to true: narrows `html` and `markdown` to the main content. Set false for the whole DOM. - `waitForSelector` (string) — Wait for this CSS selector before capturing. - `persist` (boolean) — Store the capture and return a link that renders it from the webfetch origin. Off by default. - `rotations` (number) — How many exits to try on a wall. Default 3, clamped 0–5. - `parallelProbes` (number) — How many exits to try concurrently. Default 3, clamped 1–5. - `timeout` (number) — Overall budget in milliseconds. Default 120000, clamped 5000–300000. - `session` (object) — Replay a cleared session: `session.cookies` (and `egressPort`) from a previous response. Keys are created in the console. The plaintext is shown once; only a SHA-256 hash is stored. Send the key as `X-API-Key: sk_live_...`. Note: the live OpenAPI document currently describes this as `bearerAuth` (HTTP bearer, format `sk_live_…`) and says “API key. Paid plans.” The human docs and `agent.json` specify the `X-API-Key` header. Prefer `X-API-Key` as documented on https://webfetch.run/docs until the OpenAPI security scheme is reconciled. ## Formats (14) Ask for any combination. You get back only what you asked for. - `markdown` (string) — The page as markdown. Default when no format is given. - `html` (string) — Cleaned HTML. Narrowed by `onlyMainContent` (default true). - `rawHtml` (string) — The document exactly as received, never narrowed. - `rawBase64` (string) — The document bytes as base64. UTF-8 safe. - `text` (string) — Visible text only, no markup. - `screenshot` (string) — Base64 PNG of the rendered page. - `links` (string[]) — Absolute URLs found on the page. - `images` ({src, alt, ...}[]) — Absolute image URLs with alt text and dimensions when present. - `metadata` (object) — Head tags: title, description, og:*, canonical, language, plus fetch metadata such as `finalUrl`, `status`, `verdict`, `attempts`, and `session`. - `branding` (object) — Colours, fonts and logo, extracted deterministically. - `attributes` (object) — Named attributes per CSS selector. Send `attributes: [{selector, attribute}]`. - `summary` (string) — A short abstract, generated by a model. - `json` (object) — Structured extraction. Send `jsonOptions: { schema }`. - `ai_overview` (object) — The generated-answer card, expanded: markdown plus a PNG of that card. `present` is false when the page has none. ## Response and errors A successful body includes `success: true`, `data` (only requested formats plus metadata), and may include a `balance` object. A failure is always `success: false` with a machine-readable code, and is not charged. Documented error codes: | Code | HTTP | Meaning | | --- | --- | --- | | `invalid_request` | 400 | The body did not validate — a missing `url`, an unknown format, a bad selector shape. | | `target_not_allowed` | 400 | The URL is private, internal, or not a public `http(s)` address. | | `egress_unavailable` | 400 | You asked for an egress tier this deployment has not configured. Refunded in full. | | `insufficient_balance` | 402 | The balance cannot cover one fetch. Nothing ran, nothing was charged. | | `blocked` | 200 | The site returned a wall instead of content. `success: false`, nothing charged. On `blocked`, retry with egress `"residential"` and `rotations` 5. Changing the format or the URL will not help if the refusal is an IP problem. | | `timeout` | 504 | The request exceeded its `timeout` budget. Nothing charged. | | `fleet_unavailable` | 503 | The renderer could not be reached. Refunded in full. | ## Billing rules (mechanical, not a price list) These rules are documented on the live site. For current dollar amounts, read https://webfetch.run/pricing rather than this file. - A successful uncached API fetch uses credit. Cache hits cost nothing. - Failed, blocked, empty, or timed-out fetches are not charged. - `blocked` is an HTTP 200 — always check `success`. - Egress choice does not change the per-fetch price. - Interactive sessions are billed by browser time, with a documented one-minute minimum and a reserve that is settled when the session closes. See the docs page for the current amounts. ### Sandbox allowance A free account includes 10 successful rendered sandbox fetches for life. API and MCP fetches use a prepaid balance. ## Interactive sessions (details) - One session per account at a time. - Expires after five minutes, or after 60 seconds without activity. - Each `session_execute` is capped at 30 seconds. - Open, execute, list, and close are available over REST (`/v1/sessions`) and MCP. - You can pass `location` when opening so the session uses country-targeted egress. ## Discovery files this site should serve - https://webfetch.run/llms.txt - https://webfetch.run/llms-full.txt (this file — must be public, not behind sign-in) - https://webfetch.run/elements.txt - https://webfetch.run/elements-full.txt - https://webfetch.run/agent.json and https://webfetch.run/.well-known/agent.json - https://webfetch.run/openapi.json and https://api.webfetch.run/openapi.json - https://webfetch.run/server-card - https://webfetch.run/.well-known/ai-catalog.json - https://webfetch.run/robots.txt - https://webfetch.run/sitemap.xml - Markdown page variants: https://webfetch.run/index.md, /docs.md, /pricing.md ## Optional - [Status](https://webfetch.run/) — footer of the site links a Status page; use the live footer URL if you need uptime, do not invent a status host here.