How to Screenshot Password-Protected Pages with an API
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:
- Grafana: Dashboards load fully, including live data panels
- Kibana: Visualizations render with real data
- Jenkins: Build pages show complete status
- Any HTTP Basic Auth page: Works out of the box
Security Considerations
- Requires an API key — anonymous users can't use auth parameters (prevents abuse)
- No caching — authenticated screenshots are never cached to disk (dashboard data is dynamic and potentially sensitive)
- Credentials are never logged — only the URL and dimensions appear in server logs
- HTTPS only — credentials are transmitted over TLS
Combine with Other Features
The auth parameters work with all other Screenshot API features:
wait_for=.panel-content— Wait for dashboard panels to fully renderdelay=5000— Extra time for data-heavy dashboardsfull_page=true— Capture the entire scrollable dashboardscale=2— Retina-quality output for reportsdark_mode=true— Match your dashboard's dark themeformat=webp— 49% smaller files for storage efficiency
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
- Get a free API key:
curl -X POST https://51-68-119-197.sslip.io/api/keys -d '{}' - Take your first authenticated screenshot using the curl example above
- 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) |