Mintlify Index
获取结果内容
搜索后,通过结果 ID 或结果 URL 从 Mintlify Index 获取内容。
POST
/
v1
/
contents
获取结果内容
curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/contents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
"nextjs:/docs/app/getting-started/caching-and-revalidating"
],
"query": "重新验证缓存的数据",
"maxCharacters": 12000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/contents"
payload = {
"ids": ["nextjs:/docs/app/getting-started/caching-and-revalidating"],
"query": "重新验证缓存的数据",
"maxCharacters": 12000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ids: ['nextjs:/docs/app/getting-started/caching-and-revalidating'],
query: '重新验证缓存的数据',
maxCharacters: 12000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/contents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://leaves.mintlify.com/api/universal-search/v1/contents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
'nextjs:/docs/app/getting-started/caching-and-revalidating'
],
'query' => '重新验证缓存的数据',
'maxCharacters' => 12000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://leaves.mintlify.com/api/universal-search/v1/contents"
payload := strings.NewReader("{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://leaves.mintlify.com/api/universal-search/v1/contents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/contents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}"
response = http.request(request)
puts response.read_body{
"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"
}
]
}{
"error": "一个请求最多可以在 urls 和 ids 中引用 20 项"
}{
"error": "未授权"
}{
"error": "该 API key 不允许此 IP 地址"
}{
"error": "超出速率限制。请稍后重试"
}{
"error": "<string>"
}授权
带有 mint_us_ 前缀的 Mintlify Index API 密钥。
请求体
application/json
- Option 1
- Option 2
至少提供一个 Mintlify 结果 ID 或结果 URL。你可以同时使用两个字段,总计最多 20 项。
要获取的结果 URL。对于 Web 结果,请使用此字段。
Required array length:
1 - 20 elements要获取的 Mintlify 结果 ID。
Required array length:
1 - 20 elementsMinimum string length:
1每个结果要返回的最大内容字符数。
必填范围:
x >= 1当内容超过 maxCharacters 时,用于选择最相关部分的查询。
Minimum string length:
1⌘I
获取结果内容
curl --request POST \
--url https://leaves.mintlify.com/api/universal-search/v1/contents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
"nextjs:/docs/app/getting-started/caching-and-revalidating"
],
"query": "重新验证缓存的数据",
"maxCharacters": 12000
}
'import requests
url = "https://leaves.mintlify.com/api/universal-search/v1/contents"
payload = {
"ids": ["nextjs:/docs/app/getting-started/caching-and-revalidating"],
"query": "重新验证缓存的数据",
"maxCharacters": 12000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ids: ['nextjs:/docs/app/getting-started/caching-and-revalidating'],
query: '重新验证缓存的数据',
maxCharacters: 12000
})
};
fetch('https://leaves.mintlify.com/api/universal-search/v1/contents', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://leaves.mintlify.com/api/universal-search/v1/contents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
'nextjs:/docs/app/getting-started/caching-and-revalidating'
],
'query' => '重新验证缓存的数据',
'maxCharacters' => 12000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://leaves.mintlify.com/api/universal-search/v1/contents"
payload := strings.NewReader("{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://leaves.mintlify.com/api/universal-search/v1/contents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://leaves.mintlify.com/api/universal-search/v1/contents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n \"nextjs:/docs/app/getting-started/caching-and-revalidating\"\n ],\n \"query\": \"重新验证缓存的数据\",\n \"maxCharacters\": 12000\n}"
response = http.request(request)
puts response.read_body{
"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"
}
]
}{
"error": "一个请求最多可以在 urls 和 ids 中引用 20 项"
}{
"error": "未授权"
}{
"error": "该 API key 不允许此 IP 地址"
}{
"error": "超出速率限制。请稍后重试"
}{
"error": "<string>"
}