We use cookies

We use cookies to enhance your experience and analyse site usage.

Python Integration

Screenshot API for Python

Capture website screenshots in Python with a single HTTP request. No Selenium, no WebDriver, no Chrome binary to install or maintain. Just the requests library you already use.

  • No Selenium, no browser drivers, no system dependencies
  • Works with requests, httpx, aiohttp — your choice
  • Compatible with Django, Flask, FastAPI, and Lambda
  • Async support via httpx for high-throughput workloads
  • Handles rendering, JavaScript, and timeouts server-side
  • Free tier: 100 screenshots/month, no credit card required
Python
import os
import requests

def screenshot(url: str, **kwargs) -> bytes:
    response = requests.get(
        'https://api.webcaptureapi.com/api/screenshot',
        params={'url': url, **kwargs},
        headers={'x-api-key': os.environ['WEBCAPTURE_API_KEY']},
        timeout=30,
    )
    response.raise_for_status()
    return response.content

# Save to disk
image = screenshot('https://example.com', format='png', width=1280)
with open('screenshot.png', 'wb') as f:
    f.write(image)

More examples

Common patterns for Python apps.

Full-page capture

Python
# Full-page screenshot (entire scrollable page)
image = screenshot(
    'https://example.com',
    format='jpeg',
    quality=85,
    width=1440,
    full_page='true',
)

with open('full-page.jpg', 'wb') as f:
    f.write(image)

Django view

Python
# Django view
import os
import requests
from django.http import HttpResponse, JsonResponse

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

    res = requests.get(
        'https://api.webcaptureapi.com/api/screenshot',
        params={'url': url, 'format': 'png', 'width': 1280},
        headers={'x-api-key': os.environ['WEBCAPTURE_API_KEY']},
        timeout=30,
    )
    res.raise_for_status()
    return HttpResponse(res.content, content_type='image/png')

Async with httpx (FastAPI)

Python
import os
import httpx

async def screenshot_async(url: str, **kwargs) -> bytes:
    async with httpx.AsyncClient(timeout=30) as client:
        response = await client.get(
            'https://api.webcaptureapi.com/api/screenshot',
            params={'url': url, **kwargs},
            headers={'x-api-key': os.environ['WEBCAPTURE_API_KEY']},
        )
        response.raise_for_status()
        return response.content

# In a FastAPI route:
@app.get('/capture')
async def capture(url: str):
    image = await screenshot_async(url, format='jpeg', quality=85)
    return Response(content=image, media_type='image/jpeg')

What you can build

Web scraping pipelines

Add visual snapshots to your scraping workflow alongside structured data extraction.

Automated reporting

Screenshot dashboard pages and attach them to automated email or Slack reports.

Data science tooling

Capture visual context alongside scraped data in Jupyter notebooks or ML pipelines.

Django/Flask admin tools

Add screenshot capture to internal admin tools for moderation, QA, or content review.

Competitor monitoring

Build scheduled capture jobs to track competitor pricing pages or landing pages over time.

Visual regression tests

Screenshot pages in CI with pytest or unittest to catch layout regressions before deploy.

Start capturing screenshots in Python

Free tier — 100 screenshots/month, no credit card required.

Get your free API key