This is not an HTTP request: the page is loaded and rendered, so what comes back is what a visitor would see — including whatever JavaScript built. That is also why there is no client-side timeout on the call.
Parameters
urlstringrequiredThe page. It must be public — see below.
timeoutinteger20000Milliseconds. Clamped between 5000 and 60000.
screenshotbooleanfalseAlso capture the image, in the same credit.
typestringpageUse screenshot to return only an image; use page with screenshot: true to return text and image together.
viewport{ width, height }1280 × 720Responsive CSS viewport. For type: "screenshot", explicitly setting it returns viewport-only pixels at that size when deviceScaleFactor: 1.
deviceScaleFactor1 | 2 | 31Raster density multiplier; 2× and 3× multiply output pixel dimensions.
waitinteger1000Extra visual settling time, 0–10000 ms.
includestring[]Attach console, network, links, forms, snapshot, or screenshot.
Returns
{
ok: true,
type: "page",
title: "Example Domain",
url: "https://example.com/",
mimeType: "text/html; charset=utf-8",
timedOut: false,
markdown: "# Example Domain\n\nThis domain is for use in…",
elements: { head: "<meta …>", body: "<main>…</main>", css: "body{…}" },
console: [{ level: "error", message: "Uncaught TypeError…", source: "…/app.js", location: "14:9" }],
sources: [{ url: "https://example.com/app.js", method: "GET", status: 200,
type: "script", mimeType: "text/javascript", duration: 84 }],
performance: {
navigation: { /* timings */ },
paints: [ /* first paint, first contentful paint */ ],
resources: { count: 24, totalBytes: 418_204, totalDuration: 1_902,
slowest: [{ url: "…", duration: 840, transferSize: 120_400 }] }
},
security: {
https: true, protocol: "https",
tls: { version: "TLS 1.3", cipher: "…", certificate: { subject, issuer, validFrom, validTo } },
headers: { contentSecurityPolicy, strictTransportSecurity, xFrameOptions,
xContentTypeOptions, referrerPolicy },
mixedContent: [], cookies: { total: 3, secure: 3, httpOnly: 2, list: [ … ] },
warnings: []
},
captureMs: 1_640,
cached: false,
creditsUsed: 1,
timing: { durationMs: 1_902 }
}{
"ok": True,
"type": "page",
"title": "Example Domain",
"url": "https://example.com/",
"mimeType": "text/html; charset=utf-8",
"timedOut": False,
"markdown": "# Example Domain\n\nThis domain is for use in…",
"elements": {"head": "<meta …>", "body": "<main>…</main>", "css": "body{…}"},
"console": [{"level": "error", "message": "Uncaught TypeError…", "source": "…/app.js", "location": "14:9"}],
"sources": [{"url": "https://example.com/app.js", "method": "GET", "status": 200,
"type": "script", "mimeType": "text/javascript", "duration": 84}],
"performance": {
"navigation": {}, # timings
"paints": [], # first paint, first contentful paint
"resources": {"count": 24, "totalBytes": 418_204, "totalDuration": 1_902,
"slowest": [{"url": "…", "duration": 840, "transferSize": 120_400}]},
},
"security": {
"https": True, "protocol": "https",
"tls": {"version": "TLS 1.3", "cipher": "…", "certificate": {"subject": ..., "issuer": ..., "validFrom": ..., "validTo": ...}},
"headers": {"contentSecurityPolicy": ..., "strictTransportSecurity": ..., "xFrameOptions": ...,
"xContentTypeOptions": ..., "referrerPolicy": ...},
"mixedContent": [], "cookies": {"total": 3, "secure": 3, "httpOnly": 2, "list": []},
"warnings": [],
},
"captureMs": 1_640,
"cached": False,
"creditsUsed": 1,
"timing": {"durationMs": 1_902},
}markdown is the field you usually want
The readable content, with the navigation, the scripts and the hidden elements taken out. It is what you pass to a model: elements.body is the HTML, which is several times larger for the same meaning.
The rest is for diagnosing a page
| Field | Answers |
|---|---|
console | What the page's own code complained about. Up to 500 entries. |
sources | Every request it made, with its method, status, type and duration. Up to 500. A request that failed has status: 0 and a failure — successful ones carry no such field. |
performance.resources.slowest | The five requests that cost the most time. |
security.tls | The certificate and the protocol version. |
security.headers | Five headers that decide what a browser allows. |
security.mixedContent | Insecure sub-resources on a secure page. |
security.warnings | Mixed content and certificate failures, already gathered. |
const page = await api.tools.fetch({ url: "https://example.com" });
const broken = page.console.filter((l) => l.level === "error");
const failed = page.sources.filter((s) => s.failure);
const slow = page.performance.resources.slowest;
if (page.security.warnings.length) console.warn(page.security.warnings);page = api.tools.fetch({"url": "https://example.com"})
broken = [line for line in page["console"] if line["level"] == "error"]
failed = [s for s in page["sources"] if s.get("failure")]
slow = page["performance"]["resources"]["slowest"]
if page["security"]["warnings"]:
print(page["security"]["warnings"])The page and its image, one credit
screenshot: true adds the image to a page capture without a second call and without a second credit. The flag is part of the cache key, so asking for it on a page captured without it does a fresh capture rather than handing back one with no image.
const page = await api.tools.fetch({ url, screenshot: true });
// page.screenshot → { mimeType: "image/jpeg", base64: "…" } full page, JPEG
// A capture that could not be taken arrives as { error: "…" } — the page is still therepage = api.tools.fetch({"url": url, "screenshot": True})
# page["screenshot"] → {"mimeType": "image/jpeg", "base64": "…"} full page, JPEG
# A capture that could not be taken arrives as {"error": "…"} — the page is still theretimedOut does not mean failed
When the ceiling is reached, what had loaded is captured and timedOut is true. A long-polling page or an endless animation would otherwise cost a credit for nothing — here you get the content and the warning.
Private addresses are refused
The address is checked before anything is opened: the scheme must be http or https, and the host must resolve to a public address. A redirect does not escape the check.
That matters most when the URL comes from a model or from a page's own text: it is the difference between reading the web and being asked to read something that is not meant to be read.
What is charged
| Situation | creditsUsed |
|---|---|
| A capture | 1 |
| The same page within the hour, same flags | 0 — cached: true |
| The capture failed | 0 — refunded, then fetch_failed |
Errors
| Code | Status | When |
|---|---|---|
| url_required | 400 | url is missing or is not a string. |
| url_refusee | 400 | The address is refused by the guard. |
| invalid_url | 400 | Not a usable address. |
| fetch_failed | 502 | The page could not be opened. The credit is given back first. |
| NotEnoughCredits | 402 | The balance will not cover one credit. |