Metadata-Version: 2.4
Name: screenshotsage
Version: 1.0.0
Summary: Official Python SDK for ScreenshotSage - Capture high-quality screenshots of any website
Project-URL: Homepage, https://screenshotsage.com
Project-URL: Documentation, https://screenshotsage.com/docs
Project-URL: Repository, https://github.com/screenshotsage/python-sdk
Project-URL: Issues, https://github.com/screenshotsage/python-sdk/issues
Author-email: ScreenshotSage <support@screenshotsage.com>
License-Expression: MIT
Keywords: puppeteer,screenshot,screenshot-api,screenshotsage,url-to-image,web-capture,webpage-capture,website-screenshot
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Multimedia :: Graphics :: Capture :: Screen Capture
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# ScreenshotSage Python SDK

Official Python SDK for [ScreenshotSage](https://screenshotsage.com) - Capture high-quality screenshots of any website.

## Installation

```bash
pip install screenshotsage
```

## Quick Start

```python
from screenshotsage import ScreenshotSage

# Initialize the client
client = ScreenshotSage(api_key="your-api-key")

# Basic screenshot
result = client.capture(url="https://example.com")
print(result["data"]["downloadUrl"])

# Mobile screenshot
result = client.capture(
    url="https://example.com",
    devicePreset="mobile",
    format="webp",
    quality=85
)

# Full page screenshot
result = client.capture(
    url="https://example.com",
    fullPage=True,
    format="png"
)

# Download the screenshot
image_bytes = client.download(result["data"]["downloadUrl"])
with open("screenshot.png", "wb") as f:
    f.write(image_bytes)

# Or capture and download in one step
image_bytes = client.capture_and_download(url="https://example.com")
```

## Async Usage

```python
import asyncio
from screenshotsage import ScreenshotSage

async def main():
    async with ScreenshotSage(api_key="your-api-key") as client:
        result = await client.capture_async(url="https://example.com")
        print(result["data"]["downloadUrl"])

        # Download
        image_bytes = await client.download_async(result["data"]["downloadUrl"])

asyncio.run(main())
```

## Features

### Device Presets

```python
# Desktop (default: 1200x800)
client.capture(url="https://example.com", devicePreset="desktop")

# Tablet (768x1024)
client.capture(url="https://example.com", devicePreset="tablet")

# Mobile (375x667, iPhone user agent)
client.capture(url="https://example.com", devicePreset="mobile")
```

### Output Formats

```python
# PNG (default)
client.capture(url="https://example.com", format="png")

# JPEG with quality
client.capture(url="https://example.com", format="jpeg", quality=90)

# WebP
client.capture(url="https://example.com", format="webp", quality=85)

# PDF (Professional+ plans)
client.capture(url="https://example.com", format="pdf")

# HTML snapshot
client.capture(url="https://example.com", format="html")
```

### Clean Screenshots

```python
# Remove ads, cookie banners, and chat widgets
client.capture(
    url="https://example.com",
    blockAds=True,
    blockCookieBanners=True,
    blockChatWidgets=True
)

# Hide specific elements
client.capture(
    url="https://example.com",
    hideSelectors=[".popup", "#newsletter-modal", ".sticky-footer"]
)
```

### Geolocation & Timezone

```python
client.capture(
    url="https://maps.google.com",
    geolocation={
        "latitude": 40.7128,
        "longitude": -74.0060,
        "accuracy": 100
    },
    timezone="America/New_York",
    language="en-US"
)
```

### Authentication

```python
# HTTP Basic Auth
client.capture(
    url="https://example.com/admin",
    basicAuth={
        "username": "admin",
        "password": "secret"
    }
)

# Session cookies
client.capture(
    url="https://example.com/dashboard",
    cookies=[
        {
            "name": "session_id",
            "value": "abc123xyz",
            "httpOnly": True,
            "secure": True
        }
    ]
)
```

### Custom CSS/JavaScript

```python
# Inject custom styles and scripts (Professional+ plans)
client.capture(
    url="https://example.com",
    customCss="body { background: #f0f0f0 !important; }",
    customJs="document.querySelector('.popup')?.remove();"
)
```

### Clip Region

```python
# Capture a specific region
client.capture(
    url="https://example.com",
    clip={
        "x": 0,
        "y": 0,
        "width": 800,
        "height": 600
    }
)
```

## Error Handling

```python
from screenshotsage import ScreenshotSage, ScreenshotSageError

client = ScreenshotSage(api_key="your-api-key")

try:
    result = client.capture(url="https://example.com")
except ScreenshotSageError as e:
    print(f"Error: {e}")
    print(f"Status code: {e.status_code}")
    print(f"Response: {e.response}")
```

## Configuration

```python
client = ScreenshotSage(
    api_key="your-api-key",
    base_url="https://screenshotsage.com",  # Custom base URL
    timeout=120.0  # Request timeout in seconds
)
```

## License

MIT
