# AI-Ready Documentation & RAG Ingest (`laced_kirtan/ai-ready-docs-rag`) Actor

Crawls public documentation pages, removes navigation and boilerplate, and emits clean Markdown with bounded token-sized chunks.

- **URL**: https://apify.com/laced\_kirtan/ai-ready-docs-rag.md
- **Developed by:** [Shwetanshu Mehta](https://apify.com/laced_kirtan) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 documentation pages

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/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## AI-Ready Documentation & RAG Ingest

This Actor crawls public documentation, blog, or Notion HTML pages and returns clean Markdown without navigation, scripts, styles, forms, or other boilerplate. Each page includes an exact `cl100k_base` token count plus stable, overlapping chunks designed for vector ingestion.

### Input

```json
{
  "startUrls": ["https://docs.python.org/3/library/asyncio.html"],
  "maxDepth": 3,
  "chunkSize": 1000,
  "chunkOverlapTokens": 100,
  "outputFormat": "MARKDOWN_CHUNKS",
  "maxRetries": 2
}
```

The crawler stays on each start URL origin, follows same-origin links only, and emits pages as soon as they are processed. It does not execute JavaScript or bypass authentication; JS-only pages may therefore produce an empty-page or fetch diagnostic in `RUN_SUMMARY`. Public-site markup and anti-bot behavior can change; direct retries are bounded, challenge pages are reported, and CAPTCHAs are never solved or bypassed. Unexpected empty Markdown pages become bounded, query-stripped source warnings instead of silent healthy results.

### Output

```json
{
  "url": "https://docs.example/guide/create",
  "title": "Create a charge",
  "markdown": "# Create a charge\nTo charge a credit card...",
  "tokenCount": 842,
  "tokenizer": "cl100k_base",
  "chunks": ["Chunk 1 content...", "Chunk 2 content..."],
  "chunkMetadata": [{
    "chunkId": "9f75ef57c3d8948e6b77e59e6c2f764fce6b5804f63f28e84762eb86d9d96a95",
    "chunkIndex": 0,
    "headingPath": ["Create a charge"],
    "tokenCount": 842,
    "overlapTokenCount": 0
  }],
  "ingestStatus": "ready",
  "isChargeable": true
}
```

### Resource controls

- BFS uses an index cursor instead of repeated `shift()` and has a hard page/queue cap.
- HTML responses and Markdown per page have byte/character limits before expensive parsing; truncation is explicit in `truncated`.
- The tokenizer is initialized once per run, and chunking uses bounded text segments instead of retaining every page.
- Pages are not retained after `Actor.pushData`; only bounded URL sets and the current DOM are live.
- No concurrent request fan-out is used, which limits peak parser memory and source load.

### Monetization

The manifest declares `documentation-page` at $0.0008 per substantive page ($0.80 per 1,000). Empty or low-content pages are returned with `isChargeable: false` and are not charged.

The published schema includes one official Python documentation prefill with `maxDepth: 0` and `maxPages: 1`, so the Store health test receives one useful page without an uncontrolled crawl. Replace it with your own documentation URLs for production use.

### Local development

```bash
npm install
npm test
npm run check
apify validate-schema .actor/input_schema.json
apify run --purge
```

# Actor input Schema

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

One or more public documentation pages. Crawling stays on each start URL origin by default.

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

Maximum number of same-origin link hops from each start URL.

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

Hard cl100k\_base token limit for each Markdown chunk.

## `chunkOverlapTokens` (type: `integer`):

Maximum cl100k\_base token overlap copied from the preceding chunk to preserve retrieval context.

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

Whether to return one full-page chunk or token-sized Markdown chunks.

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

Hard run-level page cap; pages are emitted as they are processed.

## `maxResponseBytes` (type: `integer`):

Reject oversized pages before DOM parsing.

## `maxMarkdownChars` (type: `integer`):

Truncate unusually large cleaned pages before chunking and output.

## `maxRetries` (type: `integer`):

Bounded direct retries after failed or challenged public page requests. Challenge pages are detected, but CAPTCHAs are never solved or bypassed.

## `requestTimeoutSecs` (type: `integer`):

Timeout per public documentation page request.

## Actor input object example

```json
{
  "startUrls": [
    "https://docs.python.org/3/library/asyncio.html"
  ],
  "maxDepth": 3,
  "chunkSize": 1000,
  "chunkOverlapTokens": 100,
  "outputFormat": "MARKDOWN_CHUNKS",
  "maxPages": 1,
  "maxResponseBytes": 5000000,
  "maxMarkdownChars": 250000,
  "maxRetries": 1,
  "requestTimeoutSecs": 60
}
```

# Actor output Schema

## `records` (type: `string`):

No description

## `runSummary` (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": [
        "https://docs.python.org/3/library/asyncio.html"
    ],
    "maxDepth": 0,
    "maxPages": 1,
    "maxRetries": 1,
    "requestTimeoutSecs": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("laced_kirtan/ai-ready-docs-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": ["https://docs.python.org/3/library/asyncio.html"],
    "maxDepth": 0,
    "maxPages": 1,
    "maxRetries": 1,
    "requestTimeoutSecs": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("laced_kirtan/ai-ready-docs-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": [
    "https://docs.python.org/3/library/asyncio.html"
  ],
  "maxDepth": 0,
  "maxPages": 1,
  "maxRetries": 1,
  "requestTimeoutSecs": 60
}' |
apify call laced_kirtan/ai-ready-docs-rag --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,laced_kirtan/ai-ready-docs-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/fcAqx1pcu0hlSf7I4/builds/e7r487tFIEyJX3MKj/openapi.json
