- readfetch
- docs
API reference
Integrate with x402
POST JSON to https://readfetch.com/v1/…. Paid routes return 402 until an official client or the MCP signing proxy completes x402. Start with free POST /v1/probe. Overview: homepage · clients: /integrations · questions: /faq.
How it works
- Call unpaid → 402 with quote
accepts[0] - Client or MCP proxy signs and retries
PAYMENT-SIGNATURE - Handler runs → settle if billable
PAYMENT-RESPONSE · RECEIPT
Base URL
One host, one content type, no auth header.
Every call is POST https://readfetch.com/v1/… with content-type: application/json. Discovery GETs (/openapi.json, /llms.txt, /SKILL.md) cost nothing.
Free probe
No wallet, no 402.
POST https://readfetch.com/v1/probe with {"url":"…"} — no wallet, no 402. Returns status, type, size, title, language, challenge, and optional preview (~400 chars). Rate limit: 30/min per IP. MCP: readfetch_probe.
# pip install readfetch-client
from readfetch import Client
print(Client().probe("https://example.com"))
Payment
x402: the payment is the credential.
Call the endpoint without payment. It answers 402 with the quote, both in the body and in a base64 PAYMENT-REQUIRED header. The live quote on that response is authoritative — static accepts[] in x402-resources.json are catalogue templates (snake_case aliases such as pay_to and amount_usd are display-only).
Required path: funded Base USDC wallet plus readfetch-client, @readfetch/client, or @readfetch/mcp-x402-proxy — see /integrations#clients. Those packages perform the 402 → sign → retry loop; bare curl or MCP tools/call without them stops at 402.
Successful paid responses carry PAYMENT-RESPONSE and RECEIPT when billed: true. Payment nonces are single-use.
{
"error": "payment required",
"price_usd": "…",
"pay_to": "0x26C2308aDC8fe5FFE6d4183588DD2DD22ed86071",
"network": "…",
"asset": "USDC",
"hint": "…",
"resource": {
"url": "…",
"description": "…",
"mimeType": "application/json",
"serviceName": "readfetch.com",
"tags": ["…"],
"iconUrl": "…"
},
"accepts": [
{
"scheme": "exact",
"network": "…",
"amount": "…",
"asset": "0x…",
"payTo": "0x26C2308aDC8fe5FFE6d4183588DD2DD22ed86071",
"resource": "https://readfetch.com/v1/text",
"mimeType": "application/json"
}
]
}
Gate mode: payment.status in /.well-known/service.json. MCP hosts that cannot attach payment headers: @readfetch/mcp-x402-proxy.
x402 settlement is live on eip155:8453: sign a USDC transfer and retry with PAYMENT-SIGNATURE.
Errors
Every failure is a body you can branch on.
| Status | Body | What to do |
|---|---|---|
| 402 | { "error": "…", "accepts": [ … ] } | Sign accepts[0] and resend with PAYMENT-SIGNATURE. |
| 413 | "response exceeds N bytes" | Lower max_bytes, or read a section instead of the page. |
| 422 | "error", "hint" | Validation refused the request — a private address, a missing field. Nothing ran. |
| 429 | "error" + Retry-After | Wait the advertised time, then retry the same call. Nothing settled. |
| 502 | "upstream fetch failed" | Retry once; if it repeats, /v1/probe to see what the origin answers. |
| 504 | "upstream request timed out" | The budget ran out. Give a longer timeout_s or ask for less. |
| 200 | billed: false + hint | Not charged. The hint names the next call to try. |
On reading routes, a wall, an empty extraction or an unsupported type is a 200 with billed: false, not an error: the origin answered, so the answer is a description of what came back.
On /v1/fetch, the API returns HTTP 200 with the origin status_code in the JSON; billed: true is normal for origin 4xx/5xx when the transport succeeded.
Billing
Settled after the work — delivery-gated on reading routes; transport-gated on /v1/fetch; /v1/crawl is the exception, settling its max_pages quote at accept.
Reading routes: settle only when delivered (billed: true). /v1/fetch: bills when the origin responds (including 4xx/5xx). /v1/crawl: quoted from max_pages and settled at accept, so billed on a job is informational. Responses include content_sha256 and provenance. Edge cases: /faq.
Feedback
Integrator signal — not billing.
Stuck on a 402, MCP, or doc? POST /v1/feedback with X-Request-Id. Categories: integration, docs, site, other. Delivery disputes → Claims.
{
"request_id": "<X-Request-Id from the prior response>",
"category": "integration",
"message": "402 quote confused my client"
}
Use readfetch-client / @readfetch/client submit_feedback / submitFeedback, or MCP readfetch_feedback.
Claims
A credit, not a refund — the rail cannot refund.
EIP-191 signature over sha256(receipt || rid). Auto-approve: truncated only. Manual review: wrong_content. empty is rejected (422) — probe before paying or follow the response hint. Credit via X-CREDIT on retry; cap five per address per day ($0.05 each).
{
"receipt": "<RECEIPT header value>",
"reason": "truncated",
"address": "0xpayer",
"signature": "0x…",
"note": "optional, 500 characters"
}
Only truncated is auto-approved from the delivery record. Rejections include empty (422), 404, 409, and 429 — receipt stays valid for a different reason where applicable.
Limits
What is enforced, not what is hoped.
- Request body: 1 MiB of JSON.
- Redirects: 5, each hop re-validated as a public address; loopback, private, link-local and metadata addresses are refused.
- Time: every
timeout_sis a whole-call budget that starts at the first DNS lookup. DNS, connect, redirects, every sitemap fetch, every retry and every render share that clock; no step starts a fresh timer. The default and maximum for an endpoint are printed on its page. - Delivery-gated routes: nothing undelivered is billed; a budget that expires mid-walk returns
status: "partial". /v1/fetch: bills when the origin answers; a timeout or transport failure before that is unbilled.
Machine-readable
Everything above, in a form an agent can parse.
Endpoints
Generated from the catalog. Each row links to its page.
| Endpoint | Price | Returns |
|---|---|---|
POST /v1/text | $0.002 | Article text and metadata, boilerplate stripped. No browser by default; falls back to one when a page blocks plain HTTP. |
POST /v1/map | $0.002 | Sitemaps, robots rules, feeds and link counts for a whole site, in one call. Plan a crawl before paying for it. |
POST /v1/scrape | $0.005 | Chromium renders the page, runs interactions, and returns Markdown, text or HTML with its links. |
POST /v1/scrape/residential | $0.02 | Scrape through a residential address pool, for targets that refuse a datacentre address. Same contract as /v1/scrape, one attempt, priced for the bandwidth. |
POST /v1/fetch | $0.0015 | Raw HTTP through the same egress. JSON APIs, GraphQL, PDFs, byte ranges - anything that is not a page. |
POST /v1/batch | $0.0015/page | Read up to 50 HTML pages in one payment (same /v1/text extraction per URL). Results in input order; undelivered pages are credited, not billed. |
POST /v1/pdf | $0.005/document | Documents, not pages: page text plus one Markdown body, priced per document rather than per page. |
POST /v1/section | $0.003 | Read one heading or one selector instead of the whole page - ten to a hundred times fewer tokens. |
POST /v1/diff | $0.003 | Stateless change detection. Send the hash you hold, get back whether it changed and a bounded diff. |
POST /v1/screenshot | $0.003 | PNG or JPEG of a rendered page: viewport, full page, or one element via CSS selector. |
POST /v1/search | $0.005 | Web search without a search subscription, returning titles, URLs and snippets. |
POST /v1/crawl | $0.003/page | Bounded async crawl with a job id, a page cap quoted up front, and per-page Markdown. |
GET /v1/crawl/{id} | $0 | Poll a crawl job: status, completed page count, and per-page Markdown as they land. |
POST /v1/probe | free | FREE · metadata before spending, plus the full extracted text on the first 3 probes per IP per day (a ~400-character preview after that). |
Flat prices run $0.0015–$0.02 per call; /v1/batch is priced per delivered page and /v1/crawl quotes max_pages at accept — both quoted before the work starts.