# API Documentation Crawler for RAG & AI Agents (`ahampton83/api-docs-rag-crawler`) Actor

Crawl API documentation sites and extract structured, LLM-ready content. Use via Apify Console/API or connect as an MCP server for Claude, Cursor, and other AI agents.

- **URL**: https://apify.com/ahampton83/api-docs-rag-crawler.md
- **Developed by:** [Aaron Hampton](https://apify.com/ahampton83) (community)
- **Categories:** AI, Developer tools, MCP servers
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 page crawleds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## API Documentation Crawler for RAG & AI Agents

Crawl API documentation sites and extract clean, structured content for AI models, RAG pipelines, and vector databases. Use it as a normal Apify Actor or connect it to Claude, Cursor, and other MCP-compatible clients.

### What it does

This Actor crawls API documentation websites and returns structured records for each page:

- **Title & description**
- **Heading hierarchy** (with anchor IDs)
- **Markdown-formatted content**
- **Plain text** (for simple embedding)
- **Detected API endpoints** (method + path, when visible on the page)
- **Code examples**
- **Outbound links**
- **Metadata** (canonical URL, OpenGraph tags)

You can also switch to **chunking mode** to get pre-split text snippets ready for vector DB ingestion.

### Why use this?

- **Feed RAG pipelines** with clean, structured API docs.
- **Power AI agents** that need to answer questions about an API.
- **Avoid brittle copy-paste** from docs into LLM context windows.
- **MCP-native:** call it as a tool from Claude, Cursor, ChatGPT, and other MCP clients.

### How to use

#### Apify Console / API

Provide one or more start URLs and optional limits:

```json
{
  "startUrls": ["https://docs.apify.com/api/v2"],
  "maxPages": 20,
  "maxDepth": 2,
  "outputFormat": "full"
}
````

#### MCP mode

Connect the Actor as an MCP server in Cursor/Claude Desktop:

```json
{
  "mcpServers": {
    "api-docs-crawler": {
      "url": "https://AHampton83--api-docs-rag-crawler.apify.actor/mcp"
    }
  }
}
```

Available tools:

- `crawl_api_docs(startUrl, maxPages?, maxDepth?)` — crawl docs and return structured page summaries.
- `get_page_chunks(startUrl, maxPages?, chunkSize?, chunkOverlap?)` — return pre-chunked text for vector DBs.

### Output schema

#### Full format (`outputFormat: "full"`)

```json
{
  "url": "https://docs.example.com/api/v1/users",
  "title": "Users API",
  "description": "Manage users via the REST API",
  "headings": [{ "level": 1, "text": "Users API", "id": "users-api" }],
  "markdown": "# Users API\n\n## Get all users\n\n`GET /api/v1/users`",
  "text": "Users API Get all users GET /api/v1/users ...",
  "endpoints": [{ "method": "GET", "path": "/api/v1/users", "confidence": "high" }],
  "codeBlocks": [{ "language": "bash", "content": "curl /api/v1/users" }],
  "links": ["https://docs.example.com/api/v1/orders"],
  "metadata": { "canonicalUrl": "...", "ogTitle": "...", "ogDescription": "..." },
  "crawledAt": "2026-07-04T00:00:00.000Z"
}
```

#### Chunks format (`outputFormat: "chunks"`)

```json
{
  "chunkIndex": 0,
  "url": "https://docs.example.com/api/v1/users",
  "title": "Users API",
  "text": "...",
  "headings": [{ "level": 2, "text": "Get all users" }],
  "tokenEstimate": 250
}
```

### Pricing

This Actor uses **Pay Per Event (PPE)** billing:

| Event | Price | Notes |
|---|---|---|
| `apify-actor-start` | $0.00005 | Platform-provided synthetic start event |
| `page-crawled` | $0.005 | First 10 pages per run/tool-call are free |
| `chunk-generated` | $0.001 | First 10 chunks per run/tool-call are free |
| `tool-call` | $0.01 | Per MCP tool call |

Volume discounts apply based on the user's Apify plan tier.

### Publish & monetize

To activate monetization and publish this Actor on Apify Store:

1. Open the Actor in Apify Console: https://console.apify.com/actors/Dtlhc1snKkwxoikZh
2. Go to the **Publication** tab and click **Set up monetization**.
3. In the pricing step, keep `apify-actor-start` and add these custom events with the exact slugs used in the code:
   - `page-crawled` — $0.005
   - `chunk-generated` — $0.001
   - `tool-call` — $0.01
4. **Do not enable `apify-default-dataset-item`**: the Actor already charges manually per page/chunk, so the synthetic dataset-item event would double-charge users.
5. Complete the **Primary event** and **Review** steps, then submit for Store approval.

Payouts require a verified developer account with tax and payment details in Apify Console.

### Limits

- `maxPages`: up to 500 per normal run, 100 per MCP tool call.
- Crawls only same-origin links by default (configurable via `includeUrlGlobs`).
- Static HTML only — Cheerio crawler does not execute JavaScript.

### Use cases

- Build a custom API assistant for your product.
- Keep vector store embeddings in sync with live docs.
- Generate SDK examples from existing documentation.
- Competitive analysis of public APIs.

### Support

Open an issue or reach out via the Apify Store page.

# Actor input Schema

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

One or more API documentation URLs where crawling should begin.

## `maxPages` (type: `integer`):

Maximum number of pages to crawl per run.

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

Maximum link depth to follow from start URLs.

## `outputFormat` (type: `string`):

Return full page records or pre-chunked text for vector DBs.

## `chunkSize` (type: `integer`):

Approximate words per chunk when outputFormat is 'chunks'.

## `chunkOverlap` (type: `integer`):

Words of overlap between chunks.

## `includeUrlGlobs` (type: `array`):

Only crawl URLs matching these glob patterns (e.g. **/api/**). Leave empty to crawl all same-origin links.

## `excludeUrlGlobs` (type: `array`):

Skip URLs matching these glob patterns (e.g. **/blog/**, **/changelog/**).

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/api/v2"
    }
  ],
  "maxPages": 50,
  "maxDepth": 3,
  "outputFormat": "full",
  "chunkSize": 1000,
  "chunkOverlap": 100,
  "includeUrlGlobs": [],
  "excludeUrlGlobs": []
}
```

# 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/api/v2"
        }
    ],
    "includeUrlGlobs": [],
    "excludeUrlGlobs": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("ahampton83/api-docs-rag-crawler").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/api/v2" }],
    "includeUrlGlobs": [],
    "excludeUrlGlobs": [],
}

# Run the Actor and wait for it to finish
run = client.actor("ahampton83/api-docs-rag-crawler").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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/api/v2"
    }
  ],
  "includeUrlGlobs": [],
  "excludeUrlGlobs": []
}' |
apify call ahampton83/api-docs-rag-crawler --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=ahampton83/api-docs-rag-crawler",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "API Documentation Crawler for RAG & AI Agents",
        "description": "Crawl API documentation sites and extract structured, LLM-ready content. Use via Apify Console/API or connect as an MCP server for Claude, Cursor, and other AI agents.",
        "version": "0.1",
        "x-build-id": "1SC5VDUgJOCHcgSJO"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/ahampton83~api-docs-rag-crawler/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-ahampton83-api-docs-rag-crawler",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/ahampton83~api-docs-rag-crawler/runs": {
            "post": {
                "operationId": "runs-sync-ahampton83-api-docs-rag-crawler",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/ahampton83~api-docs-rag-crawler/run-sync": {
            "post": {
                "operationId": "run-sync-ahampton83-api-docs-rag-crawler",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "One or more API documentation URLs where crawling should begin.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "maxPages": {
                        "title": "Max pages",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Maximum number of pages to crawl per run.",
                        "default": 50
                    },
                    "maxDepth": {
                        "title": "Max crawl depth",
                        "minimum": 0,
                        "maximum": 10,
                        "type": "integer",
                        "description": "Maximum link depth to follow from start URLs.",
                        "default": 3
                    },
                    "outputFormat": {
                        "title": "Output format",
                        "enum": [
                            "full",
                            "chunks"
                        ],
                        "type": "string",
                        "description": "Return full page records or pre-chunked text for vector DBs.",
                        "default": "full"
                    },
                    "chunkSize": {
                        "title": "Chunk size (words)",
                        "minimum": 50,
                        "maximum": 3000,
                        "type": "integer",
                        "description": "Approximate words per chunk when outputFormat is 'chunks'.",
                        "default": 1000
                    },
                    "chunkOverlap": {
                        "title": "Chunk overlap (words)",
                        "minimum": 0,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Words of overlap between chunks.",
                        "default": 100
                    },
                    "includeUrlGlobs": {
                        "title": "Include URL patterns",
                        "type": "array",
                        "description": "Only crawl URLs matching these glob patterns (e.g. **/api/**). Leave empty to crawl all same-origin links.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "excludeUrlGlobs": {
                        "title": "Exclude URL patterns",
                        "type": "array",
                        "description": "Skip URLs matching these glob patterns (e.g. **/blog/**, **/changelog/**).",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
