# Search

Web results, optionally with the text of the top pages.

Searches the web, or one vertical chosen with `type`. Every `url` is the address of the destination page itself. With `content`, the same response carries the cleaned text of the top pages, so a model does not need a second call to read them.

Page 1 of a `type: web` search that has results may carry `knowledge_panel`: the encyclopedia card of the person, place, organization or thing the query names, the same object as `panel` of [knowledge](https://websearch.fast/docs/knowledge). It is included in the search price and adds no unit. A search without a panel costs the same.

`type: web` and `content` are available. The other types (`news`, `images`, `videos`, `places`, `shopping`, `scholar`, `patents`) and `answer` are planned; until each ships, a call that asks for it gets `501 api_not_implemented`.

Operators inside `q` (`site:`, `-site:`, `"exact phrase"`, `-term`, `OR`, `before:YYYY-MM-DD`, `after:YYYY-MM-DD`) are parsed into the fields below and echoed in `input.operators`. An operator that conflicts with an explicit field returns `400 invalid_request`.

### What is charged

Charged when at least one result comes back. An empty result set returns `results: []` with the warning `no_results` and is free, as is every error. Pages that could not be read for `content` are free; when fewer pages than asked were read, the warning `content_partial` says how many.

Units: `search_web`, `content_page`. `usage.items` in the response lists them.

## Request

```
POST https://api.websearch.fast/v1/web/search
```

`type: web` and `content` are available; other types and `answer` are planned.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `q` | string | yes | The query. Operators: site:, -site:, quotes, -term, OR, before:, after:; filetype:, intitle:, inurl: (planned). 1 to 2048 characters. |
| `type` | string |  | The vertical. Types not shipped yet return 501 api_not_implemented. One of `web`, `news`, `images`, `videos`, `places`, `shopping`, `scholar`, `patents`. Default `web`. |
| `country` | string |  | ISO 3166-1 alpha-2 country code, case-insensitive. |
| `language` | string |  | BCP 47 language tag. At most 12 characters. |
| `location` | string |  | Place to rank for, as text. 2 to 256 characters. |
| `near` | object |  | places only; exclusive with location. |
| `near.lat` | number | yes | -90 to 90. |
| `near.lon` | number | yes | -180 to 180. |
| `near.radius_m` | integer |  | 100 to 50,000. Default `5000`. |
| `freshness` | string |  | Only results published within this period. Until the hourly filter ships, hour returns 501 api_not_implemented. One of `hour`, `day`, `week`, `month`, `year`. |
| `date_from` | string |  | Date YYYY-MM-DD (UTC). |
| `date_to` | string |  | Date YYYY-MM-DD (UTC). |
| `page` | integer |  | Results are read in blocks of 10 to 100 that start on a multiple of the block size; a page and num pair that does not fit in one block returns 400 with param num. 1 to 10. Default `1`. |
| `num` | integer |  | Default 10 (images and shopping 20). page * num at most 200. 1 to 100. |
| `safe` | string |  | One of `off`, `moderate`, `strict`. Default `moderate`. |
| `include_domains` | array of string |  | Host names; subdomains included. At most 20 items. |
| `exclude_domains` | array of string |  | At most 50 items. |
| `content` | object |  | Cleaned text of the top pages. |
| `content.pages` | integer |  | At most num. On a page above 1, content needs a num that is a multiple of 10, otherwise 400 with param content. 1 to 10. Default `3`. |
| `content.format` | string |  | One of `markdown`, `text`. Default `markdown`. |
| `content.max_chars_per_page` | integer |  | 500 to 50,000. Default `8000`. |
| `content.mode` | string |  | One of `full`, `relevant`. Default `full`. |
| `answer` | boolean or object |  | Planned. True is the same as {}. |
| `max_age` | integer |  | Accept a stored copy up to this age in seconds. 0 to 2,592,000. |
| `no_cache` | boolean |  | Never answer from a stored copy. Default `false`. |
| `timeout_ms` | integer |  | Our deadline for this call; default and maximum 20000, or 25000 with content. A value outside 1000 to that maximum is refused with 400. 1000 to 25,000. |

### Example request

curl:

```bash
curl https://api.websearch.fast/v1/web/search \
  -H "Authorization: Bearer $WEBSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "rust async runtime comparison",
    "num": 3,
    "content": {"pages": 1, "max_chars_per_page": 3000}
  }'
```

Python:

```python
import os
import httpx

response = httpx.post(
    "https://api.websearch.fast/v1/web/search",
    headers={"Authorization": f"Bearer {os.environ['WEBSEARCH_API_KEY']}"},
    json={
        "q": "rust async runtime comparison",
        "num": 3,
        "content": {"pages": 1, "max_chars_per_page": 3000},
    },
    timeout=60,
)
response.raise_for_status()
print(response.json())
```

TypeScript:

```typescript
const response = await fetch("https://api.websearch.fast/v1/web/search", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.WEBSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    q: "rust async runtime comparison",
    num: 3,
    content: { pages: 1, max_chars_per_page: 3000 },
  }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

### Example response

```json
{
  "object": "web.search",
  "request_id": "20261128120000123456789a1b2c3d4Kx7Qm2Pz",
  "created": 1795867200,
  "input": {
    "q": "rust async runtime comparison",
    "type": "web",
    "page": 1,
    "num": 3,
    "safe": "moderate",
    "operators": {},
    "content": {
      "pages": 1,
      "format": "markdown",
      "max_chars_per_page": 3000,
      "mode": "full"
    },
    "timeout_ms": 25000
  },
  "results": [
    {
      "position": 1,
      "title": "Choosing an async runtime in 2026",
      "url": "https://blog.example.com/posts/async-runtimes-2026",
      "domain": "blog.example.com",
      "snippet": "We benchmarked four runtimes on the same HTTP workload and compared scheduling, I/O and memory use.",
      "published_at": "2026-09-14T00:00:00Z",
      "origin": "index",
      "content": {
        "status": "ok",
        "format": "markdown",
        "chars": 3000,
        "truncated": true,
        "text": "# Choosing an async runtime in 2026\n\n...",
        "fetched_at": 1795860000
      }
    },
    {
      "position": 2,
      "title": "Async runtimes: a comparison of schedulers",
      "url": "https://docs.example.org/rust/async/runtimes",
      "domain": "docs.example.org",
      "snippet": "How work-stealing and thread-per-core runtimes differ, with notes on when each fits.",
      "published_at": "2026-06-02T00:00:00Z",
      "origin": "live"
    },
    {
      "position": 3,
      "title": "Moving a service between async runtimes",
      "url": "https://www.example.net/notes/runtime-migration",
      "domain": "www.example.net",
      "snippet": "What changed in our code when we moved a Rust service from one async runtime to another.",
      "published_at": "2026-03-21T00:00:00Z",
      "origin": "live"
    }
  ],
  "has_more": true,
  "usage": {
    "charged": true,
    "items": [
      {"unit": "search_web", "count": 1},
      {"unit": "content_page", "count": 1}
    ]
  },
  "cache": {"hit": false, "data_age_seconds": 0, "fetched_at": 1795867200}
}
```

### Response fields

Results. An empty list carries the warning no_results and is not charged.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | string | yes | Always `web.search`. |
| `request_id` | string | yes | Same as the X-Request-Id header. |
| `created` | integer | yes | Unix seconds (UTC). |
| `input` | object | yes | The parameters as applied, defaults filled in. |
| `usage` | object | yes |  |
| `usage.charged` | boolean | yes |  |
| `usage.items` | array of object | yes |  |
| `usage.items.unit` | string | yes | Billable unit, for example search_web, content_page, fetch_page, geocode, autocomplete, knowledge. |
| `usage.items.count` | integer | yes |  |
| `cache` | object |  |  |
| `cache.hit` | boolean | yes | The response, or every page in it, came from a stored copy. |
| `cache.data_age_seconds` | integer | yes | Age of the oldest part of the response. |
| `cache.fetched_at` | integer | yes | Unix seconds when the oldest part was read. |
| `warnings` | array of object |  |  |
| `warnings.code` | string | yes | For example no_results, content_partial, answer_unavailable, partial, all_failed, reach_reduced. |
| `warnings.message` | string |  |  |
| `warnings.param` | string |  |  |
| `results` | array of object | yes |  |
| `results.position` | integer | yes | 1-based rank across pages. At least 1. |
| `results.title` | string | yes |  |
| `results.url` | string | yes | Real destination URL, never a redirect link. |
| `results.domain` | string | yes | Host of url, lowercase, without www. |
| `results.snippet` | string |  | At most 400 characters. |
| `results.published_at` | string |  | ISO 8601 UTC, when known. |
| `results.site_name` | string |  | The publisher's own name, when known. |
| `results.origin` | string | yes | Our neutral label of how the result reached you. New values can appear. One of `index`, `live`, `open_data`. |
| `results.sitelinks` | array of object |  | At most 8 items. |
| `results.sitelinks.title` | string | yes |  |
| `results.sitelinks.url` | string | yes |  |
| `results.attributes` | object |  | Facts shown with the result. |
| `results.content` | object |  | Cleaned page text added by the content option. |
| `results.content.status` | string | yes | One of `ok`, `failed`. |
| `results.content.error_code` | string |  | One of `fetch_failed`, `site_refused`, `unsupported_content`, `page_too_large`, `timeout`. |
| `results.content.format` | string |  | One of `markdown`, `text`. |
| `results.content.text` | string |  |  |
| `results.content.chars` | integer |  |  |
| `results.content.truncated` | boolean |  |  |
| `results.content.title` | string |  |  |
| `results.content.fetched_at` | integer |  | Unix seconds when the page was read. |
| `has_more` | boolean | yes |  |
| `answer_box` | object |  |  |
| `answer_box.title` | string |  |  |
| `answer_box.answer` | string | yes |  |
| `answer_box.snippet` | string |  |  |
| `answer_box.url` | string |  |  |
| `knowledge_panel` | object |  | An encyclopedia card from open data. In a search it comes only on page 1 of a search with results and is included in the search price. |
| `knowledge_panel.title` | string | yes |  |
| `knowledge_panel.type` | string |  | Short label, for example Physicist or City. |
| `knowledge_panel.description` | string |  | A short text from the encyclopedia article. |
| `knowledge_panel.description_url` | string |  | The article the description comes from. |
| `knowledge_panel.description_site_name` | string |  | Name of the encyclopedia, with description_url. |
| `knowledge_panel.website` | string |  | Official website of the entity. |
| `knowledge_panel.attributes` | object |  | Key facts as name: value, in a stable order. |
| `knowledge_panel.attribution` | array of object | yes | The open data projects the data comes from, with their licences. Show it with the data. |
| `knowledge_panel.attribution.source` | string | yes | Name of the open data set the fact comes from. |
| `knowledge_panel.attribution.url` | string | yes |  |
| `knowledge_panel.attribution.license` | string | yes | For example CC BY-SA 4.0 or CC0 1.0. |
| `related_questions` | array of object |  |  |
| `related_questions.question` | string | yes |  |
| `related_questions.snippet` | string |  |  |
| `related_questions.title` | string |  |  |
| `related_questions.url` | string |  |  |
| `related_searches` | array of object |  |  |
| `related_searches.query` | string | yes |  |
| `top_stories` | array of object |  | At most 10 items. |
| `top_stories.position` | integer | yes | 1-based rank across pages. At least 1. |
| `top_stories.title` | string | yes |  |
| `top_stories.url` | string | yes | Real destination URL, never a redirect link. |
| `top_stories.domain` | string | yes | Host of url, lowercase, without www. |
| `top_stories.snippet` | string |  | At most 400 characters. |
| `top_stories.published_at` | string |  | ISO 8601 UTC, when known. |
| `top_stories.site_name` | string |  | The publisher's own name, when known. |
| `top_stories.origin` | string | yes | Our neutral label of how the result reached you. New values can appear. One of `index`, `live`, `open_data`. |
| `top_stories.image_url` | string |  |  |
| `top_stories.authors` | array of string |  |  |
| `top_stories.content` | object |  | Cleaned page text added by the content option. |
| `top_stories.content.status` | string | yes | One of `ok`, `failed`. |
| `top_stories.content.error_code` | string |  | One of `fetch_failed`, `site_refused`, `unsupported_content`, `page_too_large`, `timeout`. |
| `top_stories.content.format` | string |  | One of `markdown`, `text`. |
| `top_stories.content.text` | string |  |  |
| `top_stories.content.chars` | integer |  |  |
| `top_stories.content.truncated` | boolean |  |  |
| `top_stories.content.title` | string |  |  |
| `top_stories.content.fetched_at` | integer |  | Unix seconds when the page was read. |
| `answer` | object |  | Planned. |
| `answer.status` | string | yes | One of `ok`, `unavailable`. |
| `answer.text` | string |  | Markdown with [n] markers that index citations. |
| `answer.data` | object |  | Structured answer when answer.schema was sent. |
| `answer.citations` | array of object |  |  |
| `answer.citations.index` | integer | yes | At least 1. |
| `answer.citations.url` | string | yes |  |
| `answer.citations.title` | string |  |  |
| `answer.citations.site_name` | string |  |  |
| `answer.citations.published_at` | string |  |  |
| `answer.language` | string |  |  |

### Errors

| Status | Codes |
| --- | --- |
| `400` | `invalid_request`, `invalid_url`, `invalid_schema` or `invalid_image`. Not charged. |
| `401` | `invalid_token`. Not charged. |
| `403` | `pre_consume_token_quota_failed` (the key's own spending limit), `access_denied`, `web_not_allowed` or `model_not_in_plan` (customer keys while plans cannot include the web tools). Not charged. |
| `404` | `not_found` or `invalid_endpoint`. Not charged. |
| `413` | `read_request_body_failed`: the request body is over the limit. Not charged. |
| `429` | `rate_limited`, `concurrency_limited`, `api_key_temporarily_frozen`, or the failure guard. Not charged. |
| `500` | `internal_error`. Not charged. |
| `501` | `api_not_implemented`: the endpoint, type or option has not shipped. Not charged. |
| `503` | `source_unavailable`, `web_api_disabled`, `token_cache_busy` or `billing_busy` (the charge could not be prepared in time; retry after Retry-After). Not charged. |
| `504` | timeout. Not charged. |
