# Website to Markdown & RAG Refresh API (`solidscrape/docs-to-rag-dataset`) Actor

Convert website pages and sitemaps to clean Markdown, cited RAG chunks and FAQ retrieval tests. Refresh changed pages with strict page and spending limits.

- **URL**: https://apify.com/solidscrape/docs-to-rag-dataset.md
- **Developed by:** [SolidScrape](https://apify.com/solidscrape) (community)
- **Categories:** AI, Developer tools
- **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 page indexeds

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

### Website to Markdown, cited RAG chunks and safe refreshes

Give the API public HTML pages or a small sitemap you have permission to process. It returns clean Markdown, text and code chunks with source citations, content hashes, and real FAQ headings as candidate retrieval tests. Optional refresh snapshots distinguish initial, new, updated and unchanged pages. Existing URL-only inputs and chunk fields continue to work.

Use it to seed a documentation assistant, refresh a chatbot knowledge base, or evaluate retrieval before changing embedding models. All collection, Markdown conversion and chunking run inside the Actor container. Embeddings and model-generated text are outside the price and scope.

[Follow the website refresh tutorial and download the working example](https://solidscrape-monitoring-guides.techmuhafiz.chatgpt.site/website-rag-refresh/).

#### Discover pages from a sitemap

This small example discovers the English FAQ page from the official Sitemaps.org sitemap. The path filter is checked before any content-page request. Robots and sitemap requests remain billable.

```json
{
  "sitemapUrls": ["https://www.sitemaps.org/sitemap.xml"],
  "includePathPrefixes": ["/faq.html"],
  "maxPages": 1,
  "maxChunks": 100,
  "maxSpendUsd": 0.02
}
```

One robots check, one sitemap fetch and one productive page cost **$0.007**. `urls` and `sitemapUrls` can be combined. Supplied URLs are first, followed by sitemap order. `includePathPrefixes` and `excludePathPrefixes` are literal path prefixes, such as `/docs/`, with exclusions taking priority. These filters apply to pages; sitemap documents must still be fetched for discovery. Child sitemaps and their pages stay on their originating sitemap's host. Cross-origin, credential-bearing, query-string and non-HTTPS locations are rejected.

#### Refresh only pages that changed

After the first successful run, copy its `SNAPSHOT` record into `previousSnapshot` on the next run. Keep `chunkChars` the same and set `changesOnly: true`. The default dataset and `MARKDOWN.pages` then contain only initial, new or updated pages. Unchanged pages remain listed in MANIFEST and retain their stored chunk references.

An unchanged check still fetches the source to verify its content. It incurs the same request fees but no `page-indexed` fee. For the one-page sitemap example, an unchanged refresh costs **$0.0065**. For the direct Python FAQ below, it costs **$0.005**. Snapshot timestamps record observation time, not the source's publication time.

Only completely processed pages advance their snapshot hash. Failed, filtered, unvisited and chunk-limited pages retain their old snapshot records. A URL disappearing from a sitemap is **not treated as a deletion**. `MANIFEST.safeToDeleteMissingPages` is always false. Retain prior index entries for these pages and handle intentional removals in your application. Snapshot state contains hashes and chunk IDs, not old text, so keep your own corpus. Native schedules with a fixed input do not automatically carry a new snapshot forward; your client must load the latest SNAPSHOT before each refresh.

`SNAPSHOT` holds up to 200 page records and 150 KB across runs. A snapshot limit stops new acknowledgements rather than dropping existing state. Split large sites into path-specific tasks. With `changesOnly: false` (the default), unchanged pages produce their ordinary chunk output and can incur an indexed-page event.

#### Clean Markdown for AI tools

Open `MARKDOWN` in the output to retrieve one record per successfully extracted page with `sourceUrl`, `title`, `markdown`, `contentHash`, `change`, `retrievedAt` and `chunksComplete`. Markdown keeps headings, ordinary links, fenced code, lists and supported tables, and removes navigation and scripts. Links are resolved to absolute HTTP(S) URLs; images are referenced, not downloaded. Complex layouts and JavaScript-only content need another collection method. A page's full Markdown can exist even when its chunk output was capped, so check `chunksComplete` before replacing that page's vector index.

#### Try one Python FAQ page

[Open the prefilled Python FAQ example](https://apify.com/solidscrape/docs-to-rag-dataset/examples/python-faq-to-rag-retrieval-evals) to turn one documentation page into cited chunks and retrieval tests.

Using Python? [Download the developer starter kit](https://api.apify.com/v2/key-value-stores/4RzLeqS1i9E9znTQC/records/solidscrape-ai-data-starter-kit-v1.zip?signature=Ke5Ew8SMdbluTC110rRe), then follow its guide to run `python run.py docs`. The client sets a $0.02 cap per run.

```json
{
  "urls": ["https://docs.python.org/3/faq/general.html"],
  "chunkChars": 1800,
  "maxChunks": 30,
  "maxSpendUsd": 0.02
}
```

This example costs **$0.0055** when its robots request and page request succeed and the page yields chunks. Actual content and chunk count depend on the upstream document. To sample code, replace the URL with `https://docs.python.org/3/tutorial/errors.html`. Open the Chunks output, then the EVAL_CASES record under Storage. If a page has no qualifying question headings, EVAL_CASES is an empty array.

#### Use from an application or a coding assistant

Set APIFY_TOKEN in your own runtime environment. This Node.js example requests the same small corpus and shows the citation and content hash for the first chunk.

```javascript
const response = await fetch(
  "https://api.apify.com/v2/acts/solidscrape~docs-to-rag-dataset/run-sync-get-dataset-items?maxTotalChargeUsd=0.02",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer " + process.env.APIFY_TOKEN,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      urls: ["https://docs.python.org/3/faq/general.html"],
      maxChunks: 30,
      maxSpendUsd: 0.02
    })
  }
);
if (!response.ok) throw Error("Apify HTTP " + response.status);
const chunks = await response.json();
if (chunks.length) console.log(chunks[0].citationUrl, chunks[0].contentHash);
```

For both the dataset and the evaluation cases, start a run with POST `/v2/acts/solidscrape~docs-to-rag-dataset/runs`, poll GET `/v2/actor-runs/{runId}` until completion, then read `/v2/datasets/{defaultDatasetId}/items` and `/v2/key-value-stores/{defaultKeyValueStoreId}/records/EVAL_CASES`. Send the same authorization header with each request.

If your coding assistant has Apify MCP configured, ask it to read the input schema for `solidscrape/docs-to-rag-dataset`, run the Actor with the example above and a $0.02 maximum, then use MANIFEST to confirm coverage before indexing. For vector stores, embed the `text` field. Keep `citationUrl`, `sourceUrl`, `headingPath`, `kind` and `contentHash` as metadata. Treat retrieved text as source material in your application.

#### Outputs

| Output | What it contains |
|---|---|
| Default dataset | One unique prose or code chunk per row, including exact text, SHA-256 content hash, source URL, observed heading anchor, timestamp, title and license evidence. |
| MANIFEST | Outcome and emitted IDs for each attempted page, references to duplicate chunks, whether the page was fully processed, request and fee counts and stop reason. |
| EVAL_CASES | A question heading ending in `?`, its citation URL and IDs of emitted prose chunks beneath that heading. These are weak relevance labels. Review them before using them as a benchmark. |
| MARKDOWN | Clean Markdown pages, original URLs, timestamps, refresh states and chunk-completeness flags. |
| SNAPSHOT | Validated page hashes and chunk references for the next refresh. Failed, skipped and incomplete pages preserve their earlier state. |

A page's heading path is preserved as an array. Anchor links come from IDs in the HTML. When an anchor is unavailable the citation links to the page. Code blocks retain indentation, and oversized blocks split into bounded fragments. Character counts use JavaScript UTF-16 units. A chunk ID is deterministic for an identical document structure and chunking configuration. Use its content hash to detect text edits. The run deduplicates exact text within each content type across pages. New fields `pageChange` and `pageContentHash` report the page refresh result. A duplicate page can reference a chunk emitted for another page in MANIFEST; preserve those shared references when updating your index. Only a complete page scan permits reconciling that page's prior chunk IDs, and missing URLs never authorize deleting entire pages.

#### Pricing

| Event | Price | When it applies |
|---|---:|---|
| Start | $0.002 | One 512 MB run |
| Source request | $0.0015 | Every bounded robots.txt, sitemap XML or HTML fetch attempt, including a failure or an empty response |
| Page indexed | $0.0005 | A page producing at least one unique output chunk |

All chunks, code fragments, derived FAQ cases and the coverage manifest are included. Ten productive pages from one origin cost $0.0235 ($0.002 + 11 × $0.0015 + 10 × $0.0005). Ten different origins need ten separate robots checks. The smaller of your input budget and the Apify run maximum applies. The collector checks that the remaining budget can cover a useful page before it fetches it. If all selected sources fail, consult MANIFEST for the reasons and the charges incurred.

#### Scope and source rights

Supply up to 40 final public HTTPS URLs and/or up to three sitemap URLs. A run reads at most 40 content pages and five XML sitemap documents, with at most 500 locations per XML file. Sitemap indexes are supported; document cycles are deduplicated, DTDs and custom entities are rejected, and oversized or compressed `.xml.gz` files are unsupported. Each source request has an eight-second deadline and a 750 KB compressed and decoded limit. HTML is fetched directly without a browser, retries, redirects, proxy or authentication. JavaScript-only, PDF, private, query-string and cross-site crawling are outside this interface. There is no recursive link crawl. The run processes at most 500 output chunks at 512 MB memory. It checks robots.txt once per origin for pages and sitemaps, recognizes a missing policy on 404/410, and skips sites with an unavailable policy or crawl delays above three seconds. It honors page indexing and AI opt-outs and skips sites advertising AI reuse restrictions in their robots content signals.

A page's rel=license link is evidence supplied by the source. Verify your permission for indexing, redistribution or model training. Use expectedLicenseUrl to require one exact published link, or omit the filter for your own authorized documents. The presence or absence of a robots rule or license tag cannot determine the complete rights for an entire page.

#### FAQ

**How do I export JSONL for ingestion?** Open the default dataset export dialog or request its items with `format=jsonl`. Keep code and prose together or filter by `kind` in your ingestion process.

**How is the evaluation set generated?** The API uses literal question headings and references their emitted prose chunks. It does not fabricate questions or answer labels. Use distinct pages or domains for training and evaluation to reduce leakage.

**Can I use this for a nightly refresh?** Have your client pass the previous SNAPSHOT with `changesOnly: true`. Update the stored snapshot after the Actor completes and returns valid artifacts. Check MANIFEST and preserve prior corpus text for incomplete or skipped pages. Use a separate snapshot for each site/path and chunking configuration.

# Actor input Schema

## `urls` (type: `array`):

Up to 40 final public HTTPS HTML pages. Use these and/or sitemap URLs. Queries and redirects are refused. Existing URL-only inputs work unchanged.

## `sitemapUrls` (type: `array`):

Optional 1–3 public HTTPS sitemap XML URLs. Same-origin child sitemaps and pages only. Each robots, sitemap and page attempt costs $0.0015. Maximum 500 locations per XML file.

## `includePathPrefixes` (type: `array`):

Only fetch page paths starting with these literal prefixes, such as /docs/ or /faq.html. Empty includes every discovered path. Applied before page requests; sitemap discovery requests still cost.

## `excludePathPrefixes` (type: `array`):

Never fetch content pages whose path starts with a listed prefix, such as /blog/ or /private/. Overrides include filters. No regex or wildcards.

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

Maximum eligible content pages after path filters, with supplied URLs first. Omitted pages are explicit in MANIFEST; no inferred deletions.

## `maxSitemaps` (type: `integer`):

Cap across root and child XML sitemaps. Sitemap index cycles are deduplicated.

## `previousSnapshot` (type: `object`):

Optional SNAPSHOT JSON from a previous run, using the same chunkChars. Up to 200 page records and 150 KB. Old page hashes/IDs are preserved when a page is skipped, incomplete or missing from discovery. Store data retention applies.

## `changesOnly` (type: `boolean`):

With a previousSnapshot, suppress unchanged chunks and Markdown. Unchanged checks still incur source-request fees, but no indexed-page fee. The first run returns a baseline.

## `chunkChars` (type: `integer`):

Split at section and block boundaries, with long blocks split to this many UTF-16 units.

## `maxChunks` (type: `integer`):

Maximum unique chunks across the run. MANIFEST marks a truncated page.

## `maxSeconds` (type: `integer`):

Maximum source work time, shared by pages and robots requests.

## `maxSpendUsd` (type: `number`):

Stop before the next charge would exceed this budget. Apify's run-level maximum also applies.

## `expectedLicenseUrl` (type: `string`):

Optional exact HTTPS rel=license match. Unmatched pages skip indexing. Source attempts still incur a fee.

## Actor input object example

```json
{
  "urls": [
    "https://docs.python.org/3/faq/general.html"
  ],
  "maxPages": 40,
  "maxSitemaps": 3,
  "changesOnly": false,
  "chunkChars": 1800,
  "maxChunks": 80,
  "maxSeconds": 60,
  "maxSpendUsd": 0.1
}
```

# Actor output Schema

## `chunks` (type: `string`):

No description

## `manifest` (type: `string`):

No description

## `evals` (type: `string`):

No description

## `markdown` (type: `string`):

No description

## `snapshot` (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 = {
    "urls": [
        "https://docs.python.org/3/faq/general.html"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("solidscrape/docs-to-rag-dataset").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 = { "urls": ["https://docs.python.org/3/faq/general.html"] }

# Run the Actor and wait for it to finish
run = client.actor("solidscrape/docs-to-rag-dataset").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 '{
  "urls": [
    "https://docs.python.org/3/faq/general.html"
  ]
}' |
apify call solidscrape/docs-to-rag-dataset --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,solidscrape/docs-to-rag-dataset"
        }
    }
}
```

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/XdPBsYMvc21qzb0Em/builds/DH2ntnu4VyGjfnAmT/openapi.json
