webclaw

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/diff

Compare 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"
  }
}
FieldTypeRequiredDescription
urlstringYesURL to scrape for the current version.
previousobjectYesA 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
}
FieldTypeDescription
statusstring"Changed" or "Unchanged".
text_diffstringUnified diff of the text content.
metadata_changesarrayList of metadata fields that changed, with old and new values.
links_addedstring[]URLs present in the current version but not the previous.
links_removedstring[]URLs present in the previous version but removed.
word_count_deltanumberDifference 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"
    }
  }'