Metadata-Version: 2.4
Name: screenshotapis
Version: 0.1.0
Summary: Python SDK for ScreenshotAPIs — convert URLs or HTML to screenshots and PDFs
Project-URL: Homepage, https://screenshotapis.org
Project-URL: Documentation, https://screenshotapis.org/guide
Project-URL: Repository, https://github.com/nbafrank/screenshotapis-python
License-Expression: MIT
License-File: LICENSE
Keywords: api,html-to-pdf,pdf,screenshot,url-to-image
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# screenshotapis

Python SDK for [ScreenshotAPIs](https://screenshotapis.org) — convert URLs or HTML to screenshots and PDFs with a single function call.

## Install

```bash
pip install screenshotapis
```

## Quick Start

```python
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

```python
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

```python
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](https://screenshotapis.org) — free tier with 100 renders/month, no credit card required.
