# Web Fetch for AI - URL to Markdown, Text, HTML & PDF (`kantolabs/web-fetch-for-ai`) Actor

Fetch any URL or a list of URLs as clean Markdown, plain text, HTML or links for AI agents, MCP, RAG, n8n and Make. Auto JavaScript rendering, PDF/DOCX to Markdown, token counts. Failed, blocked and 404 pages are free.

- **URL**: https://apify.com/kantolabs/web-fetch-for-ai.md
- **Developed by:** [Kanto Labs](https://apify.com/kantolabs) (community)
- **Categories:** AI, Developer tools, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.95 / 1,000 pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
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

### What is Web Fetch for AI?

**Web Fetch for AI turns any URL into clean Markdown, plain text, HTML or a list of links** that an LLM can read straight away. Give it one web address or a list of 1,000, and you get one tidy row per URL: the main content without menus, cookie banners or ads, plus the page title, description, language, canonical URL and a **token count**, so your **AI agent, MCP client, RAG pipeline, n8n or Make workflow** knows exactly what it is feeding the model.

It is built for agents: short inputs, predictable output, a fixed **price per page**, and **every failure is free**. That covers invalid URLs, timeouts, 404s and other error pages, blocked sites and empty pages.

### What can it fetch?

- **Web pages** as Markdown with headings, lists, tables, code blocks and absolute links kept.
- **JavaScript sites** such as React, Vue and other single-page apps. With `renderJs: auto` (the default), the Actor notices an empty app shell and renders it in headless Chromium by itself. You don't need to know which sites need a browser.
- **Documents.** PDF, Word (DOCX), PowerPoint (PPTX) and Excel (XLSX/XLS) links come back as Markdown. Spreadsheet tables become Markdown tables.
- **JSON, XML, CSV, plain-text and Markdown files** are returned as they are (wrapped in a code fence for Markdown output).
- **Any other file** (images, archives) is returned with the `raw` format as base64, up to 5 MB.

### How to use it

1. Put one address in **URL**, or many in **URLs (list)**. Addresses without a scheme, like `example.com`, work. So do old `http://` sites.
2. Choose **Output formats**: `markdown` (default), `text`, `html`, `links`, `raw`.
3. Click **Start**. Results appear in the **Output** tab and can be downloaded as JSON, CSV or Excel, or read through the API.

Optional settings: **Main content only** (on by default; switch it off to keep menus and footers), **JavaScript rendering** (`auto` / `never` / `always`), **Wait after load** in milliseconds for late content, **Max tokens per page** to cut long pages to fit a context window, **Preferred language** (Accept-Language), **Timeout per URL** and **Parallel URLs**.

### How much does it cost?

You pay **one Page event per URL that is delivered with content**. The price is the same whether the URL is a plain page, a JavaScript page rendered in the browser, a PDF or an Office file. Apify also adds its small Actor start fee once per run.

**Not charged, ever:** invalid URLs, DNS errors, timeouts, redirect loops, HTTP 4xx/5xx answers (404, 403, 500...), bot-check pages, empty pages, unsupported file types, and URLs skipped because your **maximum cost per run** was reached. Each of these still gets a row with `status`, `errorCode` and a plain-English `error`, so your agent knows what happened.

**Worked example:** you fetch a list of 1,000 URLs. 930 return content, 40 are 404s, 20 are blocked and 10 time out. You pay for **930 Pages**, and the 70 failed rows cost nothing. At $1.40 per 1,000 pages, that is $1.30 plus the start fee. Store discounts apply automatically on higher Apify plans.

### Input example

```json
{
    "urls": [
        "https://www.python-httpx.org/quickstart/",
        "https://arxiv.org/pdf/1706.03762",
        "https://react.dev/learn"
    ],
    "formats": ["markdown", "links"],
    "maxTokens": 20000
}
```

### Output example

````json
{
    "url": "https://www.python-httpx.org/quickstart/",
    "status": "ok",
    "errorCode": null,
    "error": null,
    "title": "QuickStart - HTTPX",
    "fetch": {
        "loadedUrl": "https://www.python-httpx.org/quickstart/",
        "loadedTime": "2026-11-06T04:42:36.406Z",
        "httpStatusCode": 200,
        "contentLengthBytes": 79175,
        "contentType": "text/html; charset=utf-8",
        "renderedWith": "http",
        "viaProxy": false,
        "durationMs": 183
    },
    "metadata": {
        "canonicalUrl": "https://www.python-httpx.org/quickstart/",
        "title": "QuickStart - HTTPX",
        "description": "A next-generation HTTP client for Python.",
        "languageCode": "en",
        "author": null,
        "keywords": null,
        "publishedAt": null,
        "openGraph": null,
        "jsonLd": null,
        "headers": {"content-type": "text/html; charset=utf-8"}
    },
    "markdown": "# QuickStart\n\nFirst, start by importing HTTPX:\n\n```\n>>> import httpx\n```\n...",
    "links": ["https://www.python-httpx.org/", "https://www.python-httpx.org/advanced/clients/"],
    "tokenCount": 3656,
    "wordCount": 1742,
    "truncated": false,
    "charged": true
}
````

A failed URL looks like this and is free:

```json
{"url": "https://httpbin.org/status/404", "status": "failed", "errorCode": "HTTP_404",
 "error": "The website answered HTTP 404: page not found (404). Nothing was charged.", "charged": false}
```

Error codes: `INVALID_URL`, `DNS_ERROR`, `CONNECTION_FAILED`, `FETCH_TIMEOUT`, `REDIRECT_LOOP`, `HTTP_<status>`, `BLOCKED`, `EMPTY_CONTENT`, `UNSUPPORTED_CONTENT_TYPE`, `RESPONSE_TOO_LARGE`, `DOCUMENT_UNREADABLE`, `RENDER_FAILED`, `MAX_COST_REACHED`, `RUN_STOPPED`.

### Use it from AI agents (MCP)

Add the Apify MCP server (`https://mcp.apify.com`) to Claude Desktop, Claude Code, Cursor or VS Code and let the agent call `kantolabs/web-fetch-for-ai`. The tool takes a `url` (one page) or `urls` (a list), plus optional `formats` and `maxTokens`. Each field description says when to use it, so the model fills the input correctly. The run always **succeeds** and returns a row per URL, including failures, so the agent never gets an empty answer.

**Switching from another web fetch Actor?** The `url`, `formats` (`markdown`, `html`, `text`, `links`, `raw`) and `wait` inputs mean the same thing here. The output keeps the familiar `fetch` and `metadata` objects plus one key per format.

### Use it in n8n, Make and Zapier

Use the official Apify node or app. Choose **Run Actor**, pick `kantolabs/web-fetch-for-ai`, pass `{"urls": [...]}`, then **Get dataset items** and send each row's `markdown` to your LLM, vector database or spreadsheet. Schedule the run to watch the same pages every day.

### FAQ

#### Does it get past bot protection and CAPTCHAs?

No, by design. It identifies itself honestly as `KantoFetch`, does not solve CAPTCHAs, does not log in, and does not use cookies or fingerprint tricks. When a site refuses the request, it retries once from a fresh Apify datacenter proxy IP, and from the browser when the site shows a JavaScript check. If the site still says no, you get a free `BLOCKED` or `HTTP_403` row. Most documentation, blogs, news sites, government pages and small-business sites work. Some large retailers, social networks and paywalled news sites refuse datacenter traffic.

#### Why Markdown?

Markdown keeps headings, lists, tables and links but costs far fewer tokens than HTML. It is the easiest format for an LLM to read and to cite.

#### How big can a page be?

Responses up to 10 MB are processed. Use **Max tokens per page** to keep only the first N tokens. Every row reports `tokenCount`, so you can budget your context window.

#### Is it fast?

Plain pages take well under a second each after the run starts. Up to 20 URLs are fetched in parallel. JavaScript pages take a few seconds in the browser.

#### Is it legal to fetch web pages?

Fetching public pages is generally fine, but what you do with the content matters. Respect copyright, personal data rules and each site's terms.

### Related Kanto Labs Actors

- [Document to Markdown](https://apify.com/kantolabs/document-to-markdown): convert uploaded or linked PDF, DOCX, PPTX and XLSX files with page counts and RAG chunks.
- [Website SEO Audit](https://apify.com/kantolabs/website-seo-audit): an on-page SEO score and prioritised issues for any page.

Questions or a site that should work but doesn't? Open an issue on the **Issues** tab with the URL. We reply within a day.

# Actor input Schema

## `url` (type: `string`):

One web address to fetch (http:// or https://; 'example.com' works too). Agents: use this for a single page. For many pages use 'urls'. Both can be combined.

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

Many web addresses in one run (up to 1,000), fetched in parallel, one result row each. Pages, PDFs, DOCX/PPTX/XLSX, JSON, text files. If both 'url' and 'urls' are empty, a sample page is fetched.

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

What to return per URL. markdown = clean main content with headings, links, tables (best for LLMs). text = same without formatting. html = cleaned HTML. links = every absolute link on the page. raw = untouched body (base64 for binary files up to 5 MB). Empty list = best default per file type.

## `onlyMainContent` (type: `boolean`):

On (default): keep the article / main content and drop navigation, header, footer, sidebars, cookie banners, ads and share buttons. Off: the whole page body (only scripts and styles removed) - use when you need menus or footers.

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

auto (default): plain HTTP first; a headless browser is used only when the page is an empty JavaScript app shell or shows a JavaScript check. never: HTTP only, fastest. always: render every HTML page in Chromium. Same price either way.

## `wait` (type: `integer`):

Extra milliseconds to wait after the page loads, for content that appears late. Any value above 0 renders the page in the headless browser (unless JavaScript rendering is 'never'). 0 = no extra wait.

## `maxTokens` (type: `integer`):

Cut markdown and text to this many tokens (cl100k, about 0.75 words per token) so a page fits an LLM context; the row then has truncated=true. 0 = no limit. Every row reports tokenCount either way.

## `language` (type: `string`):

Sent as the Accept-Language header so multilingual sites return that language, e.g. 'de-DE,de;q=0.9' or 'ja'.

## `timeoutSecs` (type: `integer`):

Time allowed for downloading one URL; the browser step gets the same again. A URL that runs out of time becomes a free FETCH_TIMEOUT row; the run itself never hangs.

## `maxConcurrency` (type: `integer`):

How many URLs are fetched at the same time. Raise it for long lists of different sites; lower it to be gentle with one site.

## `useApifyProxy` (type: `boolean`):

When a site refuses the request (403/429/503, bot-check page, timeout), retry once from a fresh Apify datacenter proxy IP. No CAPTCHA solving, no login, no cookies: still blocked = free BLOCKED row.

## Actor input object example

```json
{
  "urls": [
    "https://www.python-httpx.org/quickstart/"
  ],
  "formats": [
    "markdown"
  ],
  "onlyMainContent": true,
  "renderJs": "auto",
  "wait": 0,
  "maxTokens": 0,
  "language": "en-US,en;q=0.9",
  "timeoutSecs": 30,
  "maxConcurrency": 5,
  "useApifyProxy": true
}
```

# Actor output Schema

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

No description

# 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://www.python-httpx.org/quickstart/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kantolabs/web-fetch-for-ai").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://www.python-httpx.org/quickstart/"] }

# Run the Actor and wait for it to finish
run = client.actor("kantolabs/web-fetch-for-ai").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://www.python-httpx.org/quickstart/"
  ]
}' |
apify call kantolabs/web-fetch-for-ai --silent --output-dataset

```

## MCP server setup

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

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/ba9Kzz7jnurI7gUpC/builds/jAKFN7suGJxBZd6Bf/openapi.json
