# Web Fetch API (`datahamster/web-fetch-api`) Actor

Web fetch API for LLM and RAG: send one URL or a batch and get clean Markdown or plain text with a token count per page. Reads HTML, PDF and DOCX, renders JavaScript only when a page needs it, can follow same-domain links and alerts you when a page's text changes. Failed pages are free.

- **URL**: https://apify.com/datahamster/web-fetch-api.md
- **Developed by:** [Viktor Dubnytskiy](https://apify.com/datahamster) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 result items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Web Fetch API

Send one URL or a whole list and get each page back as clean Markdown or plain text, ready for an LLM prompt, a RAG index or a vector database. Every row carries a token count, the share of the page that was thrown away as menus and footers, and a text hash for change tracking. Web pages, PDF and Word DOCX files all work. Use it as a normal Actor run or as a Standby HTTP API that answers in the response.

**Try it:** the prefilled example (a docs page, a Wikipedia article and the 15-page "Attention Is All You Need" PDF) returns 3 rows in about 10 seconds and costs about $0.0035 at the default 1024 MB ($0.003 for results plus $0.0005 of platform usage). Results cost $1 per 1,000.

Coverage: public pages without login. PDFs need a text layer (no OCR). JavaScript is rendered only for pages that need it.

### Why this one

- **Batch input.** Put hundreds of URLs in one run, fetched 5 at a time by default. Apify's Web Fetch takes a single `url` per call.
- **Word DOCX to Markdown.** Headings, bullet lists and tables come out as Markdown, with the document title. PDFs work too and also report their `pageCount`.
- **Token count per page** (`tokenCount`, GPT-4o tokenizer) and an optional `maxTokensPerPage` cut, so a page never blows your context window.
- **Boilerplate score.** `boilerplateRatio` tells you how much of the page's visible text was removed as navigation, footers and banners, and `extractor` says which method found the article.
- **Change monitor.** Schedule the same URLs in monitor mode and get a row only when a page's main text changed. Re-flowed markup and whitespace do not count.
- **Depth-1 links.** Optionally also fetch up to N same-domain pages each URL links to.
- **Failed pages are free**, 404s included. A blocked site on one URL never stops the rest of the batch.

### What you get

Real rows from test runs on the platform (06.11.2026):

| page | type | tokens | boilerplate removed | how it was fetched |
|---|---|---|---|---|
| Coroutines and tasks (docs.python.org) | html | 10,561 | 7% | plain HTTP, no proxy |
| Retrieval-augmented generation (Wikipedia) | html | 3,577 | 38% | plain HTTP, no proxy |
| Attention Is All You Need (arxiv.org, 15-page PDF) | pdf | 9,492 | | plain HTTP, no proxy |
| calibre DOCX demo, cut with `maxTokensPerPage: 300` | docx | 289 | | plain HTTP, no proxy |
| react (npmjs.com, behind Cloudflare) | html | 211 | 52% | residential proxy, escalated automatically |
| quotes.toscrape.com/js (built by JavaScript) | html | 246 | 28% | browser, picked automatically |
| httpbin.org/status/404 | | | | free row with `error: "HTTP 404"` |

One row from the example dataset (Markdown cut here for space):

```json
{
  "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
  "statusCode": 200,
  "title": "Retrieval-augmented generation - Wikipedia",
  "language": "en",
  "documentType": "html",
  "markdown": "# Retrieval-augmented generation\n\n**Retrieval-augmented generation** (**RAG**) is a technique that enables large language models (LLMs) to retrieve and incorporate new information from external data sources. With RAG, LLMs first refer to a specified set of documents, then respond to user queries. ...",
  "textLength": 15308,
  "wordCount": 2306,
  "tokenCount": 3577,
  "tokenizer": "o200k_base",
  "truncated": false,
  "pageTextLength": 24773,
  "boilerplateRatio": 0.383,
  "contentHash": "3258fe316e3e52e58f23acde15b21205",
  "textHash": "d1f72137d22352d990ded354389d7ed6",
  "extractor": "trafilatura",
  "tierUsed": "none",
  "fetchMode": "http",
  "depth": 0,
  "fetchedAt": "2026-11-06T12:12:26.074209Z",
  "error": null
}
```

Full row: `url`, `finalUrl`, `statusCode`, `title`, `description`, `language`, `canonicalUrl`, `documentType` (html, pdf, docx, text), `markdown`, `text`, `textLength`, `wordCount`, `tokenCount`, `tokenizer`, `truncated`, `pageTextLength`, `boilerplateRatio`, `pageCount`, `links`, `images`, `contentType`, `contentHash`, `textHash`, `extractor`, `tierUsed`, `fetchMode`, `depth`, `linkedFrom`, `fetchedAt`, `error`.

### Standby HTTP API

The Actor also runs in Standby mode, like a small web server. Send a request, get the page in the response, no polling:

```bash
curl 'https://datahamster--web-fetch-api.apify.actor/?url=https://docs.python.org/3/library/asyncio-task.html&formats=markdown' \
  -H 'Authorization: Bearer <APIFY_TOKEN>'
```

```bash
curl -X POST 'https://datahamster--web-fetch-api.apify.actor/' \
  -H 'Authorization: Bearer <APIFY_TOKEN>' -H 'Content-Type: application/json' \
  -d '{"urls": ["https://example.com", "https://example.com/report.pdf"], "formats": ["text"], "maxTokensPerPage": 4000}'
```

- One `url` returns the row as JSON. Add `unwrap=true` to get the Markdown itself as the response body.
- Several URLs (up to 20 per request) or `crawlLinks` return `{"count", "succeeded", "failed", "items": [...]}`.
- A failed single URL returns an error object with a `code` (`BLOCKED`, `TARGET_HTTP_ERROR`, `UNSUPPORTED_CONTENT_TYPE`, `URL_REFUSED`, `FETCH_FAILED`) and is not charged.
- Query parameters: `url` (repeatable), `formats`, `maxTokensPerPage`, `crawlLinks`, `maxLinksPerUrl`, `renderJs`, `waitFor`, `documents`, `includeLinks`, `includeImages`, `proxyTier`, `proxyCountry`, `timeout`, `unwrap`. A POST body takes the same fields as the Input tab.

### Use cases

- **RAG ingestion**: load a list of docs pages, PDFs and Word files as Markdown with token counts, so you can chunk and budget before embedding.
- **AI agents**: give a tool call the text of a URL in a few thousand tokens instead of 300 KB of HTML.
- **Change alerts**: watch pricing pages, terms of service or documentation and get only the pages whose text changed.

### Input

| Field | Meaning | Default |
|---|---|---|
| `urls` | Pages, PDFs and DOCX files to fetch | Python docs page |
| `formats` | `markdown`, `text` or both | `markdown` |
| `maxTokensPerPage` | Cut each page to N tokens | no limit |
| `crawlLinks`, `maxLinksPerUrl` | Also fetch same-domain links, one level deep | `false`, `10` |
| `includeUrlPatterns`, `excludeUrlPatterns` | Glob filters for those links | empty |
| `renderJs`, `waitFor` | `auto` (browser only for JS app shells), `never`, `always` | `auto` |
| `documents` | Read PDF and DOCX | `true` |
| `includeLinks`, `includeImages` | Keep links and images and list them per row | `false` |
| `proxyTier`, `proxyCountry` | `auto` steps from no proxy up to Web Unblocker on blocks | `auto` |
| `concurrency`, `domainDelaySecs`, `timeout` | Parallel fetches, pause per site, timeout per page | `5`, `0.5`, `45` |
| `maxItems` | Stop after this many successful pages | `10` in the example |
| `mode`, `monitorStateId`, `webhookUrl`, `telegramBotToken`, `telegramChatId` | Monitor mode and alerts | `scrape` |

### Monitor mode

Save a task with

```json
{"mode": "monitor", "monitorStateId": "pricing-pages", "urls": ["https://example.com/pricing", "https://example.com/terms"]}
```

and schedule it. The first run records every page and charges nothing per page. Later runs return a page only when its main text changed (`changeType: "changed"`, with the previous `textHash`) or when you add a new URL to the list (`changeType: "new"`). Each run costs one `monitor-check`, each returned page one `change`. Pages that fail in a run are skipped and compared again next time. If a monitor run is killed, the next runs of the same state wait for its timeout and end as `overlapping_run`; give the task a new `monitorStateId` to start over.

### Related actors

- [Website to Markdown](https://apify.com/datahamster/website-to-markdown) crawls a whole site breadth-first (any depth, page budget) and returns Markdown per page.
- [Protected Page Change Monitor](https://apify.com/datahamster/protected-page-fetch-monitor) extracts one CSS selector or regex from protected pages and alerts on changes.
- [Substack Scraper](https://apify.com/datahamster/substack-posts) returns every post of a publication with full text.

### Pricing

| Event | Price |
|---|---|
| result | $0.001 per successful page ($1 per 1,000) |
| failed page | free (listed with an `error` field) |
| monitor-check | $0.005 per monitor run |
| change | $0.001 per new or changed page in monitor mode |

Apify subscribers pay less: SILVER -10%, GOLD and higher -20%.

Platform usage (compute, proxy traffic, storage) is billed by Apify on top of these prices. Apify's Web Fetch includes usage in its $1.50 per 1,000, so compare totals. Measured on the platform at the default 1024 MB (06.11.2026, warm image):

| What you fetch | Usage on top of the results | Total |
|---|---|---|
| 20 plain pages in one run | $0.00065 per run (about $0.00003 per page) | about $0.021, or $1.03 per 1,000 |
| 3 pages in one run (the prefilled example) | $0.0005 | about $0.0035 |
| 1 plain page in one run | $0.0004 | about $0.0014 |
| 1 page that needs the browser | $0.0005 | about $0.0015 |
| 1 page behind Cloudflare that needs the residential proxy | $0.0010 | about $0.002 |
| 1 page that needs Web Unblocker (the cheaper tiers are tried first) | $0.003 to $0.004 | about $0.004 to $0.005 |
| 1 Standby request to a cold container | about $0.0025, estimated from the measured compute rate (start-up plus 30 s idle at 1024 MB) | about $0.0035 |

The first run after a new build pulls the container image and can cost 2 to 3 times the usage above. Batches of plain pages come out cheaper than Web Fetch, and single plain or browser pages cost about the same. Pages that need the residential proxy or Web Unblocker cost more, and so does a lone Standby request to a cold container. Requests that reach a warm Standby container within 30 s share its start-up cost.

**Found it useful?** A short review on the Store page helps other people find this actor. If something is wrong, open an issue on the actor page.

### Limits

- No login, cookies or paywalled content.
- PDFs without a text layer (scans) come back as a free failed row; there is no OCR. PDFs are read up to 300 pages and 25 MB, HTML up to 10 MB.
- Old `.doc`, spreadsheets, images and archives are skipped as free failed rows.
- One URL gets at most 3 x `timeout` seconds (135 s by default) across all proxy tiers and the browser, then it comes back as a free failed row. Web Unblocker is tried once per URL.
- Rows arrive in the order pages finish, so a slow site never holds back the rest of the batch.
- The token count uses the o200k_base tokenizer. If it cannot be loaded, `tokenizer` says `estimate` and the count is characters / 4.
- Standby requests take up to 20 URLs and 20 links per URL and stop after 280 s; pages fetched by then are returned and charged, the rest are not. Use a normal run for bigger batches. Standby runs at 1024 MB and stops after 30 s without requests.
- Private, loopback and internal addresses are refused. With plain HTTP every redirect hop is checked before it is requested. In the browser, Chromium follows redirects itself: the browser opens the URL the HTTP pass already resolved, and a page whose redirect chain touched a private address is discarded, but that hop may already have been requested.

### FAQ

**Why is a page in the dataset with an empty `markdown`?** It failed and the `error` field says why. Failed pages are not charged. If every page failed, `RUN_SUMMARY` in the key-value store has `emptyReason` (`blocked` or `upstream_error`).

**What does `boilerplateRatio` mean?** 0.6 means 60% of the visible text on the page was navigation, footers, sidebars or banners and was left out. A value near 0 on an article page means the page had almost no chrome.

**When is a browser used?** Only when the plain HTTP answer is a JavaScript app shell with almost no readable text, or when you set `renderJs: always`. Such rows have `fetchMode: "browser"`.

### Changelog

- 0.1: initial release. Batch and Standby API, Markdown and text, DOCX and PDF, token count and cut, boilerplate ratio, JS render only for app shells, depth-1 same-domain links, monitor mode on main-text changes, free failed rows.

# Actor input Schema

## `urls` (type: `array`):

Pages or documents to fetch, one per line: web pages, PDF and DOCX files, e.g. "https://docs.python.org/3/library/asyncio-task.html". Any number per run, fetched in parallel. Private and internal addresses are refused.

## `formats` (type: `array`):

What to return per page: Markdown, plain text, or both. The token count is taken from the Markdown when it is requested, otherwise from the text.

## `maxTokensPerPage` (type: `integer`):

Optional: cut each page's Markdown/text to this many tokens (o200k_base, the GPT-4o tokenizer), e.g. 4000. The row gets truncated: true. Empty = no limit.

## `crawlLinks` (type: `boolean`):

true = for every listed URL, also fetch up to Max links per URL pages it links to on the same domain (one level deep). Login, cart, privacy and similar pages are skipped.

## `maxLinksPerUrl` (type: `integer`):

With link following on: how many same-domain links to fetch per listed URL, in page order, e.g. 10.

## `includeUrlPatterns` (type: `array`):

With link following on: glob patterns a link must match, e.g. "*/docs/*". Empty = any same-domain link.

## `excludeUrlPatterns` (type: `array`):

With link following on: glob patterns of links to skip, e.g. "*/blog/*".

## `renderJs` (type: `string`):

auto = plain HTTP first; a page is opened in headless Chromium only when the HTTP answer is an app shell with almost no text. always = every page in a browser (slower). never = plain HTTP only.

## `waitFor` (type: `string`):

Only for browser-rendered pages: CSS selector to wait for before reading, e.g. "article".

## `documents` (type: `boolean`):

true = extract the text of PDF (with a text layer) and Word DOCX files up to 25 MB. false = skip them as free failed rows.

## `includeLinks` (type: `boolean`):

true = keep links inline in the Markdown and add a links list (absolute URL and anchor text) to each row.

## `includeImages` (type: `boolean`):

true = keep images in the Markdown and add an images list (absolute URL and alt text) to each row.

## `proxyTier` (type: `string`):

auto = start without a proxy and step up to datacenter, residential and Web Unblocker only when a page answers with a block or challenge. The working tier is remembered per site.

## `proxyCountry` (type: `string`):

Optional two-letter country for proxy exits, e.g. "US" or "DE".

## `concurrency` (type: `integer`):

How many URLs are fetched at the same time, e.g. 5. Requests to one site stay at least Delay per domain apart.

## `domainDelaySecs` (type: `number`):

Minimum pause between two requests to the same site, in seconds, e.g. 0.5.

## `timeout` (type: `integer`):

Timeout of one request in seconds, e.g. 45. One URL gets at most 3 times this across all proxy tiers and the browser.

## `maxItems` (type: `integer`):

Stop after this many successful pages (failed pages are free and do not count), e.g. 10.

## `mode` (type: `string`):

scrape = full results; monitor = only new/changed items since the previous run of this task

## `monitorStateId` (type: `string`):

Optional state id when not running as a saved task (monitor mode)

## `webhookUrl` (type: `string`):

POST a change summary here in monitor mode

## `telegramBotToken` (type: `string`):

Optional: bot token for monitor-mode change summaries

## `telegramChatId` (type: `string`):

Optional: chat id that receives monitor-mode summaries

## Actor input object example

```json
{
  "urls": [
    "https://docs.python.org/3/library/asyncio-task.html",
    "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "formats": [
    "markdown"
  ],
  "crawlLinks": false,
  "maxLinksPerUrl": 10,
  "renderJs": "auto",
  "documents": true,
  "includeLinks": false,
  "includeImages": false,
  "proxyTier": "auto",
  "concurrency": 5,
  "domainDelaySecs": 0.5,
  "timeout": 45,
  "maxItems": 10,
  "mode": "scrape"
}
```

# Actor output Schema

## `results` (type: `string`):

All pushed rows (dataset, JSON)

## `resultsTable` (type: `string`):

Dataset in the Console viewer

## `runSummary` (type: `string`):

RUN_SUMMARY record

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://docs.python.org/3/library/asyncio-task.html",
        "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
        "https://arxiv.org/pdf/1706.03762"
    ],
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahamster/web-fetch-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [
        "https://docs.python.org/3/library/asyncio-task.html",
        "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
        "https://arxiv.org/pdf/1706.03762",
    ],
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("datahamster/web-fetch-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://docs.python.org/3/library/asyncio-task.html",
    "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "maxItems": 10
}' |
apify call datahamster/web-fetch-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datahamster/web-fetch-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/sKOu9YyCOQnsDjSMe/builds/JbguzHhcZckM4zM7U/openapi.json
