Diff
Track changes between two snapshots of a web page. Scrape a URL now, compare it against a previous extraction result, and get a unified diff of what changed.
POST
/v1/diffCompare a URL's current content against a previous extraction snapshot.
Request body
json
{
"url": "https://example.com/pricing",
"previous": {
"metadata": {
"url": "https://example.com/pricing",
"title": "Pricing",
"word_count": 5
},
"content": {
"markdown": "# Pricing\n\nStarter: $9/mo\nPro: $29/mo",
"plain_text": "Pricing Starter: $9/mo Pro: $29/mo",
"links": [],
"images": [],
"code_blocks": []
},
"domain_data": null
}
}| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to scrape for the current version. |
previous | object | No* | A previous ExtractionResult (the extraction field from a prior /v1/scrape call). |
Tip
Request
formats: ["json"] and save the extraction object from /v1/scrape as your baseline snapshot. Pass it as the previous field in subsequent diff requests. If omitted, the hosted API attempts to use your cached baseline; it returns 400 when no usable baseline exists.Response
json
{
"status": "Changed",
"text_diff": "--- previous\n+++ current\n@@ -2,3 +2,3 @@\n-Starter: $9/mo\n-Pro: $29/mo\n+Starter: $12/mo\n+Pro: $39/mo\n+Enterprise: $99/mo",
"metadata_changes": [
{
"field": "title",
"old": "Old title",
"new": "Pricing"
}
],
"links_added": [
{ "text": "Enterprise", "href": "https://example.com/enterprise" }
],
"links_removed": [],
"word_count_delta": 70
}| Field | Type | Description |
|---|---|---|
status | string | "Changed" or "Same". |
text_diff | string | null | Unified diff of the text content, or null when unchanged. |
metadata_changes | array | List of metadata fields that changed, with old and new values. |
links_added | object[] | Link objects with text and href, added since the baseline. |
links_removed | object[] | Link objects with text and href, removed since the baseline. |
word_count_delta | number | Difference in word count (positive = content added). |
Example
curl (requires a cached baseline)
curl -X POST https://api.webclaw.io/v1/diff \
-H "Authorization: Bearer wc_your_api_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/pricing"}'