curl --request POST \
--url https://api.zeroentropy.dev/v1/queries/top-documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collection_name": "<string>",
"query": "<string>",
"k": 123,
"filter": "<string>",
"include_metadata": false,
"reranker": "<string>",
"latency_mode": "low"
}
'import requests
url = "https://api.zeroentropy.dev/v1/queries/top-documents"
payload = {
"collection_name": "<string>",
"query": "<string>",
"k": 123,
"filter": "<string>",
"include_metadata": False,
"reranker": "<string>",
"latency_mode": "low"
}
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({
collection_name: '<string>',
query: '<string>',
k: 123,
filter: '<string>',
include_metadata: false,
reranker: '<string>',
latency_mode: 'low'
})
};
fetch('https://api.zeroentropy.dev/v1/queries/top-documents', 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://api.zeroentropy.dev/v1/queries/top-documents",
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([
'collection_name' => '<string>',
'query' => '<string>',
'k' => 123,
'filter' => '<string>',
'include_metadata' => false,
'reranker' => '<string>',
'latency_mode' => 'low'
]),
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://api.zeroentropy.dev/v1/queries/top-documents"
payload := strings.NewReader("{\n \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\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://api.zeroentropy.dev/v1/queries/top-documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zeroentropy.dev/v1/queries/top-documents")
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 \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"path": "<string>",
"score": 123,
"metadata": {},
"file_url": "<string>"
}
]
}{
"detail": "Description of Error"
}{
"detail": "Description of Error"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Top Documents
Get the top K documents that match the given query
curl --request POST \
--url https://api.zeroentropy.dev/v1/queries/top-documents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"collection_name": "<string>",
"query": "<string>",
"k": 123,
"filter": "<string>",
"include_metadata": false,
"reranker": "<string>",
"latency_mode": "low"
}
'import requests
url = "https://api.zeroentropy.dev/v1/queries/top-documents"
payload = {
"collection_name": "<string>",
"query": "<string>",
"k": 123,
"filter": "<string>",
"include_metadata": False,
"reranker": "<string>",
"latency_mode": "low"
}
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({
collection_name: '<string>',
query: '<string>',
k: 123,
filter: '<string>',
include_metadata: false,
reranker: '<string>',
latency_mode: 'low'
})
};
fetch('https://api.zeroentropy.dev/v1/queries/top-documents', 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://api.zeroentropy.dev/v1/queries/top-documents",
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([
'collection_name' => '<string>',
'query' => '<string>',
'k' => 123,
'filter' => '<string>',
'include_metadata' => false,
'reranker' => '<string>',
'latency_mode' => 'low'
]),
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://api.zeroentropy.dev/v1/queries/top-documents"
payload := strings.NewReader("{\n \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\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://api.zeroentropy.dev/v1/queries/top-documents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zeroentropy.dev/v1/queries/top-documents")
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 \"collection_name\": \"<string>\",\n \"query\": \"<string>\",\n \"k\": 123,\n \"filter\": \"<string>\",\n \"include_metadata\": false,\n \"reranker\": \"<string>\",\n \"latency_mode\": \"low\"\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"path": "<string>",
"score": 123,
"metadata": {},
"file_url": "<string>"
}
]
}{
"detail": "Description of Error"
}{
"detail": "Description of Error"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
The Authorization header must be provided in the format Bearer <your-api-key>.
You can get your API Key at the Dashboard!
Body
The query filter to apply. Please read Metadata Filtering for more information. If not provided, then all documents will be searched.
The reranker to use after initial retrieval. The default is null. You can find available model ids along with more information at /models/rerank.
This option selects between our two latency modes. The higher latency mode takes longer, but can allow for more accurate responses. If desired, test both to customize your search experience for your particular use-case, or use the default of "low" and only swap if you need an additional improvement in search result quality.
low, high