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

# 获取结果内容

> 搜索后，通过结果 ID 或结果 URL 从 Mintlify Index 获取内容。



## OpenAPI

````yaml zh/index-openapi.json POST /v1/contents
openapi: 3.0.1
info:
  title: Mintlify Index API
  description: 为应用和代理搜索并获取技术文档与 Web 上下文。
  version: 1.0.0
servers:
  - url: https://leaves.mintlify.com/api/universal-search
security:
  - bearerAuth: []
paths:
  /v1/contents:
    post:
      summary: 获取结果内容
      description: 获取搜索端点返回的 Mintlify 结果 ID 或结果 URL 对应的内容。一次请求最多可以在两个字段中包含 20 项。
      operationId: getIndexContents
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContentsRequest'
            example:
              ids:
                - nextjs:/docs/app/getting-started/caching-and-revalidating
              query: 重新验证缓存的数据
              maxCharacters: 12000
      responses:
        '200':
          description: 内容获取完成。请检查每个状态，以确定对应项目是否成功。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContentsResponse'
              example:
                requestId: 6bf694e4-76cb-4d31-a222-c94b2d9b198a
                results:
                  - id: nextjs:/docs/app/getting-started/caching-and-revalidating
                    url: >-
                      https://nextjs.org/docs/app/getting-started/caching-and-revalidating
                    title: 缓存与重新验证
                    text: |-
                      # 缓存与重新验证

                      使用重新验证 API 刷新缓存的数据。
                    truncated: false
                    totalCharacters: 78
                    score: 0
                    source: mintlify
                    siteName: nextjs
                    breadcrumbs:
                      - 应用路由
                      - 开始使用
                    publishedDate: null
                statuses:
                  - id: nextjs:/docs/app/getting-started/caching-and-revalidating
                    status: success
        '400':
          description: 请求正文无效。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: 一个请求最多可以在 urls 和 ids 中引用 20 项
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ContentsRequest:
      type: object
      additionalProperties: false
      description: 至少提供一个 Mintlify 结果 ID 或结果 URL。你可以同时使用两个字段，总计最多 20 项。
      anyOf:
        - required:
            - urls
        - required:
            - ids
      properties:
        urls:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: string
            format: uri
          description: 要获取的结果 URL。对于 Web 结果，请使用此字段。
        ids:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: string
            minLength: 1
          description: 要获取的 Mintlify 结果 ID。
        maxCharacters:
          type: integer
          minimum: 1
          description: 每个结果要返回的最大内容字符数。
        query:
          type: string
          minLength: 1
          description: 当内容超过 `maxCharacters` 时，用于选择最相关部分的查询。
    ContentsResponse:
      type: object
      additionalProperties: false
      required:
        - requestId
        - results
        - statuses
      properties:
        requestId:
          type: string
          description: 请求的唯一标识符。
        results:
          type: array
          items:
            $ref: '#/components/schemas/SearchResult'
          description: 成功获取的结果。
        statuses:
          type: array
          items:
            $ref: '#/components/schemas/ContentStatus'
          description: 每个请求项目的获取状态。
    Error:
      type: object
      additionalProperties: false
      required:
        - error
      properties:
        error:
          type: string
          description: 错误消息。
    SearchResult:
      type: object
      additionalProperties: false
      required:
        - id
        - url
        - title
        - text
        - score
        - source
        - siteName
        - breadcrumbs
        - publishedDate
      properties:
        id:
          type: string
          description: >-
            结果标识符。将 Mintlify 结果中的 ID 传入 contents 请求的 `ids` 字段。对于 Web 结果，请将结果 URL
            传入 `urls`。
        url:
          type: string
          format: uri
          description: 规范来源 URL。
        title:
          type: string
          description: 来源标题。
        text:
          type: string
          description: 请求时返回的匹配内容。否则为空字符串。
        truncated:
          type: boolean
          description: 返回的内容是否短于可用内容。
        totalCharacters:
          type: integer
          minimum: 0
          description: 截断前的可用字符数（如果有）。
        score:
          type: number
          description: 相对相关性分数。contents 响应使用 `0`，因为它获取的是所选项目，而不是对结果进行排名。
        source:
          type: string
          enum:
            - mintlify
            - web
          description: 检索来源。
        siteName:
          type: string
          description: 文档站点或 Web 主机名。
        breadcrumbs:
          type: array
          items:
            type: string
          description: 结果的文档层级。
        publishedDate:
          type: string
          nullable: true
          description: >-
            来源提供时的发布日期，否则为 `null`。`search` 结果会将其规范化为完整的 ISO 8601 时间戳。通过 `urls`
            获取的 `contents` 结果会原样传递来源的日期字符串，不进行规范化；该字符串可以是完整时间戳，也可以只是日期。
    ContentStatus:
      oneOf:
        - type: object
          additionalProperties: false
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: 请求的 ID 或 URL。
            status:
              type: string
              enum:
                - success
              description: 获取状态。
        - type: object
          additionalProperties: false
          required:
            - id
            - status
            - error
          properties:
            id:
              type: string
              description: 请求的 ID 或 URL。
            status:
              type: string
              enum:
                - error
              description: 获取状态。
            error:
              type: object
              additionalProperties: false
              required:
                - tag
                - httpStatusCode
              properties:
                tag:
                  type: string
                  description: 机器可读的错误类别。
                httpStatusCode:
                  type: integer
                  nullable: true
                  description: 上游 HTTP 状态码（如果有）。
  responses:
    Unauthorized:
      description: API key 缺失或无效，或组织无权访问 Index REST API。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 未授权
    Forbidden:
      description: API key 不允许该请求 IP。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 该 API key 不允许此 IP 地址
    RateLimited:
      description: 组织超出速率限制。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 超出速率限制。请稍后重试
    InternalError:
      description: Index 无法完成请求。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Mintlify Index API 密钥
      description: 带有 `mint_us_` 前缀的 Mintlify Index API 密钥。

````

## Related topics

- [分析](/docs/zh/optimize/analytics.md)
- [自动化概览](/docs/zh/automations/index.md)
- [页面](/docs/zh/organize/pages.md)
