# RAG Knowledge Loader (`botflowtech/rag-knowledge-loader`) Actor

Scrapes documentation sites (GitBook, ReadTheDocs, Notion public pages) and converts them into vector-ready JSON format for RAG applications.

- **URL**: https://apify.com/botflowtech/rag-knowledge-loader.md
- **Developed by:** [BotFlowTech](https://apify.com/botflowtech) (community)
- **Categories:** AI, Developer tools, Lead generation
- **Stats:** 4 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 results

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/platform/actors/running/actors-in-store#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

## RAG Knowledge Loader

Scrapes documentation sites (GitBook, ReadTheDocs, Notion public pages) and converts them into vector-ready JSON format for RAG applications.

### Features

- Crawls entire documentation sites recursively
- Extracts clean, structured content
- Removes navigation, headers, footers automatically
- Outputs vector-ready JSON format
- Supports GitBook, ReadTheDocs, Notion, and custom doc sites

### Use Cases

- Build "Chat with Docs" chatbots
- Feed LLMs with up-to-date documentation
- Create knowledge bases for RAG pipelines
- Automated documentation updates for vector databases

### Input Parameters

#### Required

- **Start URLs** (required): Array of documentation site URLs to scrape
  - Example: `https://docs.apify.com/`, `https://your-gitbook-site.com`

#### Optional Configuration

- **Max pages to crawl** (default: 1000): Maximum number of pages to scrape
  - Minimum: 1

- **Include URL patterns (globs)** (default: \[]): Only crawl URLs matching these patterns
  - Example: `["**/api/**", "**/guides/**"]`

- **Exclude URL patterns (globs)** (default: `["**/*.pdf", "**/*.zip", "**/login**", "**/signup**"]`): Skip URLs matching these patterns

- **Content CSS Selectors** (default: `"article, main, .content, .markdown-body, #content, [role='main']"`): Comma-separated CSS selectors for main content area

- **Remove CSS Selectors** (default: `"nav, header, footer, .sidebar, #sidebar, .navigation, .cookie-banner, script, style, iframe"`): Selectors for elements to remove like navigation and headers

- **Output Format** (default: `"vector-ready"`):
  - `"vector-ready"`: Flat structure optimized for embeddings
  - `"hierarchical"`: Nested structure with full metadata

- **Crawler Type** (default: `"cheerio"`):
  - `"cheerio"`: Fast HTTP crawler for static sites
  - `"playwright"`: Browser-based crawler for JavaScript-heavy sites

#### Example Input JSON

{
"startUrls": \[
{ "url": "https://docs.example.com/" },
{ "url": "https://your-gitbook.com/docs" }
],
"maxPages": 500,
"excludeUrlGlobs": \["/\*.pdf", "/login\*\*", "/signup"],
"includeUrlGlobs": \["/docs/"],
"contentSelectors": "article, main, .markdown-body",
"removeSelectors": "nav, footer, .sidebar",
"outputFormat": "vector-ready",
"crawlerType": "cheerio"
}

#### Minimal Input Example

{
"startUrls": \[
{ "url": "https://docs.example.com/" }
]
}

### Output Format

#### Vector-Ready Format (Default)

Optimized for direct ingestion into vector databases:

{
"metadata": {
"crawledAt": "2025-12-06T08:11:00.000Z",
"totalPages": 150,
"startUrls": \["https://docs.example.com/"],
"readyForEmbedding": true
},
"documents": \[
{
"id": "unique-doc-id-123",
"text": "Full page content with all text extracted and cleaned...",
"metadata": {
"source": "https://docs.example.com/page",
"title": "Page Title",
"url": "https://docs.example.com/page",
"scrapedAt": "2025-12-06T08:11:00.000Z",
"wordCount": 1234
}
}
]
}

#### Hierarchical Format

Includes full document structure with headings and metadata:

{
"metadata": {
"crawledAt": "2025-12-06T08:11:00.000Z",
"totalPages": 150,
"startUrls": \["https://docs.example.com/"]
},
"documents": \[
{
"id": "unique-doc-id-123",
"url": "https://docs.example.com/page",
"title": "Page Title",
"content": "Full page content...",
"metadata": {
"description": "Page meta description",
"keywords": "api, documentation",
"scrapedAt": "2025-12-06T08:11:00.000Z",
"headings": \[
{ "level": 1, "text": "Introduction" },
{ "level": 2, "text": "Getting Started" }
],
"wordCount": 1234,
"characterCount": 5678
}
}
]
}

### Integration with Vector Databases

The output is ready to use with popular RAG frameworks:

- **LangChain**: Use JSONLoader to load documents
- **LlamaIndex**: Import as Document objects
- **Pinecone/Weaviate**: Batch upsert with metadata
- **Chroma**: Add to collection with embeddings

# Actor input Schema

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

URLs of documentation sites to scrape (e.g., https://docs.example.com)

## `crawlLinkedPages` (type: `boolean`):

Enable to crawl all internal links found on pages. Disable to only scrape the provided start URLs.

## `maxCrawlDepth` (type: `integer`):

Maximum depth to follow links (1 = only start URLs, 2 = start URLs + direct links, etc.). Only applies if 'Crawl Linked Pages' is enabled.

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

Maximum number of pages to scrape

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

Only crawl URLs matching these patterns (e.g., **/docs/**, **/blog/**)

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

Skip URLs matching these patterns

## `contentSelectors` (type: `string`):

CSS selectors for main content area (comma-separated)

## `removeSelectors` (type: `string`):

CSS selectors to remove (navigation, headers, footers, etc.)

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

Choose output structure

## `crawlerType` (type: `string`):

Cheerio for fast static sites, Playwright for JavaScript-heavy sites

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://docs.apify.com/"
    }
  ],
  "crawlLinkedPages": true,
  "maxCrawlDepth": 99,
  "maxPages": 1000,
  "includeUrlGlobs": [],
  "excludeUrlGlobs": [
    "**/*.pdf",
    "**/*.zip",
    "**/login**",
    "**/signup**"
  ],
  "contentSelectors": "article, main, .content, .markdown-body, #content, [role=\"main\"]",
  "removeSelectors": "nav, header, footer, .sidebar, #sidebar, .navigation, .cookie-banner, script, style, iframe",
  "outputFormat": "vector-ready",
  "crawlerType": "cheerio"
}
```

# 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/"
        }
    ],
    "excludeUrlGlobs": [
        "**/*.pdf",
        "**/*.zip",
        "**/login**",
        "**/signup**"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("botflowtech/rag-knowledge-loader").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/" }],
    "excludeUrlGlobs": [
        "**/*.pdf",
        "**/*.zip",
        "**/login**",
        "**/signup**",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("botflowtech/rag-knowledge-loader").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/"
    }
  ],
  "excludeUrlGlobs": [
    "**/*.pdf",
    "**/*.zip",
    "**/login**",
    "**/signup**"
  ]
}' |
apify call botflowtech/rag-knowledge-loader --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/ZOVNWGA2H3acK4mfw/builds/bOu9gaD6aZJWOcuEL/openapi.json
