SnapAPI/sdk/python
OpenClaw 195a656a7d
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 9m14s
fix(sdk): BUG-015 validate URL in capture() when using ScreenshotOptions
- Add URL validation after options.to_dict() in Python SDK
- Add failing test first (TDD), then fix
- All 17 Python SDK tests passing
2026-02-27 11:01:11 +00:00
..
src/snapapi fix(sdk): BUG-015 validate URL in capture() when using ScreenshotOptions 2026-02-27 11:01:11 +00:00
tests fix(sdk): BUG-015 validate URL in capture() when using ScreenshotOptions 2026-02-27 11:01:11 +00:00
pyproject.toml feat: add Node.js and Python SDKs 2026-02-23 14:02:15 +00:00
README.md feat: add Node.js and Python SDKs 2026-02-23 14:02:15 +00:00

SnapAPI Python SDK

Official Python client for SnapAPI — the EU-hosted screenshot API.

Zero dependencies. Uses only Python standard library (urllib).

Installation

pip install snapapi

Quick Start

from snapapi import SnapAPI

snap = SnapAPI("your-api-key")

# Capture a screenshot
screenshot = snap.capture("https://example.com")

with open("screenshot.png", "wb") as f:
    f.write(screenshot)

Usage

Basic Screenshot

png = snap.capture("https://example.com")

With Options

jpg = snap.capture(
    "https://example.com",
    format="jpeg",
    width=1920,
    height=1080,
    quality=90,
)

Full-Page Capture

full = snap.capture(
    "https://example.com/blog",
    full_page=True,
    device_scale=2,  # Retina
)

Mobile Viewport

mobile = snap.capture(
    "https://example.com",
    width=375,
    height=812,
    device_scale=2,
)

Wait for Dynamic Content

screenshot = snap.capture(
    "https://example.com/dashboard",
    wait_for_selector="#chart-loaded",
    wait_until="networkidle2",
)

Error Handling

from snapapi import SnapAPI, SnapAPIError

snap = SnapAPI("your-api-key")

try:
    screenshot = snap.capture("https://example.com")
except SnapAPIError as e:
    print(f"API error {e.status}: {e.detail}")

API Reference

SnapAPI(api_key, base_url="https://snapapi.eu", timeout=30)

snap.capture(url, **options) -> bytes

Option Type Default Description
url str URL to capture (required)
format str "png" Output: png, jpeg, webp
width int 1280 Viewport width (3203840)
height int 800 Viewport height (2002160)
full_page bool False Capture full page
quality int 80 JPEG/WebP quality (1100)
wait_for_selector str CSS selector to wait for
device_scale float 1 Device pixel ratio (13)
delay int 0 Extra delay in ms (05000)
wait_until str "domcontentloaded" Load event

snap.health() -> dict

Returns API health status.

EU-Hosted & GDPR Compliant

SnapAPI runs entirely on EU infrastructure (Germany). Your data never leaves the EU.

License

MIT — Cloonar Technologies GmbH