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

# 发起 URL 发现

> 为指定网站启动 URL 发现任务。

## POST /discovery

为网站启动 URL 发现任务，返回用于追踪进度与获取结果的 `discoveryId`。

### 请求体

<ParamField body="url" type="string" required>
  目标网站 URL，须为合法的 http/https 地址。
</ParamField>

<ParamField body="maxUrls" type="number" default="50">
  最多发现的 URL 数量，范围 1–1000。
</ParamField>

<ParamField body="discoveryType" type="string" default="full">
  发现方式：

  * `full`：结合站点地图解析与爬取，覆盖更全
  * `sitemap`：仅解析 sitemap.xml
  * `crawl`：仅通过跟随链接爬取
</ParamField>

### 响应

<ResponseField name="id" type="string">
  发现任务唯一标识。
</ResponseField>

<ResponseField name="url" type="string">
  正在发现的 URL。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态：`started`、`processing`、`completed` 或 `failed`。
</ResponseField>

<ResponseField name="discoveryType" type="string">
  使用的发现方式。
</ResponseField>

<ResponseField name="maxUrls" type="number">
  URL 数量上限。
</ResponseField>

<ResponseField name="progress" type="string">
  进度百分比。
</ResponseField>

<ResponseField name="totalUrlsFound" type="number">
  当前已发现的 URL 数量。
</ResponseField>

<ResponseField name="createdAt" type="string">
  创建时间（ISO 8601）。
</ResponseField>

<ResponseField name="estimatedCompletion" type="string">
  预计完成时间。
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/discovery \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
          "url": "https://www.example.com",
          "maxUrls": 100,
          "discoveryType": "full"
        }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/discovery', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      url: 'https://www.example.com',
      maxUrls: 100
    })
  });

  const data = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json Success (201) theme={null}
  {
    "id": "disc_1706540000_abc123xyz",
    "url": "https://www.example.com",
    "status": "started",
    "discoveryType": "full",
    "maxUrls": 100,
    "progress": "0",
    "totalUrlsFound": 0,
    "createdAt": "2026-01-29T12:00:00.000Z",
    "estimatedCompletion": "2026-01-29T12:05:00.000Z"
  }
  ```
</ResponseExample>
