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).
- 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 /screenshotreturns a PNG byte stream. - Health check:
GET /healthreturnsokfor monitoring.
- Go 1.22+
- A Chrome/Chromium installation available on the host (used by
chromedp).
go mod tidyNote: 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/chromedpand generatego.sum.
go run main.goThe service listens on :8080 by default.
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 to1280x720with1.0scale.
Response: image/png bytes containing the screenshot.
Returns ok when the service is running.
- Set
viewport.scaleto2for Retina-like captures while keeping viewport dimensions manageable. chromedpcontexts are created per request and bound to a configurable timeout, allowing concurrent, isolated captures via Go's goroutines.