Menu
Docs/Screenshot Diff

Screenshot Diff

Compare two screenshots pixel-by-pixel. Provide two URLs or two base64 images, and get back the diff percentage, pixel count, and a visual diff image.

POST/v1/diff

Screenshot Diff requires a Growth+ plan.

Parameters

ParameterTypeDefaultDescription
url_astringFirst URL to screenshot and compare. Use with url_b.
url_bstringSecond URL to screenshot and compare. Use with url_a.
image_astringFirst image as base64 string. Use with image_b.
image_bstringSecond image as base64 string. Use with image_a.
thresholdnumber0.1Color distance threshold (0–1). Lower = stricter comparison.
widthnumber1280Viewport width when capturing from URLs.
heightnumber720Viewport height when capturing from URLs.

You must provide either url_a + url_b or image_a + image_b. Mixing URL and base64 is not supported.

Response

{
  "diff_percent": 12.45,
  "diff_pixels": 114892,
  "total_pixels": 921600,
  "width": 1280,
  "height": 720,
  "threshold": 0.1,
  "diff_image_base64": "iVBORw0KGgo..."
}
FieldDescription
diff_percentPercentage of pixels that differ
diff_pixelsAbsolute count of differing pixels
total_pixelsTotal pixels compared (width × height)
diff_image_base64Visual diff image — changed pixels highlighted in red

Examples

Compare two URLs:

curl -X POST https://api.snapsharp.dev/v1/diff \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url_a": "https://example.com",
    "url_b": "https://staging.example.com",
    "width": 1440,
    "threshold": 0.05
  }'

Compare two base64 images:

curl -X POST https://api.snapsharp.dev/v1/diff \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "image_a": "iVBORw0KGgo...",
    "image_b": "iVBORw0KGgo...",
    "threshold": 0.1
  }'

Use cases

  • Visual regression testing — compare production vs staging before deploy
  • A/B testing — quantify visual differences between variants
  • Brand monitoring — detect unauthorized changes to your web pages
  • QA automation — verify UI changes in CI/CD pipelines

Errors

CodeErrorDescription
400validation_errorMust provide either url_a+url_b or image_a+image_b
401unauthorizedMissing or invalid API key
403plan_requiredGrowth+ plan required
429rate_limitedRate limit exceeded
500Internal server error