Screenshotlayer vs. Google PageSpeed Screenshots for Website Previews
Screenshotlayer creates configurable website images; PageSpeed Insights analyzes performance. Here’s how to choose, call each API, and use ScreenshotNeo for clean previews.
Short answer: Use Screenshotlayer when you need a screenshot image for a website preview. Use Google PageSpeed Insights when you need a performance assessment and optimization suggestions. They are adjacent tools, not interchangeable screenshot services. If you need repeatable preview images and want cookie banners, popups, and chat widgets removed, consider ScreenshotNeo as another screenshot API option.
1. What each service returns
Screenshotlayer is a website screenshot API. Its documented options include image formats, viewport and thumbnail sizing, full-page capture, custom CSS, capture delay, caching, and export options. Its FAQ lists PNG, JPEG, and GIF output, custom User-Agent and Accept-Language headers, and a default screenshot cache period of 2,592,000 seconds (30 days); the ttl parameter can set a lower period. See the Screenshotlayer FAQ and its API specifications.
Google PageSpeed Insights API v5 analyzes a page and returns PageSpeed scores and suggestions to improve it. Its result is a diagnostic JSON report, not a configurable image asset. The current official API reference documents the v5 runpagespeed method. A screenshot field does appear in the legacy v4 reference; treat that as version-specific historical context, not evidence that the current service is a dedicated preview-image API.
| Question | Screenshotlayer | PageSpeed Insights API |
|---|---|---|
| Primary output | Website screenshot image | Performance analysis JSON with scores and suggestions |
| Best fit | Preview cards, thumbnails, and image assets | Performance checks and optimization workflows |
| Image output controls | Documented formats, viewport, sizing, delay, and other capture options | Not the purpose of the current v5 API |
| Historical screenshot detail | Core service use | Legacy v4 reference documented an optional screenshot field |
2. Choose by the deliverable
- You need an image file or image URL: use a screenshot API such as Screenshotlayer. Decide whether you need a viewport shot or full page, which format suits the destination, and whether the page needs extra render time.
- You need to understand loading and performance: call PageSpeed Insights and consume its report. Do not treat a performance result as a replacement for a stable preview image.
- You need both: call both services for separate jobs. Store the screenshot as an image asset and the PageSpeed response as diagnostic data. Avoid coupling preview generation to a performance score unless your product actually needs that relationship.
Compare the needed output, viewport or device control, capture timing, cache behavior, image format, export workflow, request volume, and commercial terms. Screenshotlayer publishes capture controls and plans; PageSpeed’s documentation describes performance analysis and recommendations. Confirm vendor quotas and plan terms on the relevant product pages before committing, since they can change.
3. Call Screenshotlayer for a preview image
Create an account with Screenshotlayer and use its access key. The API specification identifies access_key and the target url as required parameters. This cURL example writes the returned image response to a file:
curl -G "https://api.screenshotlayer.com/api/capture" \
--data-urlencode "access_key=YOUR_ACCESS_KEY" \
--data-urlencode "url=https://example.com" \
--data-urlencode "format=PNG" \
-o preview.png
Use the endpoint and parameter spelling shown in the current Screenshotlayer documentation for your account. The following optional parameters are documented in its API specifications and FAQ; verify availability and accepted values before relying on them:
| Parameter or setting | Use | Practical note |
|---|---|---|
format |
Choose PNG, JPEG, or GIF; PNG is documented as the default. | Choose based on the destination and image content. |
fullpage |
Request the full page height. | Long pages can produce large images and longer captures. |
viewport |
Set the browser viewport dimensions. | Specify dimensions that match the preview layout you need. |
width |
Request a thumbnail width. | Check output dimensions and avoid unnecessary downstream resizing. |
delay |
Wait before capture so animations or effects can finish. | Use the smallest delay that reliably captures the intended state. |
ttl |
Set cache lifetime in seconds. | The FAQ gives a 30-day default and says custom TTL can be lower. |
force |
Force a fresh capture, according to the API specification. | Use when a cached preview is stale; it may increase capture work. |
user_agent, accept_lang |
Set the outgoing User-Agent or language header. | Useful when the target varies by user agent or language. |
css_url |
Attach a custom CSS stylesheet, per the API specification. | Keep the stylesheet reachable by the capture service. |
export |
Export to an FTP path or AWS S3, per the specification. | Follow the provider’s current credential and destination instructions. |
Screenshotlayer’s FAQ also describes paid plans and a free tier, but quotas and prices are vendor claims that can change. Check its current pricing page for current terms rather than assuming figures from older documentation remain valid.
4. Call PageSpeed Insights for diagnostics
The current v5 API accepts a URL at https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed. A key is recommended for frequent automated queries in Google’s getting-started guide. Save the JSON response and inspect it as a report; it is not an image file.
cURL
curl --get "https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed" \
--data-urlencode "url=https://example.com" \
--data-urlencode "key=YOUR_API_KEY" \
--data-urlencode "strategy=mobile" \
-o pagespeed.json
Python
import requests
endpoint = "https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed"
params = {
"url": "https://example.com",
"key": "YOUR_API_KEY",
"strategy": "mobile",
}
response = requests.get(endpoint, params=params, timeout=90)
response.raise_for_status()
report = response.json()
with open("pagespeed.json", "w", encoding="utf-8") as output:
import json
json.dump(report, output, indent=2)
print("Report for:", report.get("id"))
Node.js
const endpoint = new URL(
'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed'
);
endpoint.searchParams.set('url', 'https://example.com');
endpoint.searchParams.set('key', 'YOUR_API_KEY');
endpoint.searchParams.set('strategy', 'mobile');
const response = await fetch(endpoint);
if (!response.ok) {
throw new Error(`PageSpeed request failed: ${response.status} ${await response.text()}`);
}
const report = await response.json();
console.log('Report for:', report.id);
The Google getting-started guide shows the v5 endpoint, an example cURL request, and JavaScript usage. The method reference documents request parameters including strategy and categories. Add only the categories and locale your application needs; consult the method reference for accepted values and response fields.
5. Parse outputs without mixing their purposes
For a screenshot, treat the response as image bytes or a provider-directed image result according to the selected API mode. Save it with a matching extension and content type, then validate that the file is non-empty and decodable before publishing it as a preview.
For PageSpeed, parse JSON. The response contains diagnostic information rather than a ready-to-use preview asset. Keep the full response when you need auditability, and extract only the fields your application displays. The API response schema can evolve; use the official reference rather than hard-coding assumptions from an old v4 response.
6. Reliability, latency, and cost considerations
- Preview freshness: screenshot caching reduces repeated work but may serve an older view. Pick a TTL that matches how often target pages change, and use a documented refresh mechanism where supported.
- Capture completion: client-side rendering, fonts, animations, and delayed content can affect what appears. A delay may help, but excessive waits add latency. Test representative pages and use a bounded request timeout.
- Full-page size: full-height images can be much larger than viewport captures. Choose a thumbnail width or downstream resize when the destination has a fixed card size.
- PageSpeed variability: performance analysis is a diagnostic measurement, not a visual capture contract. Keep the analysis strategy consistent when comparing reports, and avoid treating one result as a guaranteed constant.
- Request volume: estimate screenshot requests and diagnostic calls separately. Check current provider quotas, plan limits, and commercial terms before production use.
- Retries: retry transient network failures with a small bounded backoff. Do not blindly retry malformed requests or authorization failures. Avoid duplicate capture requests when a fresh result is not necessary.
- Credential handling: keep access keys out of public source repositories and client-side code when they grant account access. Use environment configuration on servers and rotate credentials if exposed.
7. Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
| Screenshot request returns an error instead of an image | Missing or invalid access key, malformed URL, unsupported parameter, or account restriction. | Check required parameters, URL encoding, key status, and the provider’s returned error details. |
| Image file contains text or JSON | The API returned an error response and the client saved it as an image. | Check HTTP status and response content type before saving; inspect the body on failure. |
| Preview is stale | A cached screenshot is being reused. | Adjust the cache TTL or use the documented force-refresh option where appropriate. |
| Page looks incomplete | Content loads after capture, requires scrolling, or depends on scripts or external resources. | Try full-page mode or a modest capture delay; check the source page and resource availability. |
| PageSpeed returns an HTTP error | Invalid request URL, key/configuration problem, quota restriction, or a temporary service failure. | Read the JSON error body, confirm the endpoint and encoded URL, then check API configuration and quotas. |
| PageSpeed request is slow | The service is running a page analysis and returning a diagnostic report. | Set a client timeout appropriate to your workflow, avoid unnecessary repeated analyses, and keep this separate from latency-sensitive image delivery. |
| PageSpeed JSON has no screenshot field | The current API is being used for its documented performance-analysis purpose; the screenshot field belongs to legacy v4 documentation. | Use a screenshot API for preview images and the current PageSpeed API for diagnostics. |
8. Or skip the browser setup
For an image preview, ScreenshotNeo provides a single GET request that returns an image or PDF. See the ScreenshotNeo API documentation for options and response behavior.
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie banners are accepted and 60+ known consent platforms, newsletter popups, and chat widgets are removed before the shot; each step can be turned off.
- Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status.
- An MCP server lets AI agents use
take_screenshot,get_page_info, andcapture_pdf. - 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000 screenshots. Every feature is on every plan.
Create a free ScreenshotNeo account and get 1,000 screenshots a month with no card.
9. FAQ
Can PageSpeed Insights generate the preview image I should show users?
Use a screenshot API for a dependable preview-image workflow. PageSpeed Insights’ current documented purpose is performance analysis; the screenshot field found in its v4 reference is version-specific legacy context.
Can I use both services in one application?
Yes. Generate the visual asset with a screenshot service and run PageSpeed separately when you need performance diagnostics.
Which format should I choose for previews?
Choose based on the destination’s supported formats and image characteristics. Screenshotlayer documents PNG, JPEG, and GIF; verify the current API documentation for any format-specific limits.
Should I use a cached screenshot?
Use caching when repeated requests should show the same capture for a period. Set freshness based on the target site’s update rate and confirm current cache controls in provider documentation.
