I Replaced a $200/mo Screenshot API With a Single Python File

Published: (March 14, 2026 at 04:11 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Why I Built My Own Screenshot API

I was tired of paying $200/month for Browserless just to take screenshots. Existing services either charge per screenshot or have high monthly fees:

  • Browserless: $200–$2000/mo
  • ScreenshotOne: $0.01 per screenshot
  • Puppeteer self‑hosted: memory leaks, Docker headaches, scaling issues

All I needed was a simple URL → PNG conversion.

Introducing SnapForge

SnapForge is a self‑hosted screenshot and PDF API that lives in a single Python file. No cloud, no subscriptions.

  • MIT‑licensed, single‑file implementation
  • Supports screenshots, PDFs, HTML rendering, device emulation, element capture, dark mode, and more
  • Optional API‑key authentication
  • Scalable with a concurrent worker pool
  • Docker‑ready for one‑line deployment

Installation

pip install playwright aiohttp
playwright install chromium

Running the API

python snapforge.py

The service starts on port 8787.

API Usage

Screenshot

curl -X POST http://localhost:8787/screenshot \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://github.com", "full_page": true }' \
  --output github.png

PDF Generation

curl -X POST http://localhost:8787/pdf \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com", "format": "A4" }' \
  --output page.pdf

HTML Rendering (example payload)

{
  "html": "\n## Invoice #1234\n\nTotal: 99 USD\n",
  "width": 600
}

Features

  • Device emulation: iPhone 14, iPad, Pixel 7, Desktop 4K
  • Element screenshots: capture a specific CSS selector
  • Dark mode: test dark‑color‑scheme rendering
  • Concurrent pool: multiple browser workers for parallel requests
  • API‑key auth: protect your instance with Bearer tokens

Docker Deployment

FROM python:3.11-slim

RUN pip install playwright aiohttp && \
    playwright install chromium --with-deps

COPY snapforge.py /app/
WORKDIR /app
EXPOSE 8787

CMD ["python", "snapforge.py", "--workers", "4"]

Deploy with a single docker build and docker run command.

Common Use Cases

  • CI/CD visual regression testing
  • Invoice and report PDF generation
  • Dynamic OG image generation for social media
  • Dashboard monitoring screenshots
  • Documentation screenshot automation

Cost Comparison (10 000 screenshots/month)

ServiceApprox. Cost
ScreenshotOne~ $100 USD/mo
Browserless$200+ USD/mo
SnapForge (5 USD VPS)$5 USD/mo

Repository

  • GitHub: Single file, MIT license. Self‑host and forget.
0 views
Back to Blog

Related posts

Read more »

Travigo

Travel as fast as you speak with Gemini! Where live agents meet immersive storytelling & 3D navigation. This project was created for entering the Gemini Live Ag...

Micro games

Hey Gamers! 👾 As part of the Rapid Games Prototyping module, we are tasked with reviewing a peer's game. The challenge is to analyse a prototype built in just...