screenshotcenter
Python SDK for the ScreenshotCenter API — capture web screenshots, PDFs, HTML, and video at scale.
Requirements
- Python 3.9 or later
- No runtime dependencies (uses only the Python standard library)
Installation
pip install screenshotcenter
Quick start
from screenshotcenter import ScreenshotCenterClient
client = ScreenshotCenterClient(api_key="your_api_key")
shot = client.screenshot.create(url="https://example.com", country="us")
result = client.wait_for(shot["id"])
print(result["url"]) # https://example.com/
print(result["status"]) # finished
client.screenshot.save_image(result["id"], "homepage.png")
Authentication
Pass your API key to the constructor:
client = ScreenshotCenterClient(api_key="your_api_key")
You can also override the base URL for self-hosted instances:
client = ScreenshotCenterClient(
api_key="your_api_key",
base_url="https://your-instance.example.com/api/v1",
)
Use cases
Basic screenshot
shot = client.screenshot.create(url="https://example.com")
result = client.wait_for(shot["id"])
client.screenshot.save_image(result["id"], "screenshot.png")
Country / geolocation
# Capture from France
shot = client.screenshot.create(url="https://example.com", country="fr")
# Exact coordinates
shot = client.screenshot.create(
url="https://example.com",
country="us",
geo_enable=True,
geo_latitude=37.7749,
geo_longitude=-122.4194,
)
PDF generation
shot = client.screenshot.create(url="https://example.com", pdf=True)
result = client.wait_for(shot["id"])
assert result["has_pdf"] is True
client.screenshot.save_pdf(result["id"], "page.pdf")
HTML capture
shot = client.screenshot.create(url="https://example.com", html=True)
result = client.wait_for(shot["id"])
client.screenshot.save_html(result["id"], "page.html")
Video recording
shot = client.screenshot.create(
url="https://example.com",
video=True,
video_duration=10, # seconds
)
result = client.wait_for(shot["id"])
client.screenshot.save_video(result["id"], "recording.webm")
Multi-shot (time-lapse)
# Capture 5 screenshots at 3-second intervals
shot = client.screenshot.create(
url="https://example.com",
shots=5,
shot_interval=3,
)
result = client.wait_for(shot["id"])
for i in range(1, 6):
client.screenshot.save_image(result["id"], f"shot_{i}.png", shot=i)
Step automation
shot = client.screenshot.create(
url="https://example.com/login",
steps=[
{"command": "type", "selector": "#email", "value": "user@example.com"},
{"command": "type", "selector": "#password", "value": "secret"},
{"command": "click", "selector": "#submit"},
{"command": "wait", "value": "2000"},
{"command": "screenshot"},
],
)
result = client.wait_for(shot["id"])
Save all outputs at once
shot = client.screenshot.create(url="https://example.com", html=True, pdf=True)
result = client.wait_for(shot["id"])
saved = client.screenshot.save_all(result["id"], "./output/", basename="homepage")
print(saved["image"]) # ./output/homepage.png
print(saved["html"]) # ./output/homepage.html
print(saved["pdf"]) # ./output/homepage.pdf
Batch processing
batch = client.batch.create(
urls=["https://example.com", "https://example.org", "https://python.org"],
country="us",
)
result = client.batch.wait_for(batch["id"], timeout=300)
print(f"Processed: {result['processed']}/{result['count']}")
if result["status"] == "finished":
client.batch.save_zip(result["id"], "results.zip")
Credit balance
acc = client.account.info()
print(f"Credits remaining: {acc['balance']}")
Error handling
from screenshotcenter import ApiError, ScreenshotFailedError, TimeoutError
try:
shot = client.screenshot.create(url="https://example.com")
result = client.wait_for(shot["id"], timeout=60)
except ScreenshotFailedError as e:
print(f"Screenshot {e.screenshot_id} failed: {e.error}")
except TimeoutError as e:
print(f"Timed out after {e.timeout_ms}ms")
except ApiError as e:
print(f"API error {e.status}: {e}")
if e.fields:
for field, messages in e.fields.items():
print(f" {field}: {', '.join(messages)}")
API reference
ScreenshotCenterClient(api_key, *, base_url=None, timeout=30)
| Parameter | Type | Description |
|---|---|---|
api_key |
str |
Your ScreenshotCenter API key (required) |
base_url |
str |
Override the API base URL (default: https://api.screenshotcenter.com/api/v1) |
timeout |
int |
Per-request timeout in seconds (default: 30) |
client.screenshot
| Method | Required | Returns | Description |
|---|---|---|---|
create(url, **kwargs) |
url |
Screenshot |
Request a new screenshot |
info(screenshot_id) |
screenshot_id |
Screenshot |
Get status and details |
list(**kwargs) |
— | list[Screenshot] |
List recent screenshots |
search(url, **kwargs) |
url |
list[Screenshot] |
Search by URL pattern |
thumbnail(screenshot_id, **kwargs) |
screenshot_id |
bytes |
Download thumbnail |
html(screenshot_id) |
screenshot_id |
str |
Get captured HTML |
pdf(screenshot_id) |
screenshot_id |
bytes |
Get rendered PDF |
video(screenshot_id) |
screenshot_id |
bytes |
Get recorded video |
delete(screenshot_id, data="all") |
screenshot_id |
None |
Delete data |
save_image(screenshot_id, path, **kwargs) |
screenshot_id, path |
None |
Download and save thumbnail |
save_html(screenshot_id, path) |
screenshot_id, path |
None |
Download and save HTML |
save_pdf(screenshot_id, path) |
screenshot_id, path |
None |
Download and save PDF |
save_video(screenshot_id, path) |
screenshot_id, path |
None |
Download and save video |
save_all(screenshot_id, dir, basename=None) |
screenshot_id, dir |
dict |
Save all available outputs |
client.batch
| Method | Required | Returns | Description |
|---|---|---|---|
create(urls, country, **kwargs) |
urls, country |
Batch |
Submit a batch job |
info(batch_id) |
batch_id |
Batch |
Get batch status |
list(**kwargs) |
— | list[Batch] |
List recent batches |
cancel(batch_id) |
batch_id |
None |
Cancel a running batch |
download(batch_id) |
batch_id |
bytes |
Download results ZIP |
save_zip(batch_id, path) |
batch_id, path |
None |
Download and save ZIP |
wait_for(batch_id, *, interval=2, timeout=120) |
batch_id |
Batch |
Poll until done |
client.account
| Method | Required | Returns | Description |
|---|---|---|---|
info() |
— | Account |
Get balance and account info |
client.wait_for(screenshot_id, *, interval=2, timeout=120)
Poll until a screenshot reaches finished or error.
| Parameter | Default | Description |
|---|---|---|
screenshot_id |
— | Screenshot ID to poll |
interval |
2 |
Seconds between polls |
timeout |
120 |
Maximum total wait in seconds |
Raises ScreenshotFailedError on status: "error", TimeoutError when the deadline is exceeded.
Testing
# Install dev dependencies
pip install -e ".[dev]"
# Unit tests only (no credentials needed)
pytest tests/test_client.py
# Unit tests + integration tests against the production API
SCREENSHOTCENTER_API_KEY=your_key pytest
# Unit tests + integration tests against a local instance
SCREENSHOTCENTER_API_KEY=your_key \
SCREENSHOTCENTER_BASE_URL=http://localhost:3000/api/v1 \
pytest
# Integration tests only
SCREENSHOTCENTER_API_KEY=your_key pytest tests/test_integration.py
| Variable | Required | Description |
|---|---|---|
SCREENSHOTCENTER_API_KEY |
Required for integration tests | API key for live requests |
SCREENSHOTCENTER_BASE_URL |
Optional | Override the API base URL |
Type hints
All methods are fully type-annotated. Response objects are typed as
TypedDict
subclasses (Screenshot, Batch, Account) — they are plain dicts at
runtime, so all standard dict operations apply. Unknown future API fields
are accessible directly on the returned dict.
from screenshotcenter import Screenshot
def print_info(shot: Screenshot) -> None:
print(shot["id"], shot["status"], shot["url"])
License
Metadata
Release files for screenshotcenter 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| screenshotcenter-1.1.1.tar.gz | 17.2 kB | Without provenance | Details for screenshotcenter-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| screenshotcenter-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for screenshotcenter-1.1.1-py3-none-any.whl |
Total release size: 31.1 kB
Release files / screenshotcenter-1.1.1.tar.gz
| Download URL | screenshotcenter-1.1.1.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
935a1f17a30fd81b4927e5cdbf789931d5d9787b5a629daa8a4567d22a9f7156
|
|
BLAKE2b-256 checksum How to use checksums |
01570c8599cd716ac4293122c2a5218c4d028dd79ac66172245b5dc4e7d941b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / screenshotcenter-1.1.1-py3-none-any.whl
| Download URL | screenshotcenter-1.1.1-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c038edc0df5cc67f6ecdb7102bfdd17c2b6a8d3fbdc612f3719fd7b57082593
|
|
BLAKE2b-256 checksum How to use checksums |
ca08a53479ad27b3a5139d0fd49bd9c88783e001a934ea6507791f19700be8e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for screenshotcenter 1.1.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.