---
title: "Web Search"
method: POST
path: "/web/search"
tags: ["Web Scraping"]
---

# Web Search

`POST /web/search`

Search the web and optionally scrape each result to Markdown in one round-trip.

## Request body

- object
  - `query` string, required — Search query. Accepts natural language as well as Google-style search operators such as `site:`, `-site:`, `inurl:`, `intitle:`, quoted phrases, and `OR`.
  - `numResults` integer — Number of results to request and return (10–100). Defaults to 10.
  - `includeDomains` string[] — Allowlist — only return results from these domains. Example: ["arxiv.org", "github.com"].
  - `excludeDomains` string[] — Blocklist — drop results from these domains. Example: ["pinterest.com", "reddit.com"].
  - `freshness` 'last_24_hours' | 'last_week' | 'last_month' | 'last_year' — Restrict results to content published within this window.
  - `country` 'af' | 'al' | 'dz' | 'as' | 'ad' | 'ao' | 'ai' | 'aq' | 'ag' | 'ar' | 'am' | 'aw' | 'au' | 'at' | 'az' | 'bs' | 'bh' | 'bd' | 'bb' | 'by' | 'be' | 'bz' | 'bj' | 'bm' | 'bt' | 'bo' | 'ba' | 'bw' | 'bv' | 'br' | 'io' | 'bn' | 'bg' | 'bf' | 'bi' | 'kh' | 'cm' | 'ca' | 'cv' | 'ky' | 'cf' | 'td' | 'cl' | 'cn' | 'cx' | 'cc' | 'co' | 'km' | 'cg' | 'cd' | 'ck' | 'cr' | 'ci' | 'hr' | 'cu' | 'cy' | 'cz' | 'dk' | 'dj' | 'dm' | 'do' | 'ec' | 'eg' | 'sv' | 'gq' | 'er' | 'ee' | 'et' | 'fk' | 'fo' | 'fj' | 'fi' | 'fr' | 'gf' | 'pf' | 'tf' | 'ga' | 'gm' | 'ge' | 'de' | 'gh' | 'gi' | 'gr' | 'gl' | 'gd' | 'gp' | 'gu' | 'gt' | 'gn' | 'gw' | 'gy' | 'ht' | 'hm' | 'va' | 'hn' | 'hk' | 'hu' | 'is' | 'in' | 'id' | 'ir' | 'iq' | 'ie' | 'il' | 'it' | 'jm' | 'jp' | 'jo' | 'kz' | 'ke' | 'ki' | 'kp' | 'kr' | 'kw' | 'kg' | 'la' | 'lv' | 'lb' | 'ls' | 'lr' | 'ly' | 'li' | 'lt' | 'lu' | 'mo' | 'mk' | 'mg' | 'mw' | 'my' | 'mv' | 'ml' | 'mt' | 'mh' | 'mq' | 'mr' | 'mu' | 'yt' | 'mx' | 'fm' | 'md' | 'mc' | 'mn' | 'ms' | 'ma' | 'mz' | 'mm' | 'na' | 'nr' | 'np' | 'nl' | 'an' | 'nc' | 'nz' | 'ni' | 'ne' | 'ng' | 'nu' | 'nf' | 'mp' | 'no' | 'om' | 'pk' | 'pw' | 'ps' | 'pa' | 'pg' | 'py' | 'pe' | 'ph' | 'pn' | 'pl' | 'pt' | 'pr' | 'qa' | 're' | 'ro' | 'ru' | 'rw' | 'sh' | 'kn' | 'lc' | 'pm' | 'vc' | 'ws' | 'sm' | 'st' | 'sa' | 'sn' | 'rs' | 'sc' | 'sl' | 'sg' | 'sk' | 'si' | 'sb' | 'so' | 'za' | 'gs' | 'es' | 'lk' | 'sd' | 'sr' | 'sj' | 'sz' | 'se' | 'ch' | 'sy' | 'tw' | 'tj' | 'tz' | 'th' | 'tl' | 'tg' | 'tk' | 'to' | 'tt' | 'tn' | 'tr' | 'tm' | 'tc' | 'tv' | 'ug' | 'ua' | 'ae' | 'gb' | 'us' | 'um' | 'uy' | 'uz' | 'vu' | 've' | 'vn' | 'vg' | 'vi' | 'wf' | 'eh' | 'ye' | 'zm' | 'zw' — Two-letter ISO 3166-1 alpha-2 country code to localize results to a specific country (maps to Google's `gl` parameter). Example: "us", "gb", "de".
  - `queryFanout` boolean — Expand the query into multiple parallel variants for broader recall.
  - `markdownOptions` object — Inline Markdown scraping for each result. Set `enabled: true` to activate.
    - `enabled` boolean — Scrape each result to Markdown. Off by default to keep search cheap and fast.
    - `includeLinks` boolean — Keep hyperlinks in the Markdown.
    - `includeImages` boolean — Emit image references in the Markdown.
    - `shortenBase64Images` boolean — Truncate inline base64 image payloads to keep responses small.
    - `useMainContentOnly` boolean — Strip nav, header, footer, and sidebar — keep only the primary article content.
    - `pdf` object — PDF handling. Use start/end to bound text extraction and OCR to a page range.
      - `shouldParse` boolean — Parse PDF URLs. When false, PDF results are skipped with WEBSITE_ACCESS_ERROR.
      - `start` integer — First PDF page to parse (1-based, inclusive). Defaults to page 1.
      - `end` integer — Last PDF page to parse (1-based, inclusive). Defaults to the final page. Must be >= start.
    - `includeFrames` boolean — Render iframe contents into the Markdown.
    - `maxAgeMs` integer — Cache TTL in ms for scraped Markdown keyed by URL + options. Default 1 day, max 30 days. Set to 0 to force a fresh scrape.
    - `waitForMs` integer — Extra wait after page load before rendering, in ms (0–30000). Useful for JS-heavy pages.
    - `timeoutMS` integer — Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).
  - `timeoutMS` integer — Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).
  - `tags` string[] — Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.

## Response `200`

Search succeeded. Results are ordered by relevance.

- object
  - `results` object[], required
    - `url` string, required — Canonical result URL.
    - `title` string, required — Page title.
    - `description` string, required — Snippet excerpt from the page.
    - `relevance` 'high' | 'medium' | 'low', required — Relevance to the original query.
    - `markdown` object, required — Markdown scrape status and content for this result.
      - `markdown` string, nullable, required — GFM Markdown of the page. Null unless markdownOptions.enabled is true and scraping succeeded.
      - `code` 'SUCCESS' | 'NOT_REQUESTED' | 'TIMEOUT' | 'CONTENT_TOO_LARGE' | 'WEBSITE_ACCESS_ERROR' | 'ERROR', required — Per-result scrape outcome. Inspect this before reading `markdown`.
  - `query` string, required — Echo of the original query (useful when fanout was enabled).
  - `key_metadata` KeyMetadata — Metadata about the API key used for the request. Included in every response whenever a valid API key is provided, even when the response status is not 200.
    - `credits_consumed` integer, required — The number of credits consumed by this request.
    - `credits_remaining` integer, required — The number of credits remaining for your organization after this request.

## Other responses

- `400` — Bad request - Invalid parameters
- `401` — Unauthorized - Invalid or missing API key
- `403` — Forbidden - Insufficient permissions or usage limit exceeded
- `408` — Request timeout
- `429` — Rate limit exceeded
- `500` — Internal server error

---

[API](https://skmtc.net/context/apis/context-dev.md) · [All operations](https://skmtc.net/context/apis/context-dev/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/context/context-dev/versions/3c6a01ba967f/schema)
