Skip to main content
This guide shows how to use the Web APIs to fetch pages, search the web, and extract structured data. It also documents the most important parameters for advanced use cases.
You can also see dedicated pages for Fetch and Search. For full schemas, see the API Reference.

Fetching a web page

With just a URL, you can extract page contents in your chosen formats using the /api/web/fetch endpoint.

Fetch Response

The fetch response includes a jobId, overall status, and the outputs under data:

Output Formats

The outputs.formats array specifies what data to return. You can mix simple strings with output objects:

Screenshot with Options

Screenshot cropping rules:
  • fullPage and cropToContent are mutually exclusive.
  • If both cropToContentMaxHeight and cropToContentMinHeight are set, max must be ≥ min.
  • Crop dimensions must be between 100 and 8000 pixels.

JSON Extraction with Schema


Fetch Options

The Fetch API supports comprehensive configuration for controlling browser behavior, navigation, and outputs.
string
required
The URL of the page to fetch.
string
"none" | "auto" | "ultra" — controls the default proxy/stealth posture.
Array<string | object>
Output formats to return (e.g. ["markdown", "links"]), plus structured outputs like {"type":"json","schema":...}.
string
"none" | "basic" | "advanced" — Sanitizes output for easier downstream parsing.
string[]
default:"[]"
CSS selectors to include. Only matching elements are returned.
string[]
default:"[]"
CSS selectors to exclude from output.
object
Pre-seed localStorage / sessionStorage as key/value pairs.
string
Load condition: "load", "domcontentloaded", or "networkidle".
number
default:"0"
Milliseconds to wait after navigation completes before collecting outputs (0–30000).
number
Max time (ms) to wait for navigation (1–60000).
number
Cache control for fetch results. Set 0 to bypass cache reads.
object
Localize via proxy location (country, state, city). If set, proxy is enabled automatically.
string
Reuse an existing browser profile.
string
Enable CAPTCHA solving.
object
Set viewport dimensions (width, height).

Example: Fetch with Advanced Options


Searching the web

Use the Search API to query the web and get structured results—titles, URLs, and descriptions—ready to use in your application.

Search Response

The response includes search results with titles, URLs, and descriptions:

Search Options

The Search API supports pagination, location-based results, and advanced filtering.
string
required
The search query (max 500 characters).
number
Page number for pagination (1-100, default: 1).
number
Cache control—cached results older than this are treated as stale. Set to 0 to bypass cache reads.
string
ISO-2 country code (e.g., "US", "GB", "DE").
string
State code (for supported countries).
string
City name (max 200 characters).

Search Filters

Advanced search filters allow you to refine your search results:
boolean
Wrap query in quotes for exact match.
boolean
Use semantic search.
string[]
Terms to exclude from results.
string[]
Terms to prioritize in results.
string
Filter by file type: pdf, doc, docx, xls, xlsx, ppt, pptx, html.
string
Limit results to a specific site.
string
Exclude results from a specific site.
string
Search term must appear in page title.
string
Search term must appear in URL.
exactPhrase and semanticPhrase cannot both be true.

Example: Search with Filters


Combining Search and Fetch

A common pattern is to search for pages and then fetch their content. Here’s how to do it:

Browser & Stealth

Both Fetch and Search APIs support stealth configuration for bypassing anti-bot measures:
  • Stealth (stealth): "none" | "auto" | "ultra"
  • Location (browser.location): { country, state, city } (enables proxy automatically)
  • CAPTCHA (browser.solveCaptchas): boolean
  • Profiles (browser.profileId): reuse an existing profile
  • Screen (browser.screen): { width, height }
Using proxy and CAPTCHA solving increases latency. Enable only when needed.
Using a custom location costs 10 credits per search. Without a location specified, searches default to US and cost 5 credits.

Best Practices

Caching

Use cache.maxAgeSeconds (Fetch) or maxAgeSeconds (Search) to control caching behavior:
  • Set to 3600 (1 hour) for frequently updated content
  • Set to 86400 (24 hours) for static content
  • Set to 0 to always fetch fresh data

Error Handling

Always check the status field in responses:

Rate Limiting

The Web APIs are rate-limited. Use the SDK’s built-in retry logic or implement your own exponential backoff strategy.

Output Sanitization

Use outputs.sanitize to clean up HTML/Markdown:
  • "none": No sanitization (fastest)
  • "basic": Remove scripts, styles, and common noise
  • "advanced": Aggressive cleaning for LLM processing

Selector Filtering

Use includeSelectors and excludeSelectors to focus on specific content: