Skip to content

FOXTetsuo/Puppyteer

Repository files navigation

Puppyteer Screenshot Service

A lightweight Go HTTP service that uses chromedp to capture high-quality screenshots of web pages. Designed for backend-to-backend usage (e.g., Laravel calling this service to generate analytics snapshots for Teams).

Features

  • High quality screenshots using full Chrome rendering and configurable viewport scale.
  • Selector-based readiness: wait for a CSS selector before capturing to ensure late-loading analytics render first.
  • Simple API: POST /screenshot returns a PNG byte stream.
  • Health check: GET /health returns ok for monitoring.

Requirements

  • Go 1.22+
  • A Chrome/Chromium installation available on the host (used by chromedp).

Install dependencies

go mod tidy

Note: if your environment restricts outbound network access, run the command in an environment that can reach the Go module proxy to fetch github.com/chromedp/chromedp and generate go.sum.

Run the server

go run main.go

The service listens on :8080 by default.

API

POST /screenshot

Request body (JSON):

{
  "url": "https://example.com/dashboard",
  "fullPage": true,
  "waitSelector": "#charts-loaded",
  "waitTimeoutMs": 15000,
  "viewport": {
    "width": 1440,
    "height": 900,
    "scale": 2
  }
}
  • url (string, required): page to capture.
  • fullPage (bool): capture the entire document instead of the current viewport.
  • waitSelector (string): CSS selector to wait for before capturing.
  • waitTimeoutMs (int): override the default 30s timeout.
  • viewport (object): override width/height/scale; defaults to 1280x720 with 1.0 scale.

Response: image/png bytes containing the screenshot.

GET /health

Returns ok when the service is running.

Notes on quality and performance

  • Set viewport.scale to 2 for Retina-like captures while keeping viewport dimensions manageable.
  • chromedp contexts are created per request and bound to a configurable timeout, allowing concurrent, isolated captures via Go's goroutines.

About

Puppeteer but vroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors