# 获取结果内容 (/zh/api/search-index/contents)

<!-- agent-signals: reading_time_min: 3 · est_tokens: 2811 · updated: 2026-09-23 -->
Related: [Mintlify Index REST API](/zh/api/search-index/introduction.md), [构建实现上下文](/zh/api/search-index/context.md), [搜索技术知识](/zh/api/search-index/search.md), [获取反馈](/zh/api/analytics/feedback.md)



`POST /v1/contents`

获取搜索端点返回的 Mintlify 结果 ID 或结果 URL 对应的内容。一次请求最多可以在两个字段中包含 20 项。

## OpenAPI

```json
{
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "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` 时，用于选择最相关部分的查询。"
            }
          }
        },
        "example": {
          "ids": [
            "nextjs:/docs/app/getting-started/caching-and-revalidating"
          ],
          "query": "重新验证缓存的数据",
          "maxCharacters": 12000
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "内容获取完成。请检查每个状态，以确定对应项目是否成功。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "requestId",
              "results",
              "statuses"
            ],
            "properties": {
              "requestId": {
                "type": "string",
                "description": "请求的唯一标识符。"
              },
              "results": {
                "type": "array",
                "items": {
                  "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` 结果会原样传递来源的日期字符串，不进行规范化；该字符串可以是完整时间戳，也可以只是日期。"
                    }
                  }
                },
                "description": "成功获取的结果。"
              },
              "statuses": {
                "type": "array",
                "items": {
                  "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 状态码（如果有）。"
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                "description": "每个请求项目的获取状态。"
              }
            }
          },
          "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": "# 缓存与重新验证\n\n使用重新验证 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": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          },
          "example": {
            "error": "一个请求最多可以在 urls 和 ids 中引用 20 项"
          }
        }
      }
    },
    "401": {
      "description": "API key 缺失或无效，或组织无权访问 Index REST API。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          },
          "example": {
            "error": "未授权"
          }
        }
      }
    },
    "403": {
      "description": "API key 不允许该请求 IP。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          },
          "example": {
            "error": "该 API key 不允许此 IP 地址"
          }
        }
      }
    },
    "429": {
      "description": "组织超出速率限制。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          },
          "example": {
            "error": "超出速率限制。请稍后重试"
          }
        }
      }
    },
    "500": {
      "description": "Index 无法完成请求。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "error"
            ],
            "properties": {
              "error": {
                "type": "string",
                "description": "错误消息。"
              }
            }
          }
        }
      }
    }
  }
}
```
