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": {
"url": "https://example.com/pricing",
"metadata": {
"title": "Pricing",
"word_count": 450
},
"markdown": "# Pricing\n\nStarter: $9/mo\nPro: $29/mo",
"text": "Pricing\n\nStarter: $9/mo\nPro: $29/mo"
}
}| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to scrape for the current version. |
previous | object | Yes | A previous ExtractionResult (the output from a prior /v1/scrape call). |
Tip
Save the full JSON response from
/v1/scrape as your baseline snapshot. Pass it as the previous field in subsequent diff requests to track changes over time.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": "word_count",
"old": 450,
"new": 520
}
],
"links_added": [
"https://example.com/enterprise"
],
"links_removed": [],
"word_count_delta": 70
}| Field | Type | Description |
|---|---|---|
status | string | "Changed" or "Unchanged". |
text_diff | string | Unified diff of the text content. |
metadata_changes | array | List of metadata fields that changed, with old and new values. |
links_added | string[] | URLs present in the current version but not the previous. |
links_removed | string[] | URLs present in the previous version but removed. |
word_count_delta | number | Difference in word count (positive = content added). |
Example
curl
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",
"previous": {
"url": "https://example.com/pricing",
"metadata": { "title": "Pricing", "word_count": 450 },
"markdown": "# Pricing\n\nStarter: $9/mo\nPro: $29/mo",
"text": "Pricing\n\nStarter: $9/mo\nPro: $29/mo"
}
}'