Skip to main content
Use the Web API when you have one URL and need its readable content. The Markdown endpoint returns content ready for search, RAG, or an LLM; the HTML endpoint returns the rendered document.
Need more than one page? Crawl a website. Need JSON fields rather than page content? Extract structured data.

Prerequisites

Create an API key in the dashboard and keep it in a server-side environment variable:
Install an SDK from the Quickstart, or use the HTTPS example below without an SDK.

Get Markdown

Pass a complete http:// or https:// URL. useMainContentOnly removes detected navigation, sidebars, and footers so the result focuses on the page body.
A successful scrape costs 1 credit, or 2 credits with browser actions. PDF OCR adds 1 credit per page recovered. A successful response includes the requested URL, Markdown, page metadata, and cache metadata:
Treat the API reference as the authority for the complete response schema.

Get rendered HTML

Use GET /web/scrape/html when downstream code needs DOM markup rather than Markdown.
You can also set includeHTML=true on a Markdown request when you need both representations from the same scrape.

Content controls

If an include selector matches nothing, the request can still succeed with an empty result. Check contentLength before indexing or summarizing the page.

Handle dynamic or protected pages

Use the least expensive control that produces the page state you need:
  1. Set waitForMs when content appears shortly after load.
  2. Set settleAnimations=true when transitions make captures inconsistent.
  3. Use browser actions when the page requires a click, scroll, or ordered interaction.
  4. Set country when the page varies by country or is unavailable from the default route.
Context.dev can retry blocked requests through different proxy routes. This improves access, but it does not guarantee access to every site. A challenge page, CAPTCHA, or login shell can return WEBSITE_BLOCKED; unsuccessful requests are not billed.

Control freshness and retention

The default maxAgeMs is 86400000 (one day). A matching cached result younger than that value can be returned. Forwarding custom headers also bypasses cache reads and writes. Keep secrets out of forwarded headers unless the target site requires them.

Plan for failures

See Troubleshooting for stable error codes and retry guidance.

Next steps

Build live web tools for an agent to turn selected pages into bounded, citable evidence with explicit read failures.

Discover website URLs

Find candidate URLs in public sitemaps.

Crawl a website

Follow links and collect content from multiple pages.

Extract page images

Get image sources, dimensions, and optional classification.

Extract structured data

Return fields shaped by your JSON Schema.

Scrape websites in batches

Process large or asynchronous scraping workloads.

Production best practices

Prepare retries, caching, and error handling for user-facing requests.
With timeoutOpts.behavior: "return-partial", a scrape can return finalDOMState: "still-loading" when the deadline arrives before the requested waits finish. Treat that content as incomplete. See Timeouts and partial results for minimum budgets, billing, and migration guidance.