# Fetch

Clean Markdown or text of up to 20 pages.

Reads one public page, or up to 20, and returns the cleaned content with its metadata. HTML, plain text, JSON, XML feeds and PDF files are read. Send `url` for one page or `urls` for several; with `urls` the response has `pages` in request order instead of `page`. Larger sets go through [batch](https://websearch.fast/docs/batch).

The fetcher loads public internet addresses on the standard web ports only, follows `robots.txt` for automated agents, and sends no credentials or cookies.

### What is charged

Each page that comes back with `status: ok` and non-empty content is charged once. A single `url` that cannot be read returns its error status and is free. With `urls`, the call is `200` as long as the body was valid, failed pages are reported per page and are free, and when every page failed the warning `all_failed` is set and nothing is charged.

Units: `fetch_page`, `fetch_pdf_pages`. `usage.items` in the response lists them.

## Request

```
POST https://api.websearch.fast/v1/web/fetch
```

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string |  | Public http(s) URL, at most 2048 bytes. At most 2048 characters. |
| `urls` | array of string |  | 1 to 20 items. |
| `format` | string |  | html returns 501 api_not_implemented until it ships. One of `markdown`, `text`, `html`. Default `markdown`. |
| `max_chars` | integer |  | 1000 to 500,000. Default `50000`. |
| `mode` | string |  | full returns 501 api_not_implemented until it ships. One of `main`, `full`. Default `main`. |
| `include_links` | boolean |  | Default `false`. |
| `include_images` | boolean |  | Default `false`. |
| `include_metadata` | boolean |  | Default `true`. |
| `pdf` | object |  |  |
| `pdf.max_pages` | integer |  | 1 to 500. Default `100`. |
| `query` | string |  | Return relevant_passages that match this text. At most 512 characters. |
| `render` | boolean |  | Planned; true returns 501 until it ships. Default `false`. |
| `max_age` | integer |  | Accept a stored copy up to this age in seconds. 0 to 2,592,000. |
| `no_cache` | boolean |  | Never answer from a stored copy. Default `false`. |
| `timeout_ms` | integer |  | 2000 to 35,000. |

### Example request

curl:

```bash
curl https://api.websearch.fast/v1/web/fetch \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.example.org/guide/install",
    "max_chars": 4000,
    "include_links": true
  }'
```

Python:

```python
import os
import httpx

response = httpx.post(
    "https://api.websearch.fast/v1/web/fetch",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    json={
        "url": "https://docs.example.org/guide/install",
        "max_chars": 4000,
        "include_links": True,
    },
    timeout=60,
)
response.raise_for_status()
print(response.json())
```

TypeScript:

```typescript
const response = await fetch("https://api.websearch.fast/v1/web/fetch", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://docs.example.org/guide/install",
    max_chars: 4000,
    include_links: true,
  }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

### Example response

```json
{
  "object": "web.fetch",
  "request_id": "20261128120001123456789a1b2c3d4Kx7Qm2Pb",
  "created": 1795867201,
  "input": {
    "url": "https://docs.example.org/guide/install",
    "format": "markdown",
    "mode": "main",
    "max_chars": 4000,
    "include_links": true,
    "include_images": false,
    "include_metadata": true,
    "timeout_ms": 35000
  },
  "page": {
    "requested_url": "https://docs.example.org/guide/install",
    "url": "https://docs.example.org/guide/install",
    "status": "ok",
    "http_status": 200,
    "content_type": "text/html",
    "title": "Install the CLI",
    "format": "markdown",
    "content": "# Install the CLI\n\nDownload the archive for your platform...",
    "chars": 2841,
    "truncated": false,
    "extraction": "article",
    "language": "en",
    "published_at": "2026-10-02T09:30:00Z",
    "metadata": {
      "description": "How to install the CLI on Linux, macOS and Windows.",
      "site_name": "Example Docs",
      "canonical_url": "https://docs.example.org/guide/install",
      "json_ld": []
    },
    "links": [
      {
        "url": "https://docs.example.org/guide/configure/",
        "text": "Configure"
      }
    ],
    "fetched_at": 1795867201
  },
  "usage": {"charged": true, "items": [{"unit": "fetch_page", "count": 1}]},
  "cache": {"hit": false, "data_age_seconds": 0, "fetched_at": 1795867201}
}
```

### Response fields

page (with url) or pages (with urls). With urls, failed pages are reported per page.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | yes | Always `web.fetch`. |
| `request_id` | string | yes | Same as the X-Request-Id header. |
| `created` | integer | yes | Unix seconds (UTC). |
| `input` | object | yes | The parameters as applied, defaults filled in. |
| `usage` | object | yes |  |
| `usage.charged` | boolean | yes |  |
| `usage.items` | array of object | yes |  |
| `usage.items.unit` | string | yes | Billable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge. |
| `usage.items.count` | integer | yes |  |
| `cache` | object |  |  |
| `cache.hit` | boolean | yes | The response, or every page in it, came from a stored copy. |
| `cache.data_age_seconds` | integer | yes | Age of the oldest part of the response. |
| `cache.fetched_at` | integer | yes | Unix seconds when the oldest part was read. |
| `warnings` | array of object |  |  |
| `warnings.code` | string | yes | For example no_results, content_partial, answer_unavailable, partial, all_failed, reach_reduced. |
| `warnings.message` | string |  |  |
| `warnings.param` | string |  |  |
| `page` | object |  |  |
| `page.requested_url` | string | yes |  |
| `page.url` | string |  | Final URL after redirects. For now the requested URL, because the reader does not report the final one yet. |
| `page.status` | string | yes | One of `ok`, `failed`. |
| `page.error` | object |  |  |
| `page.error.code` | string | yes |  |
| `page.error.message` | string | yes |  |
| `page.http_status` | integer |  |  |
| `page.content_type` | string |  |  |
| `page.title` | string |  |  |
| `page.content` | string |  |  |
| `page.format` | string |  | One of `markdown`, `text`, `html`. |
| `page.chars` | integer |  |  |
| `page.truncated` | boolean |  |  |
| `page.extraction` | string |  | Neutral label of how the text was taken. New values can appear. One of `article`, `full_page`, `document`, `feed`, `plain`, `structured`. |
| `page.language` | string |  |  |
| `page.published_at` | string |  |  |
| `page.metadata` | object |  |  |
| `page.metadata.description` | string |  |  |
| `page.metadata.author` | string |  |  |
| `page.metadata.site_name` | string |  |  |
| `page.metadata.canonical_url` | string |  |  |
| `page.metadata.image_url` | string |  |  |
| `page.metadata.keywords` | array of string |  |  |
| `page.metadata.meta` | object |  | Meta name and property tags, at most 100. |
| `page.metadata.json_ld` | array of object |  | At most 20 items. |
| `page.links` | array of object |  | At most 1000 items. |
| `page.links.url` | string | yes |  |
| `page.links.text` | string |  |  |
| `page.links.rel` | string |  |  |
| `page.images` | array of object |  | At most 200 items. |
| `page.images.url` | string | yes |  |
| `page.images.alt` | string |  |  |
| `page.images.width` | integer |  |  |
| `page.images.height` | integer |  |  |
| `page.pdf_pages` | integer |  |  |
| `page.relevant_passages` | array of string |  |  |
| `page.fetched_at` | integer |  |  |
| `pages` | array of object |  |  |
| `pages.requested_url` | string | yes |  |
| `pages.url` | string |  | Final URL after redirects. For now the requested URL, because the reader does not report the final one yet. |
| `pages.status` | string | yes | One of `ok`, `failed`. |
| `pages.error` | object |  |  |
| `pages.error.code` | string | yes |  |
| `pages.error.message` | string | yes |  |
| `pages.http_status` | integer |  |  |
| `pages.content_type` | string |  |  |
| `pages.title` | string |  |  |
| `pages.content` | string |  |  |
| `pages.format` | string |  | One of `markdown`, `text`, `html`. |
| `pages.chars` | integer |  |  |
| `pages.truncated` | boolean |  |  |
| `pages.extraction` | string |  | Neutral label of how the text was taken. New values can appear. One of `article`, `full_page`, `document`, `feed`, `plain`, `structured`. |
| `pages.language` | string |  |  |
| `pages.published_at` | string |  |  |
| `pages.metadata` | object |  |  |
| `pages.metadata.description` | string |  |  |
| `pages.metadata.author` | string |  |  |
| `pages.metadata.site_name` | string |  |  |
| `pages.metadata.canonical_url` | string |  |  |
| `pages.metadata.image_url` | string |  |  |
| `pages.metadata.keywords` | array of string |  |  |
| `pages.metadata.meta` | object |  | Meta name and property tags, at most 100. |
| `pages.metadata.json_ld` | array of object |  | At most 20 items. |
| `pages.links` | array of object |  | At most 1000 items. |
| `pages.links.url` | string | yes |  |
| `pages.links.text` | string |  |  |
| `pages.links.rel` | string |  |  |
| `pages.images` | array of object |  | At most 200 items. |
| `pages.images.url` | string | yes |  |
| `pages.images.alt` | string |  |  |
| `pages.images.width` | integer |  |  |
| `pages.images.height` | integer |  |  |
| `pages.pdf_pages` | integer |  |  |
| `pages.relevant_passages` | array of string |  |  |
| `pages.fetched_at` | integer |  |  |

### Errors

| Status | Codes |
| --- | --- |
| `400` | `invalid_request`, `invalid_url`, `invalid_schema` or `invalid_image`. Not charged. |
| `401` | `invalid_token`. Not charged. |
| `403` | `pre_consume_token_quota_failed` (the key's own spending limit), `access_denied`, `web_not_allowed` or `model_not_in_plan` (customer keys while plans cannot include the web tools). Not charged. |
| `404` | `not_found` or `invalid_endpoint`. Not charged. |
| `413` | `read_request_body_failed`: the request body is over the limit. Not charged. |
| `415` | `unsupported_content`. Not charged. |
| `422` | `fetch_failed`, `site_refused`, `page_too_large` or `extraction_failed`. Not charged. |
| `429` | `rate_limited`, `concurrency_limited`, `api_key_temporarily_frozen`, or the failure guard. Not charged. |
| `500` | `internal_error`. Not charged. |
| `501` | `api_not_implemented`: the endpoint, type or option has not shipped. Not charged. |
| `503` | `source_unavailable`, `web_api_disabled`, `token_cache_busy` or `billing_busy` (the charge could not be prepared in time; retry after Retry-After). Not charged. |
| `504` | timeout. Not charged. |
