Skip to main content

Official Python SDK for SnapRender Screenshot API

Project description

snaprender

PyPI version PyPI downloads license

Official Python SDK for the SnapRender Screenshot API — capture pixel-perfect screenshots of any webpage with a single API call.

500 free screenshots/month — Get your API key

Features

  • Multiple output formats — PNG, JPEG, WebP, and PDF
  • Device emulation — iPhone, iPad, Pixel, and more presets
  • Dark mode — Capture pages with prefers-color-scheme: dark
  • Ad blocking — Remove ads automatically before capture
  • Cookie banner removal — Clean screenshots without consent popups
  • Smart caching — Configurable CDN cache with TTL control
  • Full-page captures — Screenshot the entire scrollable page

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
print(info["expires_at"])  # ISO date string (when cached)

# 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")

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 ("iphone_14", "iphone_15_pro", "pixel_7", "ipad_pro", "macbook_pro")
hide_selectors str Comma-separated CSS selectors to hide
click_selector str CSS selector to click before capture
user_agent str Custom user agent string
cache bool True Use cache
cache_ttl int 86400 Cache TTL in seconds
response_type str "json" returns metadata + base64 data URI

snap.info(url) -> dict

Check if a screenshot is cached without capturing. Returns { url, cached, cache_key, cached_at, expires_at, content_type }.

snap.usage() -> dict

Get current month's usage.

snap.usage_daily(days=30) -> dict

Get daily usage breakdown (default 30 days).

LangChain Integration

Use SnapRender as a LangChain tool for AI agents:

import os
from langchain_core.tools import tool
from snaprender import SnapRender

client = SnapRender(api_key=os.environ["SNAPRENDER_API_KEY"])

@tool
def take_screenshot(url: str, format: str = "png", dark_mode: bool = False) -> str:
    """Capture a screenshot of any website URL. Returns base64 data URI."""
    result = client.capture(
        url, format=format, dark_mode=dark_mode, response_type="json"
    )
    return result["image"]

Works with LangGraph, CrewAI, and any framework that supports LangChain tools.

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"

Links

License

MIT

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.3.0.tar.gz (5.1 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.3.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for snaprender-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7eda305a4706c580bddc58b49e1927356fb9ef7cd471089f8cd399af09d51cc9
MD5 ceeb9f91f6af9f50d53a88765e2e1511
BLAKE2b-256 b31650b2602a3669a87ec5cce9b29bdac10b0682c52155a37b3098f0483f6abf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: snaprender-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9aaf855443d557daaf18dbb39b75dc25cde4d9f219753868d5c31144c5ce8f6d
MD5 ffd6c7a48a116212ec24e6debfb83980
BLAKE2b-256 6b9a240f4fe49c7e987377a9d7ded5469ee4620ac865406a1b13a69275f73ac3

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