Python Integration

Screenshot API for Python

Capture any website as an image or PDF with the official nodium-screenshot Python SDK. Both synchronous and async interfaces, Django/Flask integration, and automatic retries built in.

Install in Seconds

Works with Python 3.9+ and any virtual environment.

pip

pip install nodium-screenshot

poetry

poetry add nodium-screenshot

with async support

pip install nodium-screenshot[async]

Synchronous & Asynchronous

Choose the interface that fits your application -- blocking or non-blocking.

sync_example.py
from nodium_screenshot import NodiumScreenshot

client = NodiumScreenshot("YOUR_API_KEY")

result = client.take(
    url="https://example.com",
    format="png",
    viewport_width=1440,
    viewport_height=900,
    full_page=True,
    block_ads=True,
)

with open("screenshot.png", "wb") as f:
    f.write(result.data)

print(f"Saved ({len(result.data)} bytes)")
async_example.py
import asyncio
from nodium_screenshot import AsyncNodiumScreenshot

async def capture():
    async with AsyncNodiumScreenshot("YOUR_API_KEY") as client:
        urls = [
            "https://example.com",
            "https://example.org",
            "https://example.net",
        ]

        tasks = [
            client.take(url=url, format="png")
            for url in urls
        ]
        results = await asyncio.gather(*tasks)

        for i, result in enumerate(results):
            with open(f"screenshot-{i}.png", "wb") as f:
                f.write(result.data)

asyncio.run(capture())
views.py -- Django integration
from django.http import HttpResponse, JsonResponse
from django.conf import settings
from nodium_screenshot import NodiumScreenshot, NodiumAPIError

client = NodiumScreenshot(settings.NODIUM_API_KEY)

def capture_screenshot(request):
    url = request.GET.get("url")
    if not url:
        return JsonResponse({"error": "url parameter required"}, status=400)

    try:
        result = client.take(url=url, format="png", viewport_width=1280)
        return HttpResponse(result.data, content_type="image/png")
    except NodiumAPIError as e:
        return JsonResponse({"error": e.code}, status=e.http_status)

Built for Python Developers

A Pythonic SDK that feels native to your stack.

Sync & Async
Use NodiumScreenshot for blocking calls or AsyncNodiumScreenshot with httpx for non-blocking I/O.
Automatic Retries
Built-in exponential backoff on 5xx server errors. Configure retry count and delay for your production needs.
Framework Ready
First-class integration examples for Django, Flask, FastAPI, and any WSGI/ASGI framework.
Concurrent Captures
Use asyncio.gather() to capture multiple URLs in parallel with the async client.
Typed Exceptions
Catch NodiumAPIError, NodiumTimeoutError, and check error codes, HTTP status, and retryability.
Fluent Builder
Chain methods like .url().format().viewport() for clean, readable configuration in both sync and async modes.

Why Nodium for Python?

Skip the headless browser complexity. Focus on your application logic.

Without Nodium

  • Install Selenium, Playwright, or pyppeteer with browser binaries
  • Configure display servers for headless rendering on Linux
  • Handle browser crashes, memory leaks, and zombie processes
  • Build ad blocking, device emulation, and PDF generation
  • Deploy heavy container images with Chrome dependencies

With Nodium

  • One pip install, zero system dependencies
  • Works on any platform without display configuration
  • Managed infrastructure with automatic retries
  • 145+ parameters including ads, dark mode, devices
  • Lightweight Docker images, fast CI/CD pipelines

Common Python Use Cases

Web Scraping Pipelines
Add visual captures to your Scrapy or BeautifulSoup workflows for archival and verification.
Django Admin Previews
Generate link previews and thumbnails directly from your Django application.
Automated Testing
Capture visual snapshots in pytest test suites for visual regression testing.
PDF Report Generation
Convert HTML reports and dashboards to pixel-perfect PDFs.
Social Media Cards
Generate Open Graph images dynamically for your content marketing platform.
Data Science Notebooks
Capture live dashboard screenshots from Jupyter notebooks for reporting.

Start Capturing Screenshots with Python

Free tier included. No credit card required. Get your API key and start building in minutes.