> ## 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.

# 导出为 Markdown

> 将站点内容导出为 Markdown 文件。

## GET /sites/{siteId}/markdown/export

生成并返回站点全部 URL 及其内容的 Markdown 导出，仅限付费套餐。

<Note>
  该功能需要付费订阅，免费用户将收到错误响应。
</Note>

### 路径参数

<ParamField path="siteId" type="string" required>
  要导出的站点 ID。
</ParamField>

### 查询参数

<ParamField query="format" type="string" default="individual">
  导出格式：

  * `individual`：返回 JSON，每条 URL 对应一段 Markdown
  * `combined`：返回合并后的单个 Markdown 文本
</ParamField>

<ParamField query="fresh" type="boolean" default="false">
  若为 `true`，实时抓取内容而非使用缓存 Markdown。
</ParamField>

### 响应

当 `format=individual` 时返回 JSON：

<ResponseField name="success" type="boolean">
  导出是否成功。
</ResponseField>

<ResponseField name="format" type="string">
  导出格式（`individual`）。
</ResponseField>

<ResponseField name="files" type="array">
  Markdown 文件对象数组。

  <Expandable title="file 字段">
    <ResponseField name="url" type="string">
      原始 URL。
    </ResponseField>

    <ResponseField name="title" type="string">
      页面标题。
    </ResponseField>

    <ResponseField name="markdown" type="string">
      Markdown 正文。
    </ResponseField>
  </Expandable>
</ResponseField>

当 `format=combined` 时返回纯 Markdown 文本，并附带下载用的 Content-Disposition 头。

<RequestExample>
  ```bash cURL (Individual JSON) theme={null}
  curl -X GET "https://api.llmgenerator.com/api/v1/sites/550e8400-e29b-41d4-a716-446655440000/markdown/export" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```bash cURL (Combined Markdown) theme={null}
  curl -X GET "https://api.llmgenerator.com/api/v1/sites/550e8400-e29b-41d4-a716-446655440000/markdown/export?format=combined" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -o site-export.md
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.llmgenerator.com/api/v1/sites/550e8400-e29b-41d4-a716-446655440000/markdown/export?format=combined',
    {
      headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
    }
  );

  const markdown = await response.text();
  ```
</RequestExample>

<ResponseExample>
  ```json Individual Format theme={null}
  {
    "success": true,
    "format": "individual",
    "files": [
      {
        "url": "https://example.com/",
        "title": "Example Domain - Home",
        "markdown": "# Example Domain\n\nWelcome to Example Domain...\n"
      },
      {
        "url": "https://example.com/about",
        "title": "About Us",
        "markdown": "# About Us\n\nLearn more about Example Domain...\n"
      }
    ]
  }
  ```

  ```markdown Combined Format theme={null}
  # Site Export: example.com

  ---

  ## Home

  URL: https://example.com/

  Welcome to Example Domain. This is the main landing page...

  ---

  ## About Us

  URL: https://example.com/about

  Learn more about our company and mission...
  ```
</ResponseExample>
