How to Screenshot Password-Protected Pages with an API

2026-03-21 | Tags: api, screenshot, authentication, grafana, kibana, dashboard

How to Screenshot Password-Protected Pages with an API

Internal dashboards behind HTTP Basic Auth are everywhere — Grafana, Kibana, Jenkins, Prometheus, internal admin panels. Taking automated screenshots of these pages is surprisingly hard because most screenshot APIs don't support authentication.

The Problem

You want to capture a screenshot of https://grafana.internal.company.com/d/my-dashboard but it's behind HTTP Basic Auth. Standard screenshot APIs just capture the login prompt.

With most tools, you'd need to: 1. Run a full browser automation framework (Puppeteer, Playwright, Selenium) 2. Handle authentication yourself 3. Manage browser lifecycle, timeouts, and cleanup 4. Host it all on a server with enough resources for headless Chrome

The Simple Solution

Our Screenshot API supports http_username and http_password parameters that handle HTTP Basic Auth natively:

curl "https://51-68-119-197.sslip.io/api/screenshot?\
url=https://grafana.example.com/d/my-dashboard&\
http_username=viewer&\
http_password=readonly-pass&\
width=1920&height=1080&\
delay=3000&\
format=png" \
  -H "X-API-Key: YOUR_KEY" \
  -o dashboard.png

That's it. One HTTP request, one PNG back.

How It Works

The API uses Playwright's built-in http_credentials context option, which sends credentials with every HTTP request the browser makes — including XHR calls, WebSocket connections, and embedded resources. This means:

Security Considerations

Combine with Other Features

The auth parameters work with all other Screenshot API features:

Use Cases

Automated reporting: Capture Grafana dashboards every morning and email them to stakeholders. No need for Grafana's built-in image renderer (which requires a separate service).

Incident documentation: During an outage, automatically screenshot affected dashboards for the post-mortem.

Client dashboards: If you run dashboards for clients behind basic auth, automate weekly screenshot reports.

Monitoring dashboards: Screenshot your monitoring stack periodically and archive for trend analysis.

Get Started

  1. Get a free API key: curl -X POST https://51-68-119-197.sslip.io/api/keys -d '{}'
  2. Take your first authenticated screenshot using the curl example above
  3. Integrate into your pipeline — it's just an HTTP request

Free tier includes 50 requests per day — enough for hourly dashboard captures across multiple dashboards.

API Reference

Parameter Description
url The URL to screenshot (required)
http_username HTTP Basic Auth username (requires API key)
http_password HTTP Basic Auth password (requires API key)
width Viewport width in pixels (default: 1280, max: 1920)
height Viewport height in pixels (default: 720, max: 1080)
delay Wait time in ms after page load (default: 0, max: 10000)
wait_for CSS selector to wait for before capture
full_page Capture full scrollable page (default: false)
format Output format: png, jpeg, webp (default: png)
scale Device scale factor: 1, 2, or 3 (default: 1)
dark_mode Emulate dark color scheme (default: false)
block_ads Block ads and trackers (default: false)

Full API documentation →