cURL
curl --request POST \
--url https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch \
--header 'content-type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"ids": [
"<string>"
],
"consistentRead": false,
"includeVectors": false
}
'import requests
url = "https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch"
payload = {
"ids": ["<string>"],
"consistentRead": False,
"includeVectors": False
}
headers = {
"content-type": "<content-type>",
"x-api-key": "<x-api-key>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'content-type': '<content-type>', 'x-api-key': '<x-api-key>'},
body: JSON.stringify({ids: ['<string>'], consistentRead: false, includeVectors: false})
};
fetch('https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch', 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://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch",
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' => [
'<string>'
],
'consistentRead' => false,
'includeVectors' => false
]),
CURLOPT_HTTPHEADER => [
"content-type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch"
payload := strings.NewReader("{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "<content-type>")
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch")
.header("content-type", "<content-type>")
.header("x-api-key", "<x-api-key>")
.body("{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '<content-type>'
request["x-api-key"] = '<x-api-key>'
request.body = "{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}"
response = http.request(request)
puts response.read_body{
"total": 123,
"took": 123,
"docs": [
{
"index": "<string>",
"doc": {}
}
]
}Documents
Fetch documents
Lookup and return documents by document IDs from an index.
POST
/
projects
/
{projectId}
/
indexes
/
{indexName}
/
docs
/
fetch
cURL
curl --request POST \
--url https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch \
--header 'content-type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"ids": [
"<string>"
],
"consistentRead": false,
"includeVectors": false
}
'import requests
url = "https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch"
payload = {
"ids": ["<string>"],
"consistentRead": False,
"includeVectors": False
}
headers = {
"content-type": "<content-type>",
"x-api-key": "<x-api-key>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'content-type': '<content-type>', 'x-api-key': '<x-api-key>'},
body: JSON.stringify({ids: ['<string>'], consistentRead: false, includeVectors: false})
};
fetch('https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch', 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://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch",
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' => [
'<string>'
],
'consistentRead' => false,
'includeVectors' => false
]),
CURLOPT_HTTPHEADER => [
"content-type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch"
payload := strings.NewReader("{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "<content-type>")
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch")
.header("content-type", "<content-type>")
.header("x-api-key", "<x-api-key>")
.body("{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{baseUrl}/{version}/projects/{projectId}/indexes/{indexName}/docs/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '<content-type>'
request["x-api-key"] = '<x-api-key>'
request.body = "{\n \"ids\": [\n \"<string>\"\n ],\n \"consistentRead\": false,\n \"includeVectors\": false\n}"
response = http.request(request)
puts response.read_body{
"total": 123,
"took": 123,
"docs": [
{
"index": "<string>",
"doc": {}
}
]
}Body
application/json
A list of document IDs to fetch. Note that the maximum number of document IDs is 1000.
If your application requires a strongly consistent read, set consistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value.
If your application need to include vector values in the response, set includeVectors to true.