Перейти к навигации

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

Просмотр в формате Markdown

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.
  • 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 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:

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:

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):

StepEndpointExample volumeCost
Discover doc pathsPOST /v1/web/map1 call, 20 returned URLs × $0.001$0.0200
Batch-read as MarkdownPOST /v1/web/read2 calls, 18 readable URLs × $0.002 (2 failed free)$0.0360
Total3 calls18 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.