Page speed (one lab measurement)
POST /api/page-speedOne lab measurement of a public URL, loaded once in headless Chromium.
Details
Returns navigation timings (TTFB, DOMContentLoaded, load), Web Vitals (LCP, FCP, CLS, total blocking time), transfer bytes, request count, the 5 heaviest resources, render-blocking scripts and styles, console errors and an opportunities array. Each opportunity names the element (a CSS selector) or URL, what was measured and the bytes or milliseconds behind it: the LCP element, unsized or oversized images, fonts, uncompressed or uncached responses, requests to other hosts, long tasks and layout shifts. A single lab measurement from one server location under shared load, with no throttling, not field data from real users; the answer says so in its measurement field. Deterministic code, no model. Body: {"url":"https://…","device":"mobile"|"desktop"?}.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | Public http(s) URL to load and measure Also accepted as link, uri, href, page. The example sends https://agent402.tools. |
device | string (one of: mobile, desktop) | no | Viewport profile: mobile (412x823, touch) or desktop (1350x940). Default mobile One of mobile, desktop. |
Example request
curl -i -X POST https://agent402.tools/api/page-speed \
-H "Content-Type: application/json" \
-d '{"url":"https://agent402.tools","device":"mobile"}'Watch a call get paid
POST /api/page-speed$0.01 USDCPAYMENT-SIGNATUREon 14 chains200 OKAgent402-ReceiptEd25519Example response
{
"url": "https://agent402.tools",
"finalUrl": "https://agent402.tools/",
"status": 200,
"device": "mobile",
"viewport": {
"width": 412,
"height": 823
},
"networkIdle": true,
"timings": {
"ttfbMs": 176,
"domContentLoadedMs": 443,
"loadMs": 1090
},
"webVitals": {
"lcpMs": 380,
"lcpElement": "p",
"fcpMs": 380,
"cls": 0,
"totalBlockingTimeMs": 0,
"longTaskCount": 0
},
"transfer": {
"totalBytes": 582458,
"requestCount": 43,
"failedRequests": 1
},
"heaviestResources": [
{
"url": "https://agent402.tools/",
"type": "document",
"bytes": 37659
}
],
"heaviestResourcesPartial": {
"returned": 1,
"matched": 41,
"complete": false,
"truncated": true
},
"renderBlocking": [
{
"url": "https://agent402.tools/js/theme-init.js?v=a017322",
"type": "script",
"durationMs": 139
}
],
"renderBlockingPartial": {
"returned": 1,
"matched": 1,
"complete": true,
"truncated": false
},
"consoleErrors": [],
"consoleErrorsPartial": {
"returned": 0,
"matched": 0,
"complete": true,
"truncated": false
},
"measurement": {
"kind": "lab-single-run",
"runs": 1,
"source": "one load in a headless Chromium from one server location, on shared infrastructure, with no network or CPU throttling",
"fieldData": false,
"lighthouseScore": false,
"note": "A single measurement from one server location under shared load. It is a single lab measurement, not field data from real users; repeat the call and compare runs before drawing conclusions."
},
"untrustedContent": true,
"opportunities": [
{
"id": "lcp-element",
"element": "div > div.hm-hero > div.ml-stagger:nth-of-type(1) > p.hm-lede",
"url": null,
"detail": "The largest contentful paint at 380 ms was <p>, a text block, 380x132 px, set in the web font Geist.",
"estimate": {
"ms": 380
},
"tag": "p",
"sizePx": 47488,
"lazyLoaded": null,
"webFont": "Geist"
},
{
"id": "lcp-text-behind-web-font",
"element": "div > div.hm-hero > div.ml-stagger:nth-of-type(1) > p.hm-lede",
"url": "https://agent402.tools/fonts/geist-300-latin.woff2",
"detail": "The LCP text is set in the web font Geist, fetched from https://agent402.tools/fonts/geist-300-latin.woff2; the paint waited for that font.",
"estimate": {
"bytes": 13920,
"ms": 118
}
},
{
"id": "render-blocking-script",
"element": null,
"url": "https://agent402.tools/js/theme-init.js?v=a017322",
"detail": "Script in <head> without async or defer; the parser waited for it (139 ms to fetch). Add defer, or async when order does not matter.",
"estimate": {
"bytes": 453,
"ms": 139
}
},
{
"id": "short-cache-lifetime",
"element": null,
"url": "https://agent402.tools/js/home-hero.js",
"detail": "script of 5.1 KB cached for 300 s (max-age=300). Give static assets a long max-age and change the URL when they change.",
"estimate": {
"bytes": 5243
}
},
{
"id": "uncompressed-response",
"element": null,
"url": "https://agent402.tools/x-header.svg",
"detail": "image/svg+xml response of 1.3 KB sent with no content-encoding. Serve it with gzip or brotli.",
"estimate": {
"bytes": 1379
}
},
{
"id": "transfer-by-type",
"element": null,
"url": null,
"detail": "Transferred 568.8 KB: script 327.5 KB in 12 requests, font 147.8 KB in 12 requests, image 50 KB in 14 requests, document 41.6 KB in 2 requests, fetch 1.9 KB in 2 requests, eventsource 0 KB in 1 request.",
"estimate": {
"bytes": 582458
},
"byType": {
"document": {
"bytes": 42612,
"requests": 2
},
"script": {
"bytes": 335322,
"requests": 12
},
"font": {
"bytes": 151385,
"requests": 12
},
"fetch": {
"bytes": 1904,
"requests": 2
},
"image": {
"bytes": 51235,
"requests": 14
},
"eventsource": {
"bytes": 0,
"requests": 1
}
}
},
{
"id": "large-resource",
"element": null,
"url": "https://agent402.tools/e/static/array.js",
"detail": "script of 103.7 KB transferred (application/javascript).",
"estimate": {
"bytes": 106160
},
"type": "script"
},
{
"id": "third-party-host",
"element": null,
"url": "www.googletagmanager.com",
"detail": "1 request to www.googletagmanager.com (176.9 KB), a host outside agent402.tools.",
"estimate": {
"bytes": 181162
},
"requests": 1
}
],
"opportunitiesPartial": {
"returned": 8,
"matched": 29,
"complete": false,
"truncated": true
}
}| Field | Type | Always present | In the example |
|---|---|---|---|
url | string | yes | https://agent402.tools |
finalUrl | string | yes | https://agent402.tools/ |
status | number | yes | 200 |
device | string | yes | mobile |
viewport | object | yes | 2 fields: width, height |
networkIdle | boolean | yes | true |
timings | object | yes | 3 fields: ttfbMs, domContentLoadedMs, loadMs |
webVitals | object | yes | 6 fields: lcpMs, lcpElement, fcpMs, cls, totalBlockingTimeMs and 1 more |
transfer | object | yes | 3 fields: totalBytes, requestCount and 1 more |
heaviestResources | array of objects | yes | 1 item in the example |
heaviestResourcesPartial | object | yes | 4 fields: returned, matched, complete, truncated |
renderBlocking | array of objects | yes | 1 item in the example |
renderBlockingPartial | object | yes | 4 fields: returned, matched, complete, truncated |
consoleErrors | array | yes | 0 items in the example |
consoleErrorsPartial | object | yes | 4 fields: returned, matched, complete, truncated |
measurement | object | yes | 6 fields: kind, runs, source, fieldData, lighthouseScore, note |
untrustedContent | boolean | yes | true |
opportunities | array of objects | yes | 8 items in the example |
opportunitiesPartial | object | yes | 4 fields: returned, matched, complete, truncated |
From an MCP client
catalog.call {
"slug": "page-speed",
"params": {
"url": "https://agent402.tools",
"device": "mobile"
}
}Hosted connector (https://agent402.tools/mcp): paid in the call. Stdio package (npx -y agent402-mcp@0.18.0): pays from a wallet or AGENT402_CREDITS_KEY.
Errors and behavior
- Pay $0.01 per call over x402 or MPP. Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - Required:
url; a rejected input answers 4xx witherror,tool,expected,requiredandexample. - On this route, a call ending in any status of 400 or above is not charged over x402, MPP or a credits key. A Tempo push credential pays before the call; a failure is a refund owed.
- A bodyless
GETorHEADreturns the same 402 quote. - An
Idempotency-Keyreplays the first 200 uncharged (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.01" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/page-speed", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://agent402.tools",
"device": "mobile"
}),
});Get a wallet or run npx -y agent402-mcp@0.18.0 wallet new.
The quote (Python)
import base64, json, urllib.error, urllib.request
req = urllib.request.Request("https://agent402.tools/api/page-speed", method="POST", data="{\"url\":\"https://agent402.tools\",\"device\":\"mobile\"}".encode(), headers={"Content-Type": "application/json"})
try:
urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]]) # the price, per chain, in base units