# Website to Markdown Crawler for RAG (`cardine-labs/md-crawler-rag`) Actor

Crawl any docs site into clean, LLM-ready Markdown and heading-aware chunks for RAG and vector databases. Hard page cap, incremental re-crawls, coverage report. $0.50 per 1,000 pages. No login. JSON/CSV, API or MCP.

- **URL**: https://apify.com/cardine-labs/md-crawler-rag.md
- **Developed by:** [Cardine Labs](https://apify.com/cardine-labs) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 pages processed

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/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

## Website to Markdown Crawler for RAG

Crawl a documentation site, help center or blog and get **clean Markdown plus heading-aware chunks** ready for embeddings, vector databases and LLM prompts. The page limit you set is a **hard cap** on pages and HTTP requests, every run writes a **coverage report**, and scheduled re-crawls return **only the pages that changed**, so you re-embed (and pay for) only what is new.

**Contents:** [What it does](#what-does-website-to-markdown-crawler-for-rag-do) · [Who it is for](#who-is-it-for) · [How to use it](#how-to-use-it-step-by-step) · [Input](#input) · [Output](#output) · [Cost](#how-much-does-it-cost) · [Integrations](#integrations) · [Is it legal?](#is-it-legal) · [Limits](#what-this-actor-does-not-do) · [Troubleshooting](#troubleshooting) · [FAQ](#faq) · [Other Actors](#other-cardine-labs-actors)

### What does Website to Markdown Crawler for RAG do?

You give it one or more start URLs. It follows links on the same site up to the depth you choose, removes menus, sidebars, cookie banners and footers, converts the main content to Markdown and splits it into chunks that never cut a code block in half. Each chunk carries the path of headings above it (for example `["Getting started", "Authentication", "API tokens"]`), which is exactly what you need to show citations in a RAG answer.

- **Hard cost cap.** `maxItems` limits both the pages saved and the HTTP requests made. In our November 2026 benchmark, 15 pages requested meant 15 or 16 HTTP requests on five real documentation sites. You can never be billed for more pages than you asked for.
- **Coverage report on every run.** The `RUN_REPORT` record tells you how many pages were new, changed, unchanged, removed, failed or blocked by robots.txt. No silent "successful" runs with missing pages.
- **Incremental crawling.** Turn on `incremental` and later runs return only new or changed pages, detected by a content hash. Unchanged pages are not charged.
- **Faithful Markdown.** Tables stay Markdown tables, links become absolute, code blocks are kept whole, navigation is removed (also on Sphinx sites without a `<main>` element).
- **Heading-aware chunks** with a configurable maximum size, the heading path and the character count, so you can go straight to your embedding model.
- **Polite by default.** robots.txt is respected and the crawl stays on the domains of your start URLs unless you say otherwise.

### Who is it for

- **AI engineers building RAG chatbots** over product docs, public wikis or API references. You get chunks with headings for citations and a cheap way to keep the index fresh.
- **Developer relations and documentation teams** who want their docs available to Claude, ChatGPT or Cursor as Markdown, or who need a snapshot of the docs before a migration.
- **Support teams** that feed a help center into an AI assistant and want only changed articles re-indexed each night.
- **Agencies and consultants** who prepare knowledge bases for clients and must quote a fixed maximum cost in advance.
- **Researchers and analysts** who need the text of a site in a format that is easy to diff, search and quote.
- **No-code builders** using n8n, Make or Zapier to keep a vector store (Pinecone, Qdrant, Supabase, Weaviate) in sync with a website.

### How to use it, step by step

1. Open the Actor in Apify Console and click **Try for free** (you need a free Apify account).
2. In **Start URLs**, paste the page where the crawl should start, for example `https://docs.apify.com/academy`. Add more URLs if the site has several sections.
3. Set **Max pages**. This is the hard limit on pages and requests, and so your maximum cost. Start with 50 to check the result.
4. Set **Max depth** (how many clicks away from the start URL to go). 2 is enough for most documentation sections.
5. Leave **Incremental crawl** off for the first run. Click **Start**.
6. When the run finishes, open the **Output** tab: one row per page with title, status and number of chunks. Download JSON, CSV or Excel, or open the `RUN_REPORT` record in the key-value store to see the coverage.
7. To keep the index fresh, create a **Schedule** (for example daily), turn on **Incremental crawl** and use the same **State key** for the same site. Each run then returns only new and changed pages.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` | array of URLs | (required) | Pages where the crawl starts. Links on the same site are followed. |
| `maxItems` | integer | 50 | Hard limit on pages processed and HTTP requests. This is also your maximum cost. |
| `maxDepth` | integer | 2 | How many clicks away from the start URLs to follow (0-10). |
| `maxChunkChars` | integer | 1200 | Maximum length of each chunk in characters (200-8000). |
| `incremental` | boolean | false | Return only pages that are new or changed since the last run with the same state key. |
| `includeUnchanged` | boolean | false | Also return unchanged pages (charged as processed pages). |
| `sameDomainOnly` | boolean | true | Follow links only on the domains of the start URLs. |
| `stateKey` | string | `default` | Use a different key for each site so each keeps its own crawl history. |

Example input:

```json
{
  "startUrls": [{ "url": "https://docs.apify.com/academy" }],
  "maxItems": 100,
  "maxDepth": 2,
  "maxChunkChars": 1200,
  "incremental": true,
  "stateKey": "apify-academy"
}
```

`incremental` is off by default so that a first run (and the Store's daily test) always returns everything.

### Output

One dataset row per page. These examples come from a real run on `docs.apify.com/academy` (10 pages, depth 1, 5 December 2026); the Markdown and chunk text are shortened here.

```json
{
  "schemaVersion": 1,
  "url": "https://docs.apify.com/academy",
  "title": "Apify Academy | Academy | Apify Documentation",
  "status": "new",
  "contentHash": "61b8de239e585d2fa68c5b59",
  "crawledAt": "2026-12-05T11:30:29.657Z",
  "chunkCount": 5,
  "markdown": "# Apify Academy\n\nLearn everything about web scraping and automation with our free courses...\n\n## Beginner courses\n\n#### Web scraping with AI\n...",
  "chunks": [
    {
      "index": 0,
      "headingPath": ["Apify Academy"],
      "text": "# Apify Academy\n\nLearn everything about web scraping and automation with our free courses...",
      "chars": 309
    },
    {
      "index": 1,
      "headingPath": ["Apify Academy", "Beginner courses", "Web scraping basics with JS"],
      "text": "#### Web scraping basics with JS\n\nLearn how to use JavaScript to extract information from websites...",
      "chars": 320
    }
  ]
}
```

```json
{
  "schemaVersion": 1,
  "url": "https://docs.apify.com/get-started",
  "title": "What is Apify | Platform | Apify Documentation",
  "status": "new",
  "contentHash": "06d110ca0e4bacce0319b838",
  "crawledAt": "2026-12-05T11:30:35.057Z",
  "chunkCount": 4,
  "chunks": [
    {
      "index": 0,
      "headingPath": ["What is Apify"],
      "text": "# What is Apify\n\nApify is a cloud platform for web scraping, data extraction, and automation...",
      "chars": 1010
    }
  ]
}
```

The same run wrote this `RUN_REPORT` record:

```json
{ "requests": 10, "pages": 10, "new": 10, "changed": 0, "unchanged": 0, "blockedByRobots": 0,
  "failed": 0, "chunks": 76, "removedSinceLastRun": [], "maxItems": 10, "maxDepth": 1,
  "incremental": false, "truncated": true }
```

**Fields:** `url`, `title`; `status` is `new`, `changed` or `unchanged`; `contentHash` identifies the cleaned content; `crawledAt` is an ISO date; `chunkCount`; `markdown` is the full cleaned page; `chunks[]` contains `index`, `headingPath`, `text` and `chars`. The **Output** tab shows a table with URL, title, status, chunk count and crawl date; the full Markdown and chunks are in the JSON export.

**Benchmark (November 2026, 15 pages per site, static HTML):**

| Site | HTTP requests | Pages | Failed | Chunks | Largest chunk (chars) | Markdown tables |
|---|---|---|---|---|---|---|
| docs.apify.com/academy | 15 | 15 | 0 | 107 | 1,180 | 0 |
| crawlee.dev | 16 | 15 | 0 | 246 | 1,237 | 0 |
| git-scm.com/docs | 16 | 15 | 0 | 154 | 1,198 | 0 |
| docs.python.org tutorial | 16 | 15 | 0 | 249 | 1,217 | 1 |
| sqlite.org/docs | 15 | 15 | 0 | 289 | 1,231 | 9 |

### How much does it cost?

This Actor uses **pay per event**: you pay **$0.50 per 1,000 pages processed** ($0.0005 per page), plus an Actor start event of $0.00005 per GB of memory (one event at the default 1 GB). Platform compute is included: there is no separate usage bill.

- **100 pages** of documentation: about **$0.05**.
- **1,000 pages**, a large product documentation site: about **$0.50**.
- **Daily incremental re-crawl** of a 1,000-page site where about 20 pages change per day: about 20 × $0.0005 = **$0.01 per day**, roughly $0.30 per month, because unchanged pages are not charged.

**Compared honestly with the leader:** Apify's own Website Content Crawler is free to rent but you pay platform usage (compute, and proxies if used); its default run uses 8 GB of memory and it can render JavaScript, which we do not. For static documentation sites, a flat per-page price with a hard cap is easier to predict. Other Store crawlers that convert to Markdown charge between $0.003 and $0.03 per page (Store prices on 5 December 2026). The free Apify plan includes $5 of monthly credit, enough for about 10,000 pages here.

### Integrations

**API (JavaScript):**

```javascript
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('cardine-labs/md-crawler-rag').call({
  startUrls: [{ url: 'https://docs.example.com' }], maxItems: 200, incremental: true, stateKey: 'example-docs',
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
const chunks = items.flatMap((p) => p.chunks.map((c) => ({ url: p.url, ...c })));
```

**API (Python):**

```python
from apify_client import ApifyClient
client = ApifyClient(token="YOUR_APIFY_TOKEN")
run = client.actor("cardine-labs/md-crawler-rag").call(run_input={
    "startUrls": [{"url": "https://docs.example.com"}], "maxItems": 200})
for page in client.dataset(run["defaultDatasetId"]).iterate_items():
    for chunk in page["chunks"]:
        print(page["url"], " > ".join(chunk["headingPath"]), chunk["chars"])
```

- **LangChain and LlamaIndex:** load the dataset with their Apify dataset loaders and map `chunks[].text` to documents, `url` and `headingPath` to metadata.
- **n8n:** we publish a ready template, *Docs to Markdown for RAG*, that runs this Actor through the `run-sync-get-dataset-items` endpoint with a plain HTTP Request node and passes the chunks to your vector store. No community node is needed.
- **Make and Zapier:** use the Apify app ("Run Actor" and "Get dataset items").
- **Google Sheets:** export the dataset as CSV or use the Apify Google Sheets integration for a list of pages and statuses.
- **Webhooks:** add a webhook on "Run succeeded" to trigger your re-embedding job only when the run is done.
- **MCP:** the [Web Data Tools MCP Server](https://apify.com/cardine-labs/web-tools-mcp) exposes this crawler as the `crawl_to_markdown` tool for Claude, Cursor and VS Code.

### Is it legal?

The Actor reads only **public web pages**, the same pages any visitor sees, without logging in. It checks **robots.txt** before each request and skips disallowed paths (they appear as `blockedByRobots` in the report), stays on the start domains by default and makes at most as many requests as `maxItems`. It does not use residential proxies or bypass anti-bot systems or CAPTCHAs.

Copyright still applies to the text you collect: documentation is usually licensed for reading, and reuse in an AI product may need the owner's permission. Crawl your own sites, sites whose license allows reuse (many open-source docs use MIT, Apache or Creative Commons licenses), or get permission. The pages you crawl may contain personal data such as author names; under the GDPR you need a legal basis to store them, and you should keep only what your use case needs. This is general information, not legal advice.

### What this Actor does not do

- **No JavaScript rendering.** It reads static HTML. Single-page apps that build the content in the browser may return little text. Most documentation generators (Docusaurus, Sphinx, MkDocs, Hugo) work.
- **No login, no paywalls, no private pages.**
- **No PDFs, Word files or images.** For files, use our Document to Markdown Actor (below).
- **Chunk size is in characters, not tokens.** 1,200 characters is roughly 300 English tokens.
- **No embeddings.** It prepares the text; you choose the embedding model.
- **No proxies or anti-bot bypass.** Sites that block crawlers stay blocked, and that is reported.

### Troubleshooting

- **Fewer pages than expected.** Check `RUN_REPORT`: `truncated: true` means `maxItems` was reached; `blockedByRobots` counts pages robots.txt forbids; increase `maxDepth` if links are deeper than you thought.
- **Very short Markdown.** The site is probably rendered with JavaScript. Try a static version (many docs sites have one) or start from pages listed in the sitemap.
- **Incremental run returned nothing.** That is expected if nothing changed. Use the same `stateKey` as before; to get everything again, use a new key or turn on `includeUnchanged`.
- **Pages from another domain appear.** Make sure `sameDomainOnly` is on.
- **Chunks too large or too small for your model.** Change `maxChunkChars` (for example 800 for small-context models, 3000 for long-context models).
- **A page failed.** It is counted in `failed`; the rest of the run continues. Re-run later; temporary 5xx errors are common.

### FAQ

**How is this different from Apify's Website Content Crawler?** Website Content Crawler is the most complete general crawler on the Store, with JavaScript rendering, file downloads and many options, priced by platform usage. This Actor is narrower: static sites, a fixed price per page, a hard page and request cap, a coverage report and change-only re-crawls with heading-path chunks. In a small November 2026 test with a 15-page limit, Website Content Crawler returned 21 pages on git-scm.com/docs and 1 page on sqlite.org/docs; ours returned exactly 15 on both.

**Does it render JavaScript?** No, static HTML only.

**How do I get only changed pages?** Turn on `incremental`, keep the same `stateKey` per site and schedule the Actor. Removed pages are listed in `RUN_REPORT.removedSinceLastRun` so you can delete them from your vector store.

**Can I go over my page limit?** No. `maxItems` caps both saved pages and HTTP requests.

**Can it crawl several sites in one run?** Yes, add several start URLs, but use one run (and one `stateKey`) per site if you want separate change histories.

**Which chunk size should I use?** 800-1,500 characters works well for most embedding models and keeps answers precise.

**Where is the run summary?** In the `RUN_REPORT` record of the run's key-value store.

**Can my AI agent call it directly?** Yes, through the Web Data Tools MCP Server or the Apify MCP server.

### Other Cardine Labs Actors

- [Document to Markdown](https://apify.com/cardine-labs/document-to-markdown): PDF, Word and other files to Markdown for the same RAG pipeline.
- [Sitemap New Pages Monitor](https://apify.com/cardine-labs/sitemap-new-pages-monitor): know which URLs were added to a site before you re-crawl.
- [Website Change Monitor](https://apify.com/cardine-labs/website-change-monitor): alerts when specific pages change.
- [Technical SEO Audit & Broken Link Checker](https://apify.com/cardine-labs/seo-site-auditor): broken links, titles and canonicals of the same site.
- [Web Data Tools MCP Server for Claude & Cursor](https://apify.com/cardine-labs/web-tools-mcp): this crawler and five other tools inside your AI assistant.

Questions, or a site that does not convert well? Open an issue on the Issues tab; we answer within 48 hours.

# Changelog

This Actor's version history is a separate document: https://apify.com/cardine-labs/md-crawler-rag/changelog.md

# Actor input Schema

## `startUrls` (type: `array`):

Pages where the crawl starts. Links on the same site are followed.

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

Hard limit on pages processed and HTTP requests. This is also your maximum cost.

## `maxDepth` (type: `integer`):

How many clicks away from the start URLs to follow.

## `maxChunkChars` (type: `integer`):

Maximum length of each text chunk.

## `incremental` (type: `boolean`):

Return only pages that are new or changed since the last run with the same state key. Turn it on for scheduled runs.

## `includeUnchanged` (type: `boolean`):

Also return pages that did not change since the last run (charged as processed pages).

## `sameDomainOnly` (type: `boolean`):

Follow links only on the domains of the start URLs.

## `stateKey` (type: `string`):

Use a different key for each site so each keeps its own crawl history.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy"
    }
  ],
  "maxItems": 50,
  "maxDepth": 2,
  "maxChunkChars": 1200,
  "incremental": false,
  "includeUnchanged": false,
  "sameDomainOnly": true,
  "stateKey": "default"
}
```

# Actor output Schema

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

One row per page: URL, title, status, Markdown and chunks.

## `summary` (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 = {
    "startUrls": [
        {
            "url": "https://docs.apify.com/academy"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("cardine-labs/md-crawler-rag").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 = { "startUrls": [{ "url": "https://docs.apify.com/academy" }] }

# Run the Actor and wait for it to finish
run = client.actor("cardine-labs/md-crawler-rag").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 '{
  "startUrls": [
    {
      "url": "https://docs.apify.com/academy"
    }
  ]
}' |
apify call cardine-labs/md-crawler-rag --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cardine-labs/md-crawler-rag"
        }
    }
}
```

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/UkPcwgTFZxfANZ98H/builds/eAL5AlWevlEI8BUU7/openapi.json
