Skip to main content

Screenshot & PDF API

Python wrapper for the Screenshot & PDF API on RapidAPI.

Capture screenshots, generate PDFs, extract page metadata, and render HTML/CSS to images — all from a single, zero-dependency package.

PyPI version Python 3.8+ License: MIT

Installation

pip install screenshot-pdf-api

Quick Start

from screenshot_pdf_api import ScreenshotAPI

api = ScreenshotAPI("your-rapidapi-key")

# Check API status
print(api.health())

# Take a screenshot
png = api.screenshot("https://example.com")
with open("example.png", "wb") as f:
    f.write(png)

Get Your API Key

  1. Go to RapidAPI - Screenshot & PDF API
  2. Subscribe to a plan (free tier available)
  3. Copy your X-RapidAPI-Key from the dashboard

Endpoints

Free Tier

api = ScreenshotAPI("your-key")

# Screenshot any URL → PNG, JPEG, or WebP
png = api.screenshot("https://example.com")

# Full-page screenshot with custom viewport
img = api.screenshot(
    "https://example.com",
    width=1920,
    height=1080,
    full_page=True,
    format="jpeg",
    quality=90,
)

# Screenshot a specific element
element = api.screenshot(
    "https://example.com",
    selector="#main-content",
)

# Wait for dynamic content before capture
img = api.screenshot(
    "https://example.com",
    delay=2000,  # wait 2 seconds
)

Basic Tier

# Generate a PDF from any URL
pdf = api.pdf("https://example.com")
with open("page.pdf", "wb") as f:
    f.write(pdf)

# PDF with custom options
pdf = api.pdf(
    "https://example.com",
    format="Letter",
    landscape=True,
    print_background=True,
    margin="narrow",
)

# Extract page metadata (title, OG tags, favicon, etc.)
meta = api.metadata("https://example.com")
print(meta["title"])
print(meta["og"])
print(meta["favicon"])

Pro Tier

# Render HTML/CSS to image
html = """
<html>
<body style="background: linear-gradient(135deg, #667eea, #764ba2);
             color: white; font-family: Arial; padding: 40px;">
  <h1>Hello World</h1>
  <p>Rendered from raw HTML</p>
</body>
</html>
"""
img = api.screenshot_html(html, width=800, height=600)
with open("rendered.png", "wb") as f:
    f.write(img)

Error Handling

The library raises specific exceptions for different error types:

from screenshot_pdf_api import (
    ScreenshotAPI,
    ScreenshotAuthError,
    ScreenshotForbiddenError,
    ScreenshotRateLimitError,
    ScreenshotAPIError,
)

api = ScreenshotAPI("your-key")

try:
    img = api.screenshot_html("<h1>Pro feature</h1>")
except ScreenshotAuthError:
    print("Invalid API key")
except ScreenshotForbiddenError:
    print("Upgrade your plan for this endpoint")
except ScreenshotRateLimitError:
    print("Rate limited — slow down or upgrade")
except ScreenshotAPIError as e:
    print(f"API error [{e.status_code}]: {e.message}")
Exception HTTP Code Meaning
ScreenshotAuthError 401 Invalid or missing API key
ScreenshotForbiddenError 403 Endpoint not in your tier
ScreenshotNotFoundError 404 Resource not found
ScreenshotRateLimitError 429 Rate limit exceeded
ScreenshotServerError 5xx Server-side error
ScreenshotAPIError any Base class for all errors

Configuration

api = ScreenshotAPI(
    api_key="your-key",
    timeout=60,       # request timeout in seconds (default: 30)
)

Requirements

  • Python 3.8+
  • Zero dependencies — uses only urllib.request from the standard library

License

MIT

Metadata

Release files for screenshot-pdf-api 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for screenshot-pdf-api 1.1.0
File Size Uploaded Provenance
screenshot_pdf_api-1.1.0.tar.gz 8.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for screenshot-pdf-api 1.1.0
File Interpreter ABI Platform
screenshot_pdf_api-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / screenshot_pdf_api-1.1.0.tar.gz

Download URL screenshot_pdf_api-1.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6dfc442feb60f8eacf89c403e8d5d806b7d0b19b2ecebca47c371689fe60922e
BLAKE2b-256 checksum
How to use checksums
dd90b6eac0fad62be01a4231f34280085627c8df39bcb54dc5a88e489a693afe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / screenshot_pdf_api-1.1.0-py3-none-any.whl

Download URL screenshot_pdf_api-1.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1a8987a75ad2b6a18b9364f05ae23a161b2d2230bb962d3ca62e589d741280c
BLAKE2b-256 checksum
How to use checksums
c3b7da5d63d6a6bcae6b5e32e59db8550899c1740bf6ce402251be96b663277a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for screenshot-pdf-api 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page