1. readfetch
  2. choose
  3. /v1/diff

Data · Documents and structure

POST/v1/diff

Stateless change detection. Send the hash you hold, get back whether it changed and a bounded diff.

  • $0.003
  • sha256
  • no storage

What it does

Stateless change detection on readable page text (same HTTP-first extraction as readfetch_text): fetch the URL, compare to a hash or prior body you store client-side, return changed/unchanged plus optional line diff. First call with no prior fields returns a baseline hash (see hint). `previous_hash` alone detects change without a line diff; add `previous_content` when you need added/removed/diff. A no-change answer is still billable when text was delivered. Prefer readfetch_text when you need the full article once; readfetch_probe (free) for a short preview and `content_sha256` before spending on text.

Price

Quoted by the 402 before anything runs.

  • $0.003per call
  • 30 s default, 60 s maximumwhole-call budget
  • billedonly when content is delivered
  • no keythe payment is the credential

When to call it

Cheapest endpoint that answers the question, first.

Call it when the sentence above is the whole job. Its neighbours solve the same URL with a different trade-off — a browser instead of plain HTTP, a site instead of one page, one section instead of a document. /choose walks the decision, cheapest first, browser last.

Unsure whether another URL is worth paying for at all? /v1/probe is free: metadata plus the full extracted text on the first 3 probes per IP per day (a ~400-character preview after that) before you pay for a priced route.

Request fields

JSON body shape for POST /v1/diff — use with the client snippets below, not as a bare POST.

FieldTypeDefaultWhat it does
url requiredstring—Public http(s) page to re-fetch and compare; must match the extraction used when you saved the hash (same format).
previous_hashstring—sha256:… or bare hex from readfetch_diff, readfetch_probe content_sha256, or a prior text read. Omit on the first poll to establish a baseline hash in the response.
previous_contentstring—Full prior extracted text (what you stored from readfetch_text/readfetch_diff). Required for added/removed/diff output; hash-only compares do not emit a line diff.
formatstringtextExtraction flavour for this fetch and for the hash (default text). Must match how you built previous_content if you send it.
timeout_snumber30Total budget for the whole call in seconds, both fetches included. 60 s is the ceiling on this route.

Make the call

Unpaid REST stops at 402. Use readfetch-client, @readfetch/client, or MCP @readfetch/mcp-x402-proxy — they sign x402 and retry. The JSON below is the argument shape for call() / route helpers.

example body
{
  "url": "https://example.com"
}

readfetch-client / @readfetch/client (latest+) handle x402 on paid routes — full API on /integrations#clients.

python
# pip install readfetch-client
# export EVM_PRIVATE_KEY=0x…
import asyncio
from readfetch_client import readfetch_diff

async def main():
    data = await readfetch_diff("https://example.com")

asyncio.run(main())
javascript
// npm install @readfetch/client
// export EVM_PRIVATE_KEY=0x…
import { readfetchDiff } from "@readfetch/client";

const data = await readfetchDiff("https://example.com");

Response

Fields shown are the ones a caller branches on.

200 ok
{
  "added": [
    "New line"
  ],
  "billed": true,
  "changed": true,
  "diff": "@@ -1 +1 @@\n-Old line\n+New line",
  "hash": "sha256:...",
  "hint": null,
  "removed": [
    "Old line"
  ],
  "status": "changed",
  "status_code": 200,
  "url": "https://example.com/pricing"
}

Limits

Requests are JSON, 1 MiB maximum. Redirects are re-validated at every hop and capped at 5; the final URL is reported. Every call runs on one whole-call budget — DNS, connect, redirects, retries and any render share that clock, and no step starts a fresh timer. Where the endpoint publishes a timeout_s, its default and ceiling are the whole-call budget in the strip above. A budget that expires mid-walk returns status: "partial", and nothing is charged for what was not delivered.

Failures come back as {"error": "…", "hint": "…"} with a status to branch on. Shapes: /docs#errors.

Billing

$0.003 per delivered call. A response with billed: false settles nothing and names the next call to try.

billed: false on 200 usually means no content hash (nothing to compare). 502/504 settle nothing.

RECEIPT, claims, and billing rules: /docs#billing.

Settlement, receipts and claims: /docs.