Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Short answer: Google’s current PageSpeed Insights API v5 does not document a screenshot field, so a v5 request cannot be treated as a full-page screenshot service. Google’s older v4 reference documented an optional screenshot response, but that is a legacy API contract. Google Apps Script can call either endpoint, decode returned bytes and save a real image to Drive—but Apps Script cannot create screenshot data that the API did not return.

This guide shows the correct version-aware implementation, explains what each response contains, and gives you a dependable alternative when you need an actual full-page capture.

What the PageSpeed API can—and cannot—return

The current method is GET https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed. It requires a url query parameter; strategy accepts desktop or mobile and defaults to desktop. The documented v5 response contains PageSpeed and Lighthouse data such as analysisUTCTimestamp, loadingExperience, originLoadingExperience, lighthouseResult and version. The v5 schema does not document a screenshot property.

That distinction matters because many snippets online combine the old and current contracts. The v4 reference (last shown as updated September 3, 2024) lists an optional Boolean screenshot request parameter, defaulting to false, and describes a base64-encoded screenshot object with MIME type and dimensions. Treat that as v4 documentation, not proof that v5 returns a full-page image. Check the endpoint and response before writing image-handling code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Prerequisites and authorization

  • A Google account with access to Apps Script at script.google.com.
  • An Apps Script project and a destination Google Drive folder (or permission to create files in your Drive).
  • An API key if your PageSpeed configuration requires one. Keep keys in PropertiesService, not in client-side HTML.
  • For explicit Apps Script scopes, UrlFetchApp requires https://www.googleapis.com/auth/script.external_request; creating Drive files requires Drive authorization.

Apps Script’s UrlFetchApp can return response text, raw bytes or a Blob. DriveApp.createFile(blob) can persist a Blob. Neither service changes a JSON PageSpeed response into a screenshot.

Option 1: Call the current v5 API for PageSpeed data

Use this when you need Lighthouse results, not an image. The function below logs the HTTP status and parses the documented JSON response.

function runPageSpeedV5() {
  var targetUrl = 'https://example.com/';
  var endpoint = 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed';
  var params = {
    url: targetUrl,
    strategy: 'desktop'
  };
  var query = Object.keys(params).map(function (key) {
    return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
  }).join('&');
  var response = UrlFetchApp.fetch(endpoint + '?' + query, {
    method: 'get',
    muteHttpExceptions: true,
    headers: {
      Accept: 'application/json'
    }
  });
  var status = response.getResponseCode();
  var text = response.getContentText();
  if (status < 200 || status >= 300) {
    throw new Error('PageSpeed v5 HTTP ' + status + ': ' + text);
  }
  var data = JSON.parse(text);
  Logger.log(JSON.stringify({
    analyzedUrl: data.id || targetUrl,
    timestamp: data.analysisUTCTimestamp,
    lighthouseVersion: data.lighthouseResult && data.lighthouseResult.lighthouseVersion
  }));
  return data;
}

If you need a mobile run, change strategy to mobile. Do not add code that expects data.screenshot unless you have independently confirmed that a particular response actually contains such a field; the current reference does not promise it.

Option 2: Handle the legacy v4 screenshot response

The v4 reference documents a separate screenshot request. Because v4 and v5 have different contracts, isolate this code and label files accordingly. The example below requests v4 with screenshot=true, checks for a screenshot object, decodes its base64 payload and saves it to Drive.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
function captureLegacyPageSpeedScreenshot() {
  var targetUrl = 'https://example.com/';
  var endpoint = 'https://www.googleapis.com/pagespeedonline/v4/runPagespeed';
  var apiKey = PropertiesService.getScriptProperties().getProperty('PAGESPEED_API_KEY');
  var query = [
    'url=' + encodeURIComponent(targetUrl),
    'screenshot=true',
    'strategy=desktop'
  ];
  if (apiKey) query.push('key=' + encodeURIComponent(apiKey));

  var response = UrlFetchApp.fetch(endpoint + '?' + query.join('&'), {
    method: 'get',
    muteHttpExceptions: true,
    headers: { Accept: 'application/json' }
  });
  var status = response.getResponseCode();
  var text = response.getContentText();
  if (status < 200 || status >= 300) {
    throw new Error('PageSpeed v4 HTTP ' + status + ': ' + text);
  }
  var data = JSON.parse(text);
  var shot = data.screenshot;
  if (!shot || !shot.data) {
    throw new Error('The response did not contain the v4 screenshot object.');
  }

  var mimeType = shot.mime_type || 'image/png';
  var bytes = Utilities.base64Decode(shot.data);
  var blob = Utilities.newBlob(bytes, mimeType, 'pagespeed-legacy-screenshot.png');
  var file = DriveApp.createFile(blob);
  Logger.log(file.getUrl());
  return file.getId();
}

Base64 cleanup and MIME types

Some APIs prefix base64 with a data-URI header such as data:image/png;base64,. The v4 description identifies the payload as base64 and supplies MIME information; if your response includes a prefix, remove everything through the first comma before calling Utilities.base64Decode. Use the returned MIME type when creating the Blob, and choose a matching extension (.png, .jpeg or another type actually returned).

function decodeScreenshotPayload(payload, mimeType, filename) {
  var comma = payload.indexOf(',');
  if (payload.indexOf('data:') === 0 && comma >= 0) {
    payload = payload.substring(comma + 1);
  }
  return Utilities.newBlob(
    Utilities.base64Decode(payload),
    mimeType || 'image/png',
    filename || 'pagespeed-screenshot.png'
  );
}

Saving and organizing files in Drive

DriveApp.createFile(blob) creates the file in the authorizing user’s My Drive. For repeat jobs, add a timestamp and a stable hostname to avoid overwriting confusion, and move the file to a known folder after creation.

function saveBlobInFolder(blob, folderId, name) {
  var folder = DriveApp.getFolderById(folderId);
  blob.setName(name);
  var file = folder.createFile(blob);
  return file.getUrl();
}

Drive authorization is requested the first time the script runs this path. A failed authorization, a deleted folder, or a folder ID from a different account prevents file creation even when the HTTP request succeeded.

Why this is not necessarily a full-page capture

A screenshot object documented by an older API does not automatically mean a complete, vertically stitched page. PageSpeed analysis and browser screenshot services have different goals, and the current v5 reference does not establish a full-page image mechanism. If your requirement is a complete page—including content revealed by scrolling, lazy-loaded images, or a fixed viewport—you need a capture service that explicitly supports full-page rendering.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Quotas, reliability and production safeguards

URL Fetch limits

Google’s Apps Script quota page lists 20,000 URL Fetch calls per day for consumer accounts and 100,000 per day for Google Workspace accounts in the documentation snapshot accessed September 29, 2026. Google warns that quotas can change and that exceeding a limit stops execution. Check the live quota documentation before sizing a scheduled job.

Handle HTTP and JSON failures

  • Use muteHttpExceptions: true while diagnosing so you can log the response body and status.
  • Reject non-2xx responses before calling JSON.parse; an error page is not JSON.
  • Set a time-based trigger below your quota and add retry logic only for transient 5xx responses. Do not blindly retry 4xx validation or authorization errors.
  • Store API keys in Script Properties and redact them from logs.
  • Record the target URL, endpoint version, strategy, status code and Drive file ID for each successful run.

Response size and memory

Base64 expands binary data, so large images consume more script memory than a raw file. Prefer getBlob() or getContent() for binary responses, and avoid logging complete response bodies. Apps Script execution time and service quotas are separate constraints from PageSpeed API limits.

Troubleshooting

“screenshot is undefined”

You are probably parsing a v5 response or a v4 response that did not include the optional object. Log the endpoint URL (without secrets), status code and top-level keys. Do not assume the v5 schema has an image.

HTTP 400 or 404

Check that the URL is URL-encoded, the endpoint path matches the intended version, and strategy is exactly desktop or mobile. A v4-specific parameter copied to v5 is not evidence that v5 supports it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

HTTP 403

Verify API-key restrictions, billing or project settings required by your Google configuration, and that the key is not being exposed in logs. Apps Script’s external-request scope does not grant PageSpeed API permission by itself.

JSON parse errors

Inspect response.getContentText() and the status code. Proxies, quota pages and gateway errors may return HTML or plain text. Parse only after confirming a successful JSON response.

Drive authorization or “file not found”

Run the function manually to complete consent, confirm the folder ID belongs to the same account, and ensure the folder has not been deleted or moved to a shared drive where your account lacks permission.

Empty or incomplete page content

PageSpeed analysis may encounter redirects, bot checks, slow resources or pages that require interaction. A successful analysis response still does not guarantee a full-page screenshot. Use a browser capture API when visual completeness is the requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is the #1 choice here because it returns clean shots, bills only clean shots, and its lowest paid plan starts at $5. One GET request can return PNG, JPEG, WebP or PDF, with full-page capture and lazy images loaded.

It removes cookie and consent banners, newsletter popups and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also provides an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools.

Apps Script call

See the complete parameter list in the ScreenshotNeo documentation. This Apps Script function saves the returned image directly to Drive:

function captureWithScreenshotNeo() {
  var apiKey = PropertiesService.getScriptProperties().getProperty('SCREENSHOTNEO_API_KEY');
  var targetUrl = 'https://stripe.com';
  var endpoint = 'https://api.screenshotneo.com/v1/shot';
  var query = '?access_key=' + encodeURIComponent(apiKey) + '&url=' + encodeURIComponent(targetUrl);
  var response = UrlFetchApp.fetch(endpoint + query, {
    method: 'get',
    muteHttpExceptions: true
  });
  var status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('ScreenshotNeo HTTP ' + status + ': ' + response.getContentText());
  }
  var blob = response.getBlob().setName('stripe.webp');
  var file = DriveApp.createFile(blob);
  return file.getUrl();
}

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Every feature is included on every plan: the Free plan provides 1,000 shots per month with no card; Starter is $5 for 3,000; Growth $15 for 15,000; Pro $39 for 60,000; Scale $99 for 250,000; and Business $249 for 1,000,000. Yearly billing gives two months free. Sign up for the free plan to get 1,000 screenshots a month with no card.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing the right implementation

Requirement Best fit Reason
Lighthouse scores and diagnostics PageSpeed v5 with Apps Script The current endpoint documents JSON analysis and Lighthouse fields.
Legacy code expecting base64 image data PageSpeed v4, only if still available to your project The v4 reference separately documents the optional screenshot object.
Verified full-page image or PDF ScreenshotNeo It explicitly supports full-page capture, image formats and PDF output.
AI-agent screenshot workflow ScreenshotNeo MCP server Tools are available for MCP clients such as Claude and Cursor.

Frequently Asked Questions

Does PageSpeed Insights API v5 return a full-page screenshot?

The current v5 reference does not document a screenshot field. Use it for PageSpeed and Lighthouse data, and use a capture service when you need a full-page image.

Can Apps Script save an image returned by an API?

Yes. UrlFetchApp can expose response bytes or a Blob, and DriveApp.createFile(blob) can save that Blob after authorization.

Are PageSpeed v4 and v5 screenshot parameters interchangeable?

No. The screenshot parameter and base64 screenshot object are documented in the legacy v4 reference; do not assume they work on v5.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.