Skip to main content

Official Python SDK for RendShot — HTML-to-image rendering and URL screenshots

Project description

rendshot

Official Python SDK for RendShot — HTML-to-image rendering and URL screenshots.

Installation

pip install rendshot

Quick Start

from rendshot import RendshotClient, RenderImageOptions, ScreenshotUrlOptions

client = RendshotClient(api_key="rs_live_...")

# Render HTML to image
result = client.render_image(RenderImageOptions(
    html="<h1 style='color: green;'>Hello World</h1>",
    width=800,
    height=400,
))
print(result.url)

# Screenshot a URL
result = client.screenshot_url(ScreenshotUrlOptions(url="https://example.com"))
print(result.url)

Async

from rendshot import AsyncRendshotClient, ScreenshotUrlOptions

async with AsyncRendshotClient(api_key="rs_live_...") as client:
    result = await client.screenshot_url(
        ScreenshotUrlOptions(url="https://example.com", full_page=True)
    )
    print(result.url)

API

RendshotClient / AsyncRendshotClient

client = RendshotClient(api_key="rs_live_...", base_url="https://api.rendshot.ai")

Both clients support context managers and expose the same methods:

Method Description
render_image(options) Render HTML/CSS to an image
screenshot_url(options) Take a screenshot of a URL
get_usage() Get current month's usage
get_image(image_id) Get metadata for a specific image

Options

All option classes accept keyword arguments and convert Python snake_case to API camelCase automatically.

RenderImageOptions

Parameter Type Default Description
html str required HTML content to render
css str Optional CSS styles
width int 1080 Image width (1–4096)
height int 1080 Image height (1–4096)
format "png" | "jpg" "png" Output format
quality int 90 JPEG quality (1–100)
device_scale 1 | 2 | 3 1 Device scale factor
fonts list[str] Custom fonts
timeout int 10000 Timeout in ms (1000–30000)

ScreenshotUrlOptions

Parameter Type Default Description
url str required URL to screenshot
width int 1280 Viewport width (1–4096)
height int 800 Viewport height (1–4096)
format "png" | "jpg" "png" Output format
quality int 90 JPEG quality (1–100)
full_page bool False Capture full page
device_scale 1 | 2 | 3 1 Device scale factor
timeout int 10000 Timeout in ms (1000–30000)

Error Handling

from rendshot import RendshotClient, RendshotError, RenderImageOptions

client = RendshotClient(api_key="rs_live_...")

try:
    client.render_image(RenderImageOptions(html="<h1>Hello</h1>"))
except RendshotError as e:
    print(e.code)     # "RATE_LIMIT_EXCEEDED"
    print(e.status)   # 429
    print(e)          # "Rate limited"

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

rendshot-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

rendshot-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rendshot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9659f89f09be90d714c9146a43e18752efa7c9b0185dc3d4e400051c78e62143
MD5 423f96595328a09d393f68ea31765868
BLAKE2b-256 b4885ef46073d342651afaad65ef8c6257b9f9a4b86ab7eec489180443412098

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rendshot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for rendshot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 627fb528d8d8f8a88da929ea23d52d4874003e55151c3b0a469e5a7b47460223
MD5 1565d170f96c4fabcd7369ed1f2dc2ab
BLAKE2b-256 b1a6683d45ea0d5393950566d0b5dfad61cd123bcffae45a460e553733e4b008

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