# RAG Documentation-to-Markdown Extractor (`afkdigital/rag-documentation-to-markdown-extractor`) Actor

Convert permitted technical documentation or supplied HTML into source-linked Markdown, with code, tables and optional heading-aware chunks.

- **URL**: https://apify.com/afkdigital/rag-documentation-to-markdown-extractor.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 converted 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?

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

## RAG Documentation-to-Markdown Extractor

Turn permitted technical documentation into Markdown for search, indexing or offline reading. One output record represents one attempted page. The default example is original inline HTML and needs no external website.

### Input

Provide startUrls (strings or objects with a url) or htmlFiles (objects with sourceUrl and UTF-8 html text). Paste file contents as strings. Source URLs identify uploaded files and resolve relative references. No remote requests are made for uploads. Clear the sample htmlFiles before submitting your own URLs. Before live fetching, review the publisher's terms, confirm your rights and set sourceTermsReviewed to true. This confirmation records the caller's review. The Actor checks robots.txt separately for every origin, including redirect targets. Use public documentation only.

allowedDomains is an exact hostname allowlist, defaulting to seed hosts. includePaths and excludePaths match a full path or its slash-delimited descendants. Specify narrow language and version prefixes. maxDepth defaults to zero, up to three. Discovery requires includePaths. maxPages counts unique attempts including failures (default 10, maximum 100). Redirect aliases and duplicate URLs do not create another successful page. Separate final URLs remain separate even when their content or declared canonical URLs match.

### Extraction and limits

renderMode is http. The Actor does not execute JavaScript or code samples, sign in, summarize missing material or reconstruct dynamic panels. Dynamic sites can yield failed or partial static content. Main/article selection and navigation removal are heuristic. Standard tables are converted to GFM. Headerless or merged tables retain HTML. Links are resolved against the document base. Standard ports only, public DNS addresses pinned at connection time, up to three redirects, 8 seconds per HTTP transfer, maximum 1 MiB per HTML body. HTTP robots redirects, undecodable content and oversized responses can fail closed. The output limit is 7 MiB per row. Input that requires a browser should be supplied as permitted HTML. Never submit sensitive content.

### Output and pricing

sourceUrl is the submitted/discovered URL, resolvedUrl the final URL and canonicalUrl the publisher's declared canonical or final URL. Each successful record contains title, first section headingPath, full markdown, codeLanguages, SHA-256 contentHash of UTF-8 Markdown, fetchedAt (processing timestamp), extractionStatus and warnings. Failed records have no Markdown. Optional chunks contain chunkId, chunkText and headingPath within their parent source record. Use sourceUrl plus chunkId for provenance. optionalChunkSize is zero or 256–32000 Unicode code points. overlap is zero to half the chunk size, only within one heading section. Chunk boundaries may split code blocks. No tokenizer, embeddings or RAG accuracy guarantee.

The configured custom PPE unit is page-converted: one successful page of at most 1 MiB input, including all its chunks. Failed rows and skipped duplicates trigger no custom event. No per-chunk charge. Check the Store pricing tab for active rates.

### Download and automation

See examples/input.json and examples/download.sh for a Markdown export. Set APIFY_TOKEN and DATASET_ID for private runs. See examples/integrations.md for n8n and Make flows.

# Actor input Schema

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

Documentation URLs

## `htmlFiles` (type: `array`):

Inline HTML files

## `allowedDomains` (type: `array`):

Exact allowed hostnames

## `includePaths` (type: `array`):

Included path prefixes

## `excludePaths` (type: `array`):

Excluded path prefixes

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

maxPages

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

maxDepth

## `optionalChunkSize` (type: `integer`):

optionalChunkSize

## `overlap` (type: `integer`):

overlap

## `renderMode` (type: `string`):

Static HTTP only

## `sourceTermsReviewed` (type: `boolean`):

Required for live URLs

## Actor input object example

```json
{
  "htmlFiles": [
    {
      "sourceUrl": "https://docs.example.org/en/v1/client",
      "html": "<title>Client guide</title><nav>Menu</nav><main><h1>Client guide</h1><h2>Read a record</h2><p>See the <a href=\"schema\">schema</a>.</p><pre><code class=\"language-python\">def read(client):\n    return client.get(\"record\")\n</code></pre><table><tr><th>Field</th><th>Type</th></tr><tr><td>id</td><td>string</td></tr></table></main>"
    }
  ],
  "maxPages": 10,
  "maxDepth": 0,
  "optionalChunkSize": 0,
  "overlap": 0,
  "renderMode": "http",
  "sourceTermsReviewed": false
}
```

# Actor output Schema

## `pages` (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 = {
    "htmlFiles": [
        {
            "sourceUrl": "https://docs.example.org/en/v1/client",
            "html": "<title>Client guide</title><nav>Menu</nav><main><h1>Client guide</h1><h2>Read a record</h2><p>See the <a href=\"schema\">schema</a>.</p><pre><code class=\"language-python\">def read(client):\n    return client.get(\"record\")\n</code></pre><table><tr><th>Field</th><th>Type</th></tr><tr><td>id</td><td>string</td></tr></table></main>"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/rag-documentation-to-markdown-extractor").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 = { "htmlFiles": [{
            "sourceUrl": "https://docs.example.org/en/v1/client",
            "html": """<title>Client guide</title><nav>Menu</nav><main><h1>Client guide</h1><h2>Read a record</h2><p>See the <a href=\"schema\">schema</a>.</p><pre><code class=\"language-python\">def read(client):
    return client.get(\"record\")
</code></pre><table><tr><th>Field</th><th>Type</th></tr><tr><td>id</td><td>string</td></tr></table></main>""",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/rag-documentation-to-markdown-extractor").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 '{
  "htmlFiles": [
    {
      "sourceUrl": "https://docs.example.org/en/v1/client",
      "html": "<title>Client guide</title><nav>Menu</nav><main><h1>Client guide</h1><h2>Read a record</h2><p>See the <a href=\\"schema\\">schema</a>.</p><pre><code class=\\"language-python\\">def read(client):\\n    return client.get(\\"record\\")\\n</code></pre><table><tr><th>Field</th><th>Type</th></tr><tr><td>id</td><td>string</td></tr></table></main>"
    }
  ]
}' |
apify call afkdigital/rag-documentation-to-markdown-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/rag-documentation-to-markdown-extractor"
        }
    }
}
```

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/O00zUaa1anp5voUec/builds/VKvpKcnAhgaYsGr6l/openapi.json
