Get a Knowledge Chunk - Cognigy Documentation
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get a Knowledge Chunk
API Endpoint
GET /v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId}
Example Requests
cURL
curl --request GET \
--url https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId} \
--header 'X-API-Key: <api-key>'
Python
import requests
url = "https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId}"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId}', 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-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-trial.cognigy.ai/new/v2.0/knowledgestores/{knowledgeStoreId}/sources/{sourceId}/chunks/{chunkId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Possible Responses
- 200 OK - Returns KnowledgeChunk object
- 400 Bad Request - Validation failed. Missing payload.
- 401 Unauthorized - Invalid API key.
- 404 Not Found - Resource not found.
Authorizations
X-API-Key - Supply the API Key in the HTTP-Header
Path Parameters
- knowledgeStoreId - The Id of the KnowledgeStore (required, string, length: 24)
- sourceId - The Id of the KnowledgeSource (required, string, length: 24)
- chunkId - The Id of the KnowledgeChunk (required, string, length: 24)
Response Details
KnowledgeChunk Object
- order: number - The name of the KnowledgeChunk
- text: string - The text that is the actual content of the chunk
- data: object - The extended data of KnowledgeChunk
- referenceId: string
- Reference ID of the chunk - _id: string - ID of the KnowledgeChunk
- createdAt: integer - Unix timestamp of creation
- lastChanged: integer - Unix timestamp of last change
- createdBy: string - ID of the user who created it
- lastChangedBy: string - ID of the last user who changed it