← WebExtract

WebExtract API docs

Base URL: https://api.webextract.dev (same app at https://webextract.dev). Machine-readable: /openapi.json · /llms.txt · /.well-known/x402.

Try it free (no signup)

curl -H "X-Billing: free" "https://api.webextract.dev/v1/markdown?url=https://example.com"

20 free calls/day per IP. On REST the X-Billing: free header (or ?free=1) is required; without it the endpoint answers HTTP 402 with payment options. MCP clients need no header: POST https://api.webextract.dev/mcp.

Framework guides: Vercel AI SDK (@webextract/ai-sdk) · LangChain (langchain-webextract for Python, @webextract/langchain for JS).

Endpoints

EndpointReturnsPrepaidx402
GET /v1/extract?url=<page>Markdown + metadata, product, tables1 credit$0.005
GET /v1/markdown?url=<page>Markdown, title, word count0.4 credit$0.002
GET /v1/render/extract?url=<page>Same as /v1/extract, after rendering the page in a headless browser (JS rendering)1.6 credits$0.008
GET /v1/render/markdown?url=<page>Same as /v1/markdown, after rendering the page in a headless browser0.8 credit$0.004
GET /v1/balanceCredits left on your key (send Authorization: Bearer <api_key>; returns credits_remaining, credits_purchased, credits_used), or free calls left today for your IP without a keyfree—

Prices and provenance

product.price_detail is the recommended price field. Each entry in prices[] has type (list, sale, current), amount, currency, and the matched variant when the page proves it. It never contains 0. When no price can be trusted, status is unresolved and unresolved.reason says why (for example no_offer_in_structured_data, variant_not_matched, zero_price). When the URL selects a variant (?variant=, ?sku=, ?size=…), the flat product.price is that variant's price. If the variant cannot be matched on a page whose variants have different prices, product.price is null instead of another variant's price. Listing and category pages return product: null with product_unresolved.reason: "listing_page". content_source is raw_html on /v1/extract and /v1/markdown (no JavaScript is executed) and rendered on /v1/render/*; product.source is the extraction method (json-ld, opengraph, microdata, heuristic).

Both data endpoints also accept POST with a JSON body {"url": "https://..."} (or a form body).

curl -H "X-Billing: free" "https://api.webextract.dev/v1/extract?url=https://example.com"
curl -X POST https://api.webextract.dev/v1/markdown -H "X-Billing: free" -H "Content-Type: application/json" -d '{"url":"https://example.com"}'

Tables

tables[].headers and tables[].rows follow the same grid as the Markdown table: cells that span rows or columns (rowspan, colspan) are expanded, so every cell stays in its own column. A value that spans several rows is repeated in each row it covers (values up to 200 characters; longer ones leave ""), and the extra columns of a colspan are "". Rows that are shorter in the page itself are not padded, so checks.consistent_width still reports them.

Pages with no readable text

If the raw HTML of a page yields no readable text (markdown is empty, word_count 0; on /v1/extract and the MCP tool extract_url also product: null and no tables), /v1/extract and /v1/markdown still answer HTTP 200 and add warnings: ["empty_content"] and a hint. The hint says the page may build its content with JavaScript and suggests trying a URL that shows the content directly in the page source. A page with even one word of text is not empty.

{"url":"...","final_url":"...","fetched_at":"...","content_source":"raw_html","title":null,"markdown":"","markdown_truncated":false,"word_count":0,
 "warnings":["empty_content"],
 "hint":"No readable text was found in the raw HTML of this page (word_count 0; content_source raw_html, no JavaScript executed). The page may build its content with JavaScript: try a URL that shows the content directly in the page source. This call was not charged and did not use a free call.",
 "charged":false}

JS rendering

For pages that only show their content after JavaScript runs. /v1/render/extract and /v1/render/markdown load the page in a headless browser (robots.txt respected), then return the same fields as /v1/extract / /v1/markdown with content_source: "rendered", plus a render object (render_ms, wait, subrequests, redirects, …) and an X-Render-Ms header. POST with {"url": "https://..."} works too.

curl -H "X-Billing: free" "https://api.webextract.dev/v1/render/markdown?url=https://example.com"

Auth and billing

NetworkCAIP-2USDC
Baseeip155:84530x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Polygoneip155:1370x3c499c542cEF5E3811e1192ce70d8cC03d5c3359
Arbitrum Oneeip155:421610xaf88d065e77c8cC2239327C5EDb3A432268e5831
World Chaineip155:4800x79A02482A880bCE3F13e09Da970dC34db4CD24d1
Monadeip155:1430x754704Bc059F8C67012fEd69BC8A327a5aafb603
Avalanche C-Chaineip155:431140xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
OP Mainneteip155:100x0b2C639c533813f4Aa9D7837CAf62653d097Ff85

X-Billing header: free opts into the free tier. x402 returns the 402 with payment requirements (reason x402_requested). x402-testnet uses the sandbox (below). Any other value returns 400 invalid_billing_mode.

Order of checks: 1) url validation (400, never billed) → 2) Authorization: Bearer key (credits; wins over everything below) → 3) payment header PAYMENT-SIGNATURE (wins over X-Billing: free) → 4) X-Billing: x402 → 402 x402_requested → 5) X-Billing: free or ?free=1 → free quota, or 402 free_limit_reached with X-Free-Remaining: 0 → 6) otherwise 402 x402_required.

Note on ?free=1: it is read from the API's own query string. If your target URL has its own query string, URL-encode it (curl -G --data-urlencode "url=https://a.com/?x=1" -d free=1 ...) or simply use the header.

SDK note: official x402 SDKs (@x402/evm 2.28, Python x402 2.25) do not include OP Mainnet and World Chain USDC in their default asset lists; add them to spendControls.allowedAssets, and register only the network(s) where your wallet holds USDC (or pass a requirements selector), otherwise the SDK picks the first option (Base).

HTTP 402 Payment Required

The x402 v2 requirements are in the PAYMENT-REQUIRED response header (base64 JSON). Sign one option and retry with PAYMENT-SIGNATURE. The JSON body says why payment is needed; the same value is in the X-Payment-Reason header:

reasonMeaning
x402_requiredNo key, no payment and no free opt-in. Pay with x402, send a Bearer key, or retry with X-Billing: free while your IP has free calls left.
x402_requestedYou sent X-Billing: x402 (or used the sandbox) and no payment yet.
free_limit_reachedYou opted into the free tier but your IP's free daily calls are used up (X-Free-Remaining: 0). Retrying with X-Billing: free will not help today; see two ways to keep going.
invalid_paymentA payment was sent but rejected; detail has a short reason code (e.g. insufficient funds, expired, bad signature) or a decode error. On REST, nothing was charged.
unsupported_networkThe payment used a network not offered for this endpoint.
settlement_failedThe payment was verified but on-chain settlement did not complete. On REST, nothing was charged (charged: false, retryable: true). Retry the request with a freshly signed payment.
{"error":"payment_required","reason":"x402_required","message":"Payment required. ... or try it free: add header 'X-Billing: free' ...",
 "x402":{"price":"$0.005","network":"eip155:8453","networks":["eip155:8453","eip155:137",...],"asset":"USDC"},
 "stripe":{"buy_url":"https://webextract.dev/#pricing","packs":[...]}}

With a prepaid key and no credits left you get 402 {"error":"no_credits"}. Add credits to that key at /#pricing (Option A, “Already have a key?”).

Free calls used up? Two ways to keep going

REST answers 402 free_limit_reached (the next steps are also in the body's next_steps and in the X-Next-Step-Credits / X-Next-Step-X402 headers); MCP tools/call answers “Free daily limit reached” (isError). The free tier resets at 00:00 UTC. To keep going now:

  1. Prepaid credits by card (from $1 = 200 credits, no subscription, credits never expire): buy $1 = 200 credits, or pick a pack at /#pricing. Stripe Checkout; your API key is shown once after payment. Then:
    curl -H "Authorization: Bearer <api_key>" "https://api.webextract.dev/v1/extract?url=https://example.com"
    curl -H "Authorization: Bearer <api_key>" "https://api.webextract.dev/v1/balance"
    For MCP, add the header to the server in your client config, e.g. {"url":"https://api.webextract.dev/mcp","headers":{"Authorization":"Bearer <api_key>"}} (x-api-key: <api_key> also works).
  2. No account: pay per call with x402 (USDC, $0.005 per /v1/extract, $0.002 per /v1/markdown; on REST, payment is settled only when the call succeeds). Resend the same request with a PAYMENT-SIGNATURE header signed for one option in the 402's PAYMENT-REQUIRED header; a payment wins over X-Billing: free. From code: the @x402/fetch example below; try it on the sandbox first, then drop /sandbox from the URL and register the network your wallet holds USDC on (Base is eip155:8453). From a browser wallet: /try. x402 payment is for the REST endpoints. Over MCP use the free tier or a prepaid Bearer key; paying over MCP with x402 has not been tested.

Errors

All errors are JSON. On REST, and on the free tier or with a prepaid key over MCP, they are never charged: 400 missing or invalid url (checked before any billing) or unknown X-Billing value · 401 invalid API key · 402 payment required / out of credits · 413 page over 3 MB (use a smaller page) · 415 not a web page (only HTML, XML and plain text are read; PDFs, images, archives and other file downloads are not supported, so use the HTML page that links to the file) · 422 target site blocked or errored, or the page took too long (extract_timeout, over 10 s including any wait) or was too large or complex to parse (page_too_complex) · 451 robots.txt disallows the URL · 503 extract_busy (the extractor is busy, or another extraction from your address is still running; on REST, retry after the Retry-After header; over MCP the retry advice is in the error text).

Sandbox (free test money only)

Test an x402 client end to end without real money. Same endpoints and responses:

https://api.webextract.dev/sandbox/v1/extract?url=...
https://api.webextract.dev/sandbox/v1/markdown?url=...
# or on the normal endpoints:
curl -H "X-Billing: x402-testnet" "https://api.webextract.dev/v1/markdown?url=https://example.com"

Pay from code with the official @x402/fetch client (tested with 2.28.0), testnet only:

// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.TESTNET_PRIVATE_KEY); // throwaway test wallet
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:84532", client: new ExactEvmScheme(account) }],
});
const res = await pay("https://api.webextract.dev/sandbox/v1/markdown?url=https://example.com");
console.log(res.status, (await res.json()).markdown);

MCP

Remote streamable-http server: https://api.webextract.dev/mcp (stateless JSON). Tools extract_url and page_markdown, both with outputSchema and structuredContent. Registry name dev.webextract/extract. Server card: /.well-known/mcp/server-card.json. MCP calls use the free tier (20/day per IP, no header needed) or a Bearer key; for pay-per-call use the REST endpoints with x402.

MCP errors. A failed tool call has isError: true. content[0] is one line of text that starts with the error code (missing_url, invalid_arguments, invalid_url, forbidden_host, robots_disallowed, unsupported_type, upstream_error, …) and, on the free tier or with a prepaid key, ends with "(not charged)". content[1] is JSON with error, category, charged and, for the errors above, a reason that says what to do next, a retryable flag and (for argument and url errors) an example call. retryable tells you whether sending the identical call again could succeed: false means fix the arguments or the URL, or pick another page, first; true (only for a temporary HTTP 5xx from the target site) means the same call may work a minute or two later. Errors without a retryable field give no such promise.

Crawling policy

We identify as WebExtractBot, obey robots.txt, never bypass CAPTCHAs or anti-bot protection, and refuse private network addresses.