> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 面向智能体的网页搜索 API

> 搜索网页，并在同一次调用中获得每条结果，以及页面中回答该查询的段落。

`POST /v1/search` 用智能体可以直接阅读的网页结果来回答查询：每条结果的地址、标题和摘要，一个相关性分数，以及页面中回答该查询的段落。它保持请求打开，并在同一次调用中返回结果。一个端点同时提供两种搜索，由 `type` 选择其一。

| | |
| - | - |
| 端点 | `POST /v1/search` |
| `taskType` | `task.taskType` 返回 `SEARCH`。capabilities、密钥范围和用量中记作 `WEB_SEARCH`，密钥范围接受这两个名称。`POST /v1/async/task` 对两个名称都返回 `400 USE_DEDICATED_ENDPOINT`。 |
| 输入 | `query`（必填）；`type`、`numResults`、`contents`、`userLocation`、`source`、`includeDomains`、`excludeDomains` |
| 积分 | 每次搜索 0.5，每次 Pro 搜索 2 |
| 国家 | 可选。省略 `userLocation` 响应最快；`source: "naver"` 为 `KR`。 |

## 请求

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/search \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "how do heat pumps work in cold climates", "type": "pro", "numResults": 5 }'
```

端点在请求体顶层接收下列字段，与 `idempotencyKey`、`priority`、`webhook` 并列，其他字段一律以 `400 VALIDATION_ERROR` 拒绝。响应与 [`GET /v1/async/task/:id`](https://docs.querying.ai/zh/concepts/async-tasks) 相同：`task`、`credits` 和 `response`，搜索失败时为 `error`。超过 30 秒仍在运行的搜索只返回其 `task`；请通过 `GET /v1/async/task/:id` 读取。

## 参数

| 字段 | 必填 | 说明 |
| - | - | - |
| `query` | 是 | 搜索词，最多 400 个字符。可以带运算符：`site:example.com` 和 `-site:example.com` 会加入 `includeDomains` 和 `excludeDomains`；`site:example.com/docs` 把结果限定在该站点，并让搜索引擎查找该地址下的页面；`after:2026-04-25` 和 `before:2026-07-24` 把结果限定在这两天之间发布的页面（日期未知的页面会保留）。响应中的 `query` 是发送时的原样查询。 |
| `type` | 否 | `standard` 读取搜索引擎结果背后的页面，并按其文本回答查询的程度排序，约需 2 秒。`pro` 还会用语言模型写出的其他说法搜索该查询，并让模型挑选段落，约需 4 秒。默认为 `standard`。 |
| `numResults` | 否 | 返回的结果数，1 到 10。默认为 5。 |
| `contents` | 否 | `{ "text": { "maxCharacters": 4000 } }` 设置一条结果在 `text` 中携带的页面文本的最大字符数，200 到 10,000。默认为 2,000。`{ "text": true }` 保持默认值。 |
| `userLocation` | 否 | 结果所针对的市场，两位国家代码。仅在结果必须属于某一国家时才使用：不带它的搜索以查询所用的语言响应，速度最快。`google` 默认为 `US`；`naver` 只接受 `KR`。 |
| `source` | 否 | 搜索引擎：`bing`、`google` 或 `naver`。未指定来源的搜索返回 `source: "all"`，并询问多个引擎：Bing、Brave 和 Google，Pro 搜索在查询为韩语时还会询问 Naver。指定来源的搜索只询问该引擎，并使用调用方的原始措辞。`naver` 搜索韩国网络，包括博客、咖啡馆（cafe）和新闻。 |
| `includeDomains` | 否 | 最多 20 个主机名。只返回这些站点（含子域名）的结果。 |
| `excludeDomains` | 否 | 最多 20 个主机名。这些站点的结果会被排除。 |

超出范围的值返回 `422`。

## 响应

```json theme={"theme":"css-variables"}
{
  "query": "how do heat pumps work in cold climates",
  "source": "all",
  "type": "standard",
  "results": [
    {
      "url": "https://www.example.com/heat-pumps-cold-climates",
      "title": "...",
      "snippet": "...",
      "text": "## How cold-climate heat pumps work\n\n...",
      "score": 0.93,
      "publishedDate": "2026-09-12T07:36:36Z",
      "siteName": "..."
    }
  ]
}
```

| 字段 | 说明 |
| - | - |
| `results` | 按 `score` 排序，带 `text` 的结果在前。搜索引擎没有找到任何内容时为空。 |
| `url`, `title`, `snippet` | 与搜索引擎结果页显示的一致。 |
| `text` | 按页面顺序排列的页面段落，最多 `contents.text.maxCharacters` 个字符。纯文本，标题为 `#` 行，列表项为 `-` 行，表格行的单元格以 `\|` 连接。页面未能及时读取，或普通请求拿不到文本时不会出现；这时该结果只带 `snippet`。 |
| `score` | 0 到 1，表示与其他结果相比，该结果回答查询的程度。只能在同一个响应内比较。 |
| `publishedDate` | 页面的日期，ISO 8601 格式：页面或结果页给出时间时精确到时间，否则只到日期（`2026-09-12`）。两者都没有声明日期时不会出现。 |
| `siteName` | 页面声明了才会出现。 |

## 限制与错误

* Search 不会打开浏览器，因此需要脚本才能显示文本的页面只返回摘要。把它的 `url` 传给 [Scrape](https://docs.querying.ai/zh/engines/web-scrape.md) 即可完整读取。
* PDF 会读取其文本。没有文本的扫描版 PDF、加密的 PDF 以及超过 32 MiB 的 PDF 返回摘要。
* 只要有一个引擎响应，搜索就会返回。没有任何引擎能处理的搜索，会以该引擎的错误（例如 `BING_HTTP_429`）使任务失败。
* 账户每秒最多可发送 5 次搜索，Free 套餐为每秒 1 次，子账户合并计算。超出速率的搜索返回 `429 RATE_LIMITED`，附带 `Retry-After`，且不收费。搜索不占用并发名额。参见[积分与限制](https://docs.querying.ai/zh/concepts/credits-and-limits.md#请求速率与背压)。
* 其他请求错误见[错误](https://docs.querying.ai/zh/concepts/errors.md)。

## 相关内容

* 要读取某条结果的整个页面（包括由脚本绘制的页面），请使用 [Scrape](https://docs.querying.ai/zh/engines/web-scrape.md)。
* 带广告和各类区块的结果页，请参阅 [Google Search](https://docs.querying.ai/zh/engines/google-serp.md)。
* 完整的请求和响应 schema 见 [API 参考](https://docs.querying.ai/zh/api-reference/search.md)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.