Skip to main content

Python SDK for ScreenshotAPIs — convert URLs or HTML to screenshots and PDFs

Project description

screenshotapis

Python SDK for ScreenshotAPIs — convert URLs or HTML to screenshots and PDFs with a single function call.

Install

pip install screenshotapis

Quick Start

from screenshotapis import Client

client = Client("your_api_key")

# Screenshot a URL
client.screenshot("https://example.com", file="screenshot.png")

# Screenshot with options
client.screenshot(
    "https://example.com",
    format="jpeg",
    width=1920,
    height=1080,
    full_page=True,
    file="full_page.jpeg",
)

# Render HTML to PDF
client.pdf(html="<h1>Invoice #42</h1><p>Total: $100</p>", file="invoice.pdf")

# PDF from URL
client.pdf("https://example.com", format="Letter", file="page.pdf")

Async Support

from screenshotapis.client import AsyncClient

async with AsyncClient("your_api_key") as client:
    await client.screenshot("https://example.com", file="screenshot.png")
    await client.pdf(html="<h1>Hello</h1>", file="doc.pdf")

Screenshot Options

Parameter Type Default Description
url str None URL to screenshot
html str None Raw HTML to render
format str "png" "png", "jpeg", or "webp"
width int 1280 Viewport width
height int 720 Viewport height
full_page bool False Capture full scrollable page
dark_mode bool False Enable dark color scheme
device_scale_factor int 1 Pixel density (2 for retina)
selector str None CSS selector for element capture
delay_ms int 0 Wait before capture (ms)
file str None Save to file path

PDF Options

Parameter Type Default Description
url str None URL to render
html str None Raw HTML to render
format str "A4" "A4", "Letter", "Legal", "A3", "Tabloid"
landscape bool False Landscape orientation
print_background bool True Include backgrounds
file str None Save to file path

Error Handling

from screenshotapis.client import ScreenshotAPIError

try:
    client.screenshot("https://example.com", file="shot.png")
except ScreenshotAPIError as e:
    print(e.status_code, e.detail)

Get Your API Key

Sign up at screenshotapis.org — free tier with 100 renders/month, no credit card required.

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

screenshotapis-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

screenshotapis-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for screenshotapis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a6eedb07a319d358967334b19a335ae2a6e1fbf641fce047e0d69a5a23952d9
MD5 742f727f0c3ebb8a3dc6cbbf719e6254
BLAKE2b-256 bcb061938b7fe30d04eb092ead5273f6ee9f97e433589f6c3ba37038cf827bc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for screenshotapis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ad2bd4ffc1fc564906731f3ce4cf5ba1aab756f4fdfdba7d86e5d9a4ea18d39
MD5 ced7bcf3095aadbb3aa05362e2ea1ee1
BLAKE2b-256 b3dd50e326ae860fdfca89ac751a6bb57a8c79baa9956beb4799842e877926e9

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