Skip to content

Page speed (one lab measurement)

$0.01 per callUSDC via x402POST /api/page-speed

One lab measurement of a public URL, loaded once in headless Chromium.

Category: Web & documentsTags: browser performance web-vitals lcp cls page-speed ttfb audit

Try in playground →

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

NameTypeRequiredDescription
urlstringyesPublic http(s) URL to load and measure Also accepted as link, uri, href, page. The example sends https://agent402.tools.
devicestring (one of: mobile, desktop)noViewport 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

RequestPOST /api/page-speed
402$0.01 USDC
SignPAYMENT-SIGNATURE
Settleon 14 chains
Answer200 OK
ReceiptAgent402-ReceiptEd25519

Example 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
  }
}
FieldTypeAlways presentIn the example
urlstringyeshttps://agent402.tools
finalUrlstringyeshttps://agent402.tools/
statusnumberyes200
devicestringyesmobile
viewportobjectyes2 fields: width, height
networkIdlebooleanyestrue
timingsobjectyes3 fields: ttfbMs, domContentLoadedMs, loadMs
webVitalsobjectyes6 fields: lcpMs, lcpElement, fcpMs, cls, totalBlockingTimeMs and 1 more
transferobjectyes3 fields: totalBytes, requestCount and 1 more
heaviestResourcesarray of objectsyes1 item in the example
heaviestResourcesPartialobjectyes4 fields: returned, matched, complete, truncated
renderBlockingarray of objectsyes1 item in the example
renderBlockingPartialobjectyes4 fields: returned, matched, complete, truncated
consoleErrorsarrayyes0 items in the example
consoleErrorsPartialobjectyes4 fields: returned, matched, complete, truncated
measurementobjectyes6 fields: kind, runs, source, fieldData, lighthouseScore, note
untrustedContentbooleanyestrue
opportunitiesarray of objectsyes8 items in the example
opportunitiesPartialobjectyes4 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

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

Related tools