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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rendshot-0.2.0.tar.gz.
File metadata
- Download URL: rendshot-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39667945f0526db2c1c7544c77facd566d0a8bb2e5d2493be61d519dee547588
|
|
| MD5 |
f3d3d2d18bb5d69ad7534d3ee0ba0122
|
|
| BLAKE2b-256 |
391a2910655fa7b4e8e20194f210c2920469f3baab70473183440f264447a634
|
File details
Details for the file rendshot-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rendshot-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a1ffb08d682d75d013820c1217db979d53dea654402446d6f83e7ae4eca5960
|
|
| MD5 |
bab8d2645cfe9fc141091b5e195dca53
|
|
| BLAKE2b-256 |
0e0ce2a012ede92be0b7ea2223352ad34ae2cd56d8c34bb7e6dabfd72f383929
|