screenshot.diff
Compare public web pages or a stored screenshot baseline at a fixed viewport.
https://api.kanagu.dev/v1/screenshot/diff- Price
- $0.01 per successful call
- Without a key
- 10 free calls per IP per UTC day, shared by REST and MCP.
- MCP tool
screenshot.diffathttps://api.kanagu.dev/mcp- Markdown
- /docs/screenshot.diff.md
curl https://api.kanagu.dev/v1/screenshot/diff \
-H "Content-Type: application/json" \
-d '{"url":"https://www.iana.org/domains/reserved","compareToUrl":"https://www.rfc-editor.org/about/","viewport":{"width":1024,"height":768},"waitUntil":"load","waitForSelector":"h1"}'curl https://api.kanagu.dev/v1/screenshot/diff \
-H "Authorization: Bearer $KANAGU_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://www.iana.org/domains/reserved","compareToUrl":"https://www.rfc-editor.org/about/","viewport":{"width":1024,"height":768},"waitUntil":"load","waitForSelector":"h1"}'const res = await fetch("https://api.kanagu.dev/v1/screenshot/diff", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KANAGU_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"url": "https://www.iana.org/domains/reserved",
"compareToUrl": "https://www.rfc-editor.org/about/",
"viewport": {
"width": 1024,
"height": 768
},
"waitUntil": "load",
"waitForSelector": "h1"
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "screenshot.diff",
"arguments": {
"url": "https://www.iana.org/domains/reserved",
"compareToUrl": "https://www.rfc-editor.org/about/",
"viewport": {
"width": 1024,
"height": 768
},
"waitUntil": "load",
"waitForSelector": "h1"
}
}
}{
"url": "https://www.iana.org/domains/reserved",
"compareToUrl": "https://www.rfc-editor.org/about/",
"viewport": {
"width": 1024,
"height": 768
},
"waitUntil": "load",
"waitForSelector": "h1"
}{
"changedPixels": 412318,
"diffRatio": 0.5243,
"width": 1024,
"height": 768,
"rectangles": [
{
"x": 0,
"y": 0,
"width": 1024,
"height": 768
}
],
"before": {
"id": "…",
"url": "https://api.kanagu.dev/v1/screenshot/artifacts/…",
"expiresAt": "2026-12-24T09:12:03.000Z"
},
"after": {
"id": "…",
"url": "https://api.kanagu.dev/v1/screenshot/artifacts/…",
"expiresAt": "2026-12-24T09:12:03.000Z"
},
"diff": {
"id": "…",
"url": "https://api.kanagu.dev/v1/screenshot/artifacts/…",
"expiresAt": "2026-12-24T09:12:03.000Z"
}
}Request body
application/json
urlstring (uri, max 2048 chars)requiredviewportobjectviewport.widthinteger (320 to 1600)requiredviewport.heightinteger (240 to 1200)requiredwaitUntil"load" | "domcontentloaded" | "networkidle0" | "networkidle2"waitForSelectorstring (max 256 chars)waitMsinteger (0 to 2000)maskSelectorsarray of string (max 256 chars)thresholdnumber (0 to 0.5)
Then exactly one of these 2 shapes:
1. With compareToUrl
compareToUrlstring (uri, max 2048 chars)required
2. With baselineId
baselineIdstring (uuid)required- ID of a before or after capture from a prior comparison.
Response
200 · application/json
changedPixelsinteger (-9007199254740991 to 9007199254740991)requireddiffRationumberrequiredwidthinteger (-9007199254740991 to 9007199254740991)requiredheightinteger (-9007199254740991 to 9007199254740991)requiredrectanglesarray of objectrequiredrectangles[].xinteger (-9007199254740991 to 9007199254740991)requiredrectangles[].yinteger (-9007199254740991 to 9007199254740991)requiredrectangles[].widthinteger (-9007199254740991 to 9007199254740991)requiredrectangles[].heightinteger (-9007199254740991 to 9007199254740991)requiredbeforeobjectrequiredbefore.idstring (uuid)requiredbefore.urlstring (uri)requiredbefore.expiresAtstring (date-time)requiredafterobjectrequiredafter.idstring (uuid)requiredafter.urlstring (uri)requiredafter.expiresAtstring (date-time)requireddiffobjectrequireddiff.idstring (uuid)requireddiff.urlstring (uri)requireddiff.expiresAtstring (date-time)required
Try it
Errors
Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.
| Status | Code and meaning |
|---|---|
| 400 | invalid_inputThe body does not match the request schema. The message names each field. |
| 400 | invalid_jsonThe body is missing or is not valid JSON. |
| 400 | invalid_idempotency_keyIdempotency-Key must be 1–128 visible ASCII characters. |
| 401 | invalid_api_keyThe Bearer key is missing, malformed, invalid or inactive. |
| 402 | free_allowance_exhaustedThis month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left. |
| 404 | not_foundNo operation at this path. |
| 409 | idempotency_conflictThe Idempotency-Key was already used with a different body. |
| 413 | payload_too_largeJSON bodies may be at most 64 KiB. |
| 429 | trial_limitThe anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left. |
| 500 | internal_errorThe call failed on our side. It is not billed; retry with the same Idempotency-Key. |
JSON Schema
Request schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"oneOf": [
{
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"viewport": {
"default": {
"width": 1280,
"height": 720
},
"type": "object",
"properties": {
"width": {
"type": "integer",
"minimum": 320,
"maximum": 1600
},
"height": {
"type": "integer",
"minimum": 240,
"maximum": 1200
}
},
"required": [
"width",
"height"
],
"additionalProperties": false
},
"waitUntil": {
"default": "domcontentloaded",
"type": "string",
"enum": [
"load",
"domcontentloaded",
"networkidle0",
"networkidle2"
]
},
"waitForSelector": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"waitMs": {
"default": 200,
"type": "integer",
"minimum": 0,
"maximum": 2000
},
"maskSelectors": {
"default": [],
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 256
}
},
"threshold": {
"default": 0.1,
"type": "number",
"minimum": 0,
"maximum": 0.5
},
"compareToUrl": {
"type": "string",
"maxLength": 2048,
"format": "uri"
}
},
"required": [
"url",
"compareToUrl"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 2048,
"format": "uri"
},
"viewport": {
"default": {
"width": 1280,
"height": 720
},
"type": "object",
"properties": {
"width": {
"type": "integer",
"minimum": 320,
"maximum": 1600
},
"height": {
"type": "integer",
"minimum": 240,
"maximum": 1200
}
},
"required": [
"width",
"height"
],
"additionalProperties": false
},
"waitUntil": {
"default": "domcontentloaded",
"type": "string",
"enum": [
"load",
"domcontentloaded",
"networkidle0",
"networkidle2"
]
},
"waitForSelector": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"waitMs": {
"default": 200,
"type": "integer",
"minimum": 0,
"maximum": 2000
},
"maskSelectors": {
"default": [],
"maxItems": 20,
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 256
}
},
"threshold": {
"default": 0.1,
"type": "number",
"minimum": 0,
"maximum": 0.5
},
"baselineId": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
"description": "ID of a before or after capture from a prior comparison."
}
},
"required": [
"url",
"baselineId"
],
"additionalProperties": false
}
],
"examples": [
{
"url": "https://www.iana.org/domains/reserved",
"compareToUrl": "https://www.rfc-editor.org/about/",
"viewport": {
"width": 1024,
"height": 768
},
"waitUntil": "load",
"waitForSelector": "h1"
}
],
"type": "object"
}Response schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"changedPixels": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"diffRatio": {
"type": "number"
},
"width": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"height": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"rectangles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"x": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"y": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"width": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"height": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
},
"required": [
"x",
"y",
"width",
"height"
],
"additionalProperties": false
}
},
"before": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"url": {
"type": "string",
"format": "uri"
},
"expiresAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
"id",
"url",
"expiresAt"
],
"additionalProperties": false
},
"after": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"url": {
"type": "string",
"format": "uri"
},
"expiresAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
"id",
"url",
"expiresAt"
],
"additionalProperties": false
},
"diff": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
},
"url": {
"type": "string",
"format": "uri"
},
"expiresAt": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
"id",
"url",
"expiresAt"
],
"additionalProperties": false
}
},
"required": [
"changedPixels",
"diffRatio",
"width",
"height",
"rectangles",
"before",
"after",
"diff"
],
"additionalProperties": false
}