# web.fetch

Fetch one public web page: give its address, get the status, headers and body the server sent.

Web page, one of the Web scrapers.

| | |
| --- | --- |
| Id | `web.fetch` |
| Version | 1 |
| Billed per | request — 1 unit for a charged run |
| Runs | within one request |

Start it with `POST /v1/scrapers/web.fetch/runs`. How runs work is in [Running a scraper](https://docs.enrichednow.com/running-a-scraper.md); what a run costs is in [Usage and units](https://docs.enrichednow.com/usage-and-units.md).

## Inputs

The fields of `input`. A field that is not listed here is refused.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | yes | The page's address: http or https, on a public host name. Limit: at most 2048 characters. |
| `method` | "GET" | no | GET is the only method. Default: `"GET"`. |
| `headers` | object of string values | no | Request headers to send, from: Accept, Accept-Language, User-Agent, Referer, Cache-Control, Pragma, If-Modified-Since, If-None-Match, DNT, X-Requested-With. |
| `follow_redirects` | boolean | no | Follow up to 5 redirects; false returns the redirect itself. Default: `true`. |
| `timeout_s` | number | no | Seconds for the whole fetch, redirects included. Limit: 1 to 120. Default: `30`. |
| `max_bytes` | integer | no | The body is cut after this many bytes (decoded); `truncated` says when it was. Limit: 1 to 10000000. Default: `2000000`. |

- `GET` is the only method. There is no request body, and no cookie or `Authorization` header can be sent: `headers` takes at most 10 headers, from the names listed above only.
- No JavaScript is run. `body` is what the server sent to a plain request; a page that builds its content in the browser comes back as the shell it starts from.
- A page the site itself answers with `404` or `500` is a successful fetch: the run ends `ok`, the record carries that `status`, and the run is charged like any other `ok`.
- A site that refuses the request ends the run `failed`, with no record and no charge: `blocked` for a `403`, a `999` or a challenge page, `rate_limited` for a `429`, `captcha` for a CAPTCHA. A `403` is always read as a refusal. See [the reasons of this family](https://docs.enrichednow.com/results-and-statuses.md#web).
- The body is cut after `max_bytes` — 2,000,000 by default (2 MB), 10,000,000 at most — and `truncated` is `true` when it was.
- A body that is text is given as text, decoded with the charset in `charset`. Anything else (an image, a PDF) is given as base64, and `body_encoding` says which.
- `url` must be an `http` or `https` address on a public host name, on port 80, 443, 8080 or 8443, with no login in it. Up to 5 redirects are followed, and each one is held to the same rules: more than 5 ends the run `failed` with `too_many_redirects`, one to an address that may not be fetched with `redirect_refused`.
- `headers` on the record are the response headers that describe the page. `Set-Cookie` is not among them.

## Record fields

Every record of a run has these fields. A value that is not known is `null` — never an empty string and never `0`.

| Field | Type | Notes |
| --- | --- | --- |
| `url` | string | The address that was asked for. |
| `final_url` | string | The address that answered, after redirects. |
| `status` | integer | The HTTP status of the answer (a 404 or 500 is still the page). |
| `headers` | object of string values | The response headers that describe the page, names in lower case. |
| `content_type` | string or null | The media type, without parameters, e.g. text/html. |
| `charset` | string or null | The charset the text was decoded with; null for a base64 body. |
| `body` | string | The body: text, or base64 when `body_encoding` says so. |
| `body_encoding` | "text" \| "base64" | base64 for a body that is not text (an image, a PDF). |
| `bytes` | integer | The size of the returned body in bytes, before text decoding or base64. |
| `truncated` | boolean | True when the server sent more than max_bytes and the body was cut. |
| `redirects` | array of string | The addresses the redirects led to, in order. |
| `fetched_at` | string (date-time) | When the answer was received, in UTC. |

## Example request

It starts a run with this scraper's example input and waits up to 60 seconds for it. The key is read from `ENRICHEDNOW_API_KEY`.

```bash
curl -X POST "https://api.enrichednow.com/v1/scrapers/web.fetch/runs?wait=60" \
  -H "Authorization: Bearer $ENRICHEDNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input":{"url":"https://docs.widgetlib.org/en/stable/quickstart.html"}}'
```

## Example response

The run, once it has ended. A run that has not ended within `wait` comes back with `202` and the status `queued` or `running`.

```json
{
  "id": "run_841742f37553189ff9c27ba1",
  "scraper_id": "web.fetch",
  "scraper_version": 1,
  "status": "ok",
  "reason": null,
  "input": {
    "url": "https://docs.widgetlib.org/en/stable/quickstart.html"
  },
  "record_count": 1,
  "units": 1,
  "units_per_request": 1,
  "units_per_record": null,
  "units_per_page": null,
  "diagnostics": {
    "requests": 1,
    "bytes": 259214,
    "wall_ms": 885,
    "facts": {}
  },
  "created_at": "2026-11-16T22:37:50.170950Z",
  "started_at": "2026-11-16T22:37:50.178331Z",
  "finished_at": "2026-11-16T22:37:51.066313Z"
}
```

Its records, from `GET /v1/runs/{id}/records`. The record was read by this scraper's own parser from a page built by hand for its tests, because no real page could be recorded: its fields and shapes are the scraper's, its values are invented.

```json
{
  "records": [
    {
      "url": "https://docs.widgetlib.org/en/stable/quickstart.html",
      "final_url": "https://docs.widgetlib.org/en/stable/quickstart.html",
      "status": 200,
      "headers": {
        "content-type": "text/html; charset=utf-8"
      },
      "content_type": "text/html",
      "charset": "utf-8",
      "body": "<!DOCTYPE html>\n<html class=\"writer-html5\" lang=\"en\">\n<head>\n  <meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n  <title>Quickstart &mdash; widgetlib 2.4 documentation</title>\n  <base … [truncated]",
      "body_encoding": "text",
      "bytes": 3848,
      "truncated": false,
      "redirects": [],
      "fetched_at": "2026-11-19T18:07:42.604327Z"
    }
  ],
  "next_cursor": null
}
```

What was done to the record for this page, and nothing else — the API returns every value whole. A text that was cut ends with `… [truncated]`.

- Shortened: `body`: 3,846 characters, the first 229 shown.

A run does not always end `ok`. [Results and statuses](https://docs.enrichednow.com/results-and-statuses.md#reason-codes) lists every status and the reasons every scraper shares; [the reasons of the Web scrapers](https://docs.enrichednow.com/results-and-statuses.md#web) are in their own section there.
