Skip to main content

Snapshots API

Capture Screenshot

POST /api/v1/snapshots
Request:
{
  "url": "https://example.com",
  "browser": "chromium",
  "viewport": {
    "width": 1280,
    "height": 720
  },
  "full_page": false,
  "wait_for": "network_idle",
  "hide_selectors": [".ad-banner"],
  "mask_selectors": [".dynamic-content"]
}
Response:
{
  "id": "snap_abc123",
  "url": "https://example.com",
  "browser": "chromium",
  "viewport": { "width": 1280, "height": 720 },
  "status": "completed",
  "image_url": "https://storage.brainzlab.ai/snapshots/snap_abc123.png",
  "captured_at": "2024-01-15T10:30:00Z"
}

Get Snapshot

GET /api/v1/snapshots/:id
Response:
{
  "id": "snap_abc123",
  "page_id": "page_xyz",
  "url": "https://example.com",
  "browser": "chromium",
  "viewport": { "width": 1280, "height": 720 },
  "status": "completed",
  "image_url": "https://storage.brainzlab.ai/snapshots/snap_abc123.png",
  "image_size_bytes": 125000,
  "captured_at": "2024-01-15T10:30:00Z",
  "duration_ms": 2500
}

List Snapshots

GET /api/v1/snapshots
Query Parameters:
  • page_id - Filter by page
  • browser - Filter by browser
  • since - Snapshots since timestamp
  • limit - Max results
Response:
{
  "snapshots": [
    {
      "id": "snap_abc123",
      "page_id": "page_xyz",
      "url": "https://example.com",
      "browser": "chromium",
      "status": "completed",
      "captured_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Compare Snapshot to Baseline

POST /api/v1/snapshots/:id/compare
Response:
{
  "comparison_id": "cmp_xyz789",
  "snapshot_id": "snap_abc123",
  "baseline_id": "base_def456",
  "status": "pending_review",
  "diff_percentage": 2.5,
  "threshold": 1.0,
  "passed": false,
  "diff_url": "https://storage.brainzlab.ai/diffs/diff_xyz.png"
}

Delete Snapshot

DELETE /api/v1/snapshots/:id

Comparison Endpoints

Get Comparison

GET /api/v1/comparisons/:id
Response:
{
  "id": "cmp_xyz789",
  "snapshot_id": "snap_abc123",
  "baseline_id": "base_def456",
  "status": "pending_review",
  "diff_percentage": 2.5,
  "diff_pixels": 12500,
  "threshold": 1.0,
  "baseline_url": "https://storage.brainzlab.ai/baselines/base_def456.png",
  "snapshot_url": "https://storage.brainzlab.ai/snapshots/snap_abc123.png",
  "diff_url": "https://storage.brainzlab.ai/diffs/diff_xyz.png",
  "created_at": "2024-01-15T10:30:05Z"
}

Approve Comparison

POST /api/v1/comparisons/:id/approve
Request:
{
  "reason": "Intentional design change"
}
Response:
{
  "id": "cmp_xyz789",
  "status": "approved",
  "approved_by": "[email protected]",
  "approved_at": "2024-01-15T10:35:00Z",
  "new_baseline_id": "base_new123"
}

Reject Comparison

POST /api/v1/comparisons/:id/reject
Request:
{
  "reason": "Unintended layout break"
}

Update Baseline

POST /api/v1/comparisons/:id/update_baseline
Sets the snapshot as the new baseline without changing comparison status.