Python SDK

Script Snapshot Site into batch jobs, QA pipelines, and automation flows

Use the official Python SDK when you want a clean client for screenshot capture, webpage analysis, compare workflows, and local asset downloads without managing raw HTTP payloads.

snapshot-site-sdk
Official package
Python
Scripts, pipelines, services
Download assets
Save returned files locally
Install:pip install snapshot-site-sdk
Auth:SNAPSHOT_SITE_API_KEY=ss_live_xxx
Get started for free
Python workflow
Python screenshot API automation pipeline capturing, comparing, analyzing, and saving website assets
Good fits
Content QA pipelines and recurring monitoring jobs
Archive, compliance, and documentation snapshots
Internal automation scripts that need screenshot, compare, and analyze
Python services that want a cleaner client than raw HTTP

SDK overview

The Python SDK is built for teams running scheduled, scriptable workflows. It keeps integrations small and makes it easy to save or process outputs after capture.

1

Designed for batch and automation work

Use it in scheduled scripts, worker jobs, QA pipelines, and internal tooling.

2

One client for screenshot, analyze, and compare

The same client object can cover all major Snapshot Site workflows.

3

Easy local asset handling

You can save images and outputs locally without writing custom download plumbing.

4

Good fit for recurring operational jobs

Python teams can plug it into cron jobs, data workflows, or review pipelines quickly.

Quick start

Install, authenticate, run jobs

1

Install `snapshot-site-sdk`

2

Set or inject your Snapshot Site API key

3

Instantiate `SnapshotSiteClient`

4

Run screenshot, analyze, compare, or local download workflows

Code examples

Screenshot

Minimal screenshot example

Capture a page with a lightweight Python client.

from snapshot_site import SnapshotSiteClient

import os

client = SnapshotSiteClient(
    api_key=os.environ["SNAPSHOT_SITE_API_KEY"]
)

result = client.screenshot({
    "url": "https://snapshot-site.com/pricing",
    "width": 1440,
    "format": "png",
    "fullSize": True,
    "hideCookie": True,
})

print(result.get("link"))
Analyze

Analyze example

Run webpage analysis from the same Python client.

result = client.analyze({
    "url": "https://snapshot-site.com",
    "width": 1440,
    "fullSize": True,
    "enableSummary": True,
    "enableQuality": True,
})

print(result)
Compare

Compare and download assets

Compare two states and save returned outputs locally.

result = client.compare({
    "before": {
        "url": "https://snapshot-site.com/pricing",
        "width": 1440,
        "fullSize": True,
        "hideCookie": True,
    },
    "after": {
        "url": "https://staging.snapshot-site.com/pricing",
        "width": 1440,
        "fullSize": True,
        "hideCookie": True,
    },
    "threshold": 0.1,
})

client.download_to(result, "pricing.png")

Python screenshot API workflows

The official snapshot-site-sdk package gives Python applications a small client for screenshots, rendered-page analysis, visual comparison, and asset download. It fits recurring operational work: scheduled scripts, QA pipelines, content review, internal services, and jobs that process an approved list of URLs.

The current SDK requires Python 3.9 or later. It uses the production Snapshot Site API by default and allows a custom base URL when an authorized environment requires one.

Configure credentials outside the script

Read the API key from an environment variable or secret manager. A key written directly into a script, notebook cell, example output, or repository can be copied long after the original job finishes.

import os
from snapshot_site import SnapshotSiteClient

client = SnapshotSiteClient(
    api_key=os.environ["SNAPSHOT_SITE_API_KEY"]
)

Fail clearly when the variable is missing. In CI or a scheduler, configure the secret in the platform rather than generating a local .env file during the job. Avoid printing client configuration in debug output.

Select the method for the result you need

Capture with screenshot()

Use screenshot() to create an image or PDF from a URL. Specify width so the responsive layout is intentional. Set fullSize when the complete document matters, and use the smallest reliable delay for late content. See full-page screenshots for long-page decisions.

Analyze with analyze()

Use analyze() when the rendered page should produce summary or quality information with the capture. AI output supports triage and review; preserve the URL and screenshot when a person may need to verify the generated result.

Compare with compare()

Use compare() for release QA and monitored baselines. Configure both states identically and use the returned diff image to interpret mismatch metrics. The visual regression guide covers threshold and baseline practices.

Save with download_to()

Use download_to() with a direct asset URL or supported response mapping. Choose the output path in trusted application code, create parent directories deliberately, and never concatenate an untrusted filename without validation.

Design a reliable URL batch

A list of URLs turns a simple API call into an operational workflow. Validate each input, normalize the scheme, and attach a stable internal identifier. Process results independently so one bad URL does not discard the rest of the run.

def capture_one(item):
    return client.screenshot({
        "url": item["url"],
        "format": "webp",
        "width": 1440,
        "fullSize": True,
        "hideCookie": True,
        "delay": 2,
    })

for item in approved_urls:
    try:
        result = capture_one(item)
        save_result(item["id"], result)
    except Exception as exc:
        record_failure(item["id"], exc)

Sequential processing is a clear starting point. When throughput becomes a measured constraint, add a bounded worker pool or queue. Do not submit an entire large dataset concurrently without regard for memory, retries, or service limits.

Checkpoint progress after each item or small batch. A restarted job should resume from incomplete work rather than recapture every successful page.

Python QA and monitoring patterns

Release comparison

Capture production and preview URLs with the same configuration, call compare(), and attach the diff image to the release record. Keep approval separate from baseline replacement so an unexpected change cannot approve itself.

Content inventory

Use analyze() over an authorized URL set to help classify and prioritize pages. AI-generated summaries are review aids, not canonical content records. For exact fields, use deterministic extraction or validation.

Scheduled website monitoring

Store a known-good image, capture the live page on a schedule, and compare the two. Route meaningful differences with before, after, and diff context. The website monitoring page explains baseline lifecycle and alert design.

Asset generation

Use screenshot output for documentation, internal previews, or approved marketing workflows. Cache stable results instead of recapturing the same page every time a downstream consumer asks for it.

Error and retry handling

Classify errors before retrying. Invalid URLs, missing credentials, and rejected payloads need correction. Timeouts or temporary transport failures may justify a bounded retry with backoff. Store the attempt count and final state with the URL record.

Sanitize logged URLs when query parameters may contain credentials or personal data. Log internal job identifiers and status, not the API key. Restrict access to downloaded captures according to the sensitivity of the source page.

Performance and storage

Use viewport capture when only the visible fold is needed. Full-page mode renders more content and should serve a concrete requirement. Keep delay small and evidence-based. Prevent overlapping scheduled runs from processing the same queue twice.

Select PNG for lossless UI detail, WebP or JPEG for lighter previews, and PDF for document output. Preserve the original when it is evidence and derive thumbnails separately.

Common Python integration mistakes

  • Hardcoding the key in a script or notebook.
  • Sending a large URL list with unbounded concurrency.
  • Losing completed work when one batch item fails.
  • Writing assets to unvalidated paths.
  • Retrying permanent errors indefinitely.
  • Comparing screenshots created with different settings.
  • Treating AI output as exact extracted data.

Use the API documentation for request fields and the SDK repository for current compatibility. Validate one representative workflow before scaling it across a dataset.

Python screenshot API SDK FAQ

Which Python version does the SDK require?

The current Snapshot Site Python SDK requires Python 3.9 or later. Verify the package metadata before changing the runtime of an existing deployment.

Which methods does the Python client provide?

The verified client includes screenshot, analyze, compare, and download_to methods for capture, structured analysis, visual diff, and local asset workflows.

Can I use the SDK in a scheduled script?

Yes. It is suitable for cron jobs, workers, QA pipelines, content operations, and backend services that can protect the API key.

How should I pass the API key?

Read it from an environment variable or secret manager and pass it as api_key when creating SnapshotSiteClient. Do not hardcode it in a notebook or repository.

What does download_to accept?

It accepts a direct asset URL or a supported response mapping and writes the selected downloadable asset to the supplied local path.

Can I process a large CSV of URLs?

Yes. Validate rows, use bounded concurrency, checkpoint progress, and record failures per URL. Avoid starting an unbounded number of network requests at once.

Can I use the SDK in a notebook?

Yes, if the notebook environment can protect secrets and downloaded page data. Avoid saving the API key or sensitive results in shared notebook output.

Should I use the SDK or Python requests directly?

Use the SDK for its verified client methods and download helper. Use raw HTTP when the environment cannot install the package or requires complete transport control.

Run one reproducible Python capture job

Load the key from the environment, capture a representative URL, and preserve the request settings before expanding the workflow to a batch.