Use this file to discover all available pages before exploring further.
Fetch lets you grab the content of any URL through Browserbase’s infrastructure as a lightweight complement to browser sessions. Use it for quick page retrievals where you don’t need interactivity, or ask Browserbase to turn the response into markdown or structured JSON for downstream agents and pipelines.Requests are routed through Browserbase with a real browser User-Agent by default, and you can optionally configure custom headers, proxies, redirects, and SSL behavior.
Fetch doesn’t execute JavaScript and has a 5 MB content limit. Fetch also can’t convert PDF responses to markdown or structured JSON. For pages that require JavaScript rendering or are larger than 5 MB, use a browser session instead.
Fetch without a format flag returns the page content directly, which makes it the cheapest option. This is normal Fetch.When you set format: "markdown" or format: "json", Browserbase converts the page before returning it. This is Fetch Extract. That conversion makes Fetch Extract more expensive than normal Fetch, and Browserbase prices it separately in the pricing table.
Use the same endpoint and SDK methods when you want cleaner output for LLMs or downstream systems.
SDK support for format: "markdown" and format: "json" is available in the Node SDK starting in @browserbasehq/sdkv2.12.0 and in the Python SDK starting in browserbasev1.11.0.
The page content. Raw and markdown responses return strings. JSON extraction returns a structured object matching your schema. Binary content is returned as a Base64-encoded string when encoding is base64.
contentType
string
The MIME type of the response (e.g. text/html; charset=utf-8).
encoding
string
Either utf-8 for text content or base64 for binary content.
Fetch returns structured errors when something goes wrong.
Content too large (502)
If the response body exceeds 5 MB, you’ll receive a 502 error:
{ "statusCode": 502, "error": "Bad Gateway", "message": "The response body exceeded the maximum allowed size of 5MB. Use a browser session to handle large responses."}
To handle this, catch the error and fall back to a browser session:
Node.js
Python
SDK
import Browserbase from "@browserbasehq/sdk";import { chromium } from "playwright-core";const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });try { const response = await bb.fetchAPI.create({ url: "https://httpbin.org/", }); console.log(response.content);} catch (err: any) { if (err?.statusCode === 502) { // Fall back to a full browser session for large pages const session = await bb.sessions.create(); const browser = await chromium.connectOverCDP(session.connectUrl); const page = browser.contexts()[0].pages()[0]; await page.goto("https://httpbin.org/"); const content = await page.content(); console.log(content); await browser.close(); }}
SDK
from browserbase import Browserbasefrom playwright.sync_api import sync_playwrightimport osbb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])try: response = bb.fetch_api.create(url="https://httpbin.org/") print(response.content)except Exception as err: if getattr(err, "status_code", None) == 502: # Fall back to a full browser session for large pages session = bb.sessions.create() with sync_playwright() as p: browser = p.chromium.connect_over_cdp(session.connect_url) page = browser.contexts[0].pages[0] page.goto("https://httpbin.org/") print(page.content()) browser.close()
Gateway Timeout (504)
The target page must respond within 60 seconds. If it takes longer, you’ll receive a timeout error:
{ "statusCode": 504, "error": "Gateway Timeout", "message": "The requested content took more than 60 seconds to fetch. Please try again or use a browser session for complex pages."}
If you consistently hit this timeout, consider using a browser session instead — browser sessions support long-running page loads and JavaScript-heavy content.
SSL Error (502)
If the target site has a TLS certificate issue (self-signed, expired, etc.), you’ll see an SSL error:
{ "statusCode": 502, "error": "SSL Error", "message": "TLS certificate verification failed; to bypass certificate verification, set the allowInsecureSsl option in your request"}
To resolve this, set allowInsecureSsl to true in your request:
Only enable allowInsecureSsl when you trust the target site. Disabling certificate verification removes a layer of protection against man-in-the-middle attacks.
Content size: 5 MB maximum. Responses exceeding this limit return a 502 error. See Content Too Large for how to detect and fall back to a browser session.
Timeout: 60 seconds. Pages that take longer to respond will return a 504 error.
No JavaScript execution: Fetch never renders the page in a browser. For pages that require JavaScript rendering, use a browser session.
No PDF conversion: Fetch can’t convert PDF responses to markdown or structured JSON. For PDF content, use a browser session.