> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Map a documentation site and extract clean Markdown pages for RAG or coding agents

> Discover targeted URLs inside one site with POST /v1/web/map (select_paths/exclude_paths), batch-read 1–10 URLs via POST /v1/web/read, handle failed and truncated pages, and save clean Markdown files.

When you want to feed an external API doc site or changelog into Claude Code, Cursor, or a RAG index without writing a brittle HTML scraper, discover only the relevant paths with `POST /v1/web/map`, then batch-read those URLs in groups of up to 10 with `POST /v1/web/read` to save clean Markdown.

## Prerequisites and cost scope

* **Pricing:** `POST /v1/web/map` costs `$0.001` per returned URL (max `100` URLs per call; empty results cost `$0`). `POST /v1/web/read` costs `$0.002` per successfully read URL (`failed` URLs cost `$0`). Mapping and reading 20 docs pages costs about `$0.06` total. See [BeatAPI pricing](https://beatapi.io/pricing).
* **Public URLs only:** Both endpoints reject `localhost`, private IPs, and embedded credentials with `400 bad_request`.

## 1. Map only the documentation paths you need

With [BeatAPI MCP](https://beatapi.io/integrations) connected, hand the task straight to your agent:

> Use `web_map` on `https://spec.openapis.org` with `select_paths: ["/oas/.*"]`, `max_depth: 2`, and `limit: 20`. Review the returned URLs, then call `web_read` in batches of up to 10 (`format: "markdown"`, `max_chars: 20000`) and save each page as a local `.md` file with its source URL. List any `failed` or `truncated: true` pages separately.

To run step 1 over HTTP:

```bash
curl -sS https://api.beatapi.io/v1/web/map \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: web-map-oas-2026-11-23" \
  -d '{"url":"https://spec.openapis.org","select_paths":["/oas/.*"],"exclude_paths":["/blog/.*"],"max_depth":2,"limit":20}' \
  -o mapped-urls.json
```

If `urls` comes back empty, check the returned `note`—the page may build its links purely in client-side JavaScript or link only externally.

## 2. Batch-read selected URLs as Markdown

Split your shortlisted URLs into batches of **1–10 URLs** and send each batch to `POST https://api.beatapi.io/v1/web/read`. Add `query` (up to 400 characters) when you only need passages about a specific topic, or omit `query` to keep the full page:

```bash
curl -sS https://api.beatapi.io/v1/web/read \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"urls":["https://spec.openapis.org/oas/v3.1.0","https://spec.openapis.org/oas/v3.0.3"],"format":"markdown","max_chars":20000}' \
  -o read-batch-1.json
```

## 3. Handle `failed[]` and `truncated: true` cleanly

* **`failed[]` does not break the batch:** Readable pages still return in `results[]`. Log each failed URL with its `reason` (`blocked` or `unreachable`); you are not charged for failed URLs.
* **Check `truncated: true`:** If a long specification is cut off at `20,000` characters, rerun `POST /v1/web/read` for that single URL with a higher `max_chars` (up to `100,000`) or pass a targeted `query`.

## 4. Save the local Markdown pack

Example cost breakdown for mapping and reading 20 documentation pages (assuming 18 succeed and 2 are blocked):

| Step                   | Endpoint            | Example volume                                         | Cost          |
| ---------------------- | ------------------- | ------------------------------------------------------ | ------------- |
| Discover doc paths     | `POST /v1/web/map`  | 1 call, 20 returned URLs × `$0.001`                    | `$0.0200`     |
| Batch-read as Markdown | `POST /v1/web/read` | 2 calls, 18 readable URLs × `$0.002` (2 `failed` free) | `$0.0360`     |
| **Total**              | **3 calls**         | **18 Markdown files**                                  | **`$0.0560`** |

Write one `.md` file per entry in `results[]` with frontmatter recording `source_url`, `title`, `truncated`, and `request_id`. Keep a `manifest.json` of any `failed` URLs so your RAG pipeline or coding agent knows exactly what was indexed and what was skipped.

## Related

* [BeatAPI Web Search API](https://beatapi.io/web-search-api)
* [Web Search API reference](/web-search)
* [Map coverage FAQ](/faq/web-map-coverage)
* [Partial page content FAQ](/faq/web-partial-read)
* [Truncated text FAQ](/faq/web-truncated-text)