Skip to content
Screenshot diff

screenshot.diff

Compare public web pages or a stored screenshot baseline at a fixed viewport.

POSThttps://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.diff at https://api.kanagu.dev/mcp
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"
    }
  }
}
Request body
{
  "url": "https://www.iana.org/domains/reserved",
  "compareToUrl": "https://www.rfc-editor.org/about/",
  "viewport": {
    "width": 1024,
    "height": 768
  },
  "waitUntil": "load",
  "waitForSelector": "h1"
}
Response · illustrative values
{
  "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)required
viewportobject
viewport.widthinteger (320 to 1600)required
viewport.heightinteger (240 to 1200)required
waitUntil"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)required
diffRationumberrequired
widthinteger (-9007199254740991 to 9007199254740991)required
heightinteger (-9007199254740991 to 9007199254740991)required
rectanglesarray of objectrequired
rectangles[].xinteger (-9007199254740991 to 9007199254740991)required
rectangles[].yinteger (-9007199254740991 to 9007199254740991)required
rectangles[].widthinteger (-9007199254740991 to 9007199254740991)required
rectangles[].heightinteger (-9007199254740991 to 9007199254740991)required
beforeobjectrequired
before.idstring (uuid)required
before.urlstring (uri)required
before.expiresAtstring (date-time)required
afterobjectrequired
after.idstring (uuid)required
after.urlstring (uri)required
after.expiresAtstring (date-time)required
diffobjectrequired
diff.idstring (uuid)required
diff.urlstring (uri)required
diff.expiresAtstring (date-time)required

Try it

screenshot.diff

$0.01/call

No key needed · 10 free calls per IP per day

Response

Run the request to see the live response here.

Errors

Errors are JSON {"error":{"code","message"}}. An operation may add its own 400 codes; the message says what to fix.

StatusCode and meaning
400invalid_input

The body does not match the request schema. The message names each field.

400invalid_json

The body is missing or is not valid JSON.

400invalid_idempotency_key

Idempotency-Key must be 1–128 visible ASCII characters.

401invalid_api_key

The Bearer key is missing, malformed, invalid or inactive.

402free_allowance_exhausted

This 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.

404not_found

No operation at this path.

409idempotency_conflict

The Idempotency-Key was already used with a different body.

413payload_too_large

JSON bodies may be at most 64 KiB.

429trial_limit

The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.

500internal_error

The 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
}