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/diffScreenshot Diff requires a Growth+ plan.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
url_a | string | — | First URL to screenshot and compare. Use with url_b. |
url_b | string | — | Second URL to screenshot and compare. Use with url_a. |
image_a | string | — | First image as base64 string. Use with image_b. |
image_b | string | — | Second image as base64 string. Use with image_a. |
threshold | number | 0.1 | Color distance threshold (0–1). Lower = stricter comparison. |
width | number | 1280 | Viewport width when capturing from URLs. |
height | number | 720 | Viewport 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..."
}| Field | Description |
|---|---|
diff_percent | Percentage of pixels that differ |
diff_pixels | Absolute count of differing pixels |
total_pixels | Total pixels compared (width × height) |
diff_image_base64 | Visual 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
| Code | Error | Description |
|---|---|---|
| 400 | validation_error | Must provide either url_a+url_b or image_a+image_b |
| 401 | unauthorized | Missing or invalid API key |
| 403 | plan_required | Growth+ plan required |
| 429 | rate_limited | Rate limit exceeded |
| 500 | — | Internal server error |