Skip to main content

Official Python SDK for SnapRender Screenshot API

Project description

snaprender

Official Python SDK for the SnapRender Screenshot API.

Install

pip install snaprender

Quick Start

from snaprender import SnapRender

snap = SnapRender(api_key="sk_live_...")

# Capture a screenshot
image = snap.capture("https://example.com")
with open("screenshot.png", "wb") as f:
    f.write(image)

# Capture with options
jpg = snap.capture(
    "https://example.com",
    format="jpeg",
    width=1920,
    height=1080,
    full_page=True,
    dark_mode=True,
    quality=95,
)

# Check cache status
info = snap.info("https://example.com")
print(info["cached"])  # True/False

# Get usage
usage = snap.usage()
print(f"{usage['used']}/{usage['limit']} screenshots used")

Context Manager

with SnapRender(api_key="sk_live_...") as snap:
    image = snap.capture("https://example.com")

Error Handling

from snaprender import SnapRender, SnapRenderError

snap = SnapRender(api_key="sk_live_...")

try:
    snap.capture("https://example.com")
except SnapRenderError as e:
    print(e.code)    # "QUOTA_EXCEEDED"
    print(e.status)  # 429
    print(e)         # "Monthly quota exceeded"

API

SnapRender(api_key, base_url="https://app.snap-render.com", timeout=60.0)

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

Option Type Default Description
url str URL to capture (required)
format str "png" "png", "jpeg", "webp", or "pdf"
width int 1280 Viewport width
height int 800 Viewport height
full_page bool False Capture full scrollable page
quality int 90 JPEG/WebP quality (1-100)
delay int 0 Wait ms after page load
dark_mode bool False Emulate dark mode
block_ads bool True Block ad networks
block_cookie_banners bool True Remove cookie banners
device str Device preset (e.g. "iPhone 15")
cache bool True Use cache
cache_ttl int 86400 Cache TTL in seconds

snap.info(url) -> dict

snap.usage() -> dict

snap.usage_daily(days=30) -> dict

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snaprender-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snaprender-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file snaprender-0.1.0.tar.gz.

File metadata

  • Download URL: snaprender-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for snaprender-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9bab95356c7630faff7420c68242c3eb39e35fcd3608de5b1f3a26a7d2b4a163
MD5 324ed62c5fab8167a11627cdb3018530
BLAKE2b-256 393a79ebe839399ff8f7939d3905e2bcbd9915df9baccbca965968a305756153

See more details on using hashes here.

File details

Details for the file snaprender-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: snaprender-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for snaprender-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 957d2cbf7a49012180cb9f66757370e6d5cc641545d7fe988dc965199532b517
MD5 f7f0770f17f6311fb650d8e3ab667845
BLAKE2b-256 25075a8aae904ba8a5ef1d81926defaccc5bf7b24ffce5c4f96af63b98b93300

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page