REST ClientDatasphere

list_chunks

View as MarkdownOpen in Claude

List chunks belonging to a document. Chunks are the individual text segments created when a document is processed for vector search.

Path parameters

documentIdstringRequiredformat: "uuid"
Unique ID of the Document.

Query parameters

page_numberintegerOptional>=0Defaults to 0
The page number to retrieve (0-indexed).
page_sizeintegerOptional1-1000Defaults to 50
Specify the number of results to return on a single page. The default page size is `50` and the maximum is `1000`.
page_tokenstringOptional
Token for cursor-based pagination. Required when `page_number` > 0.

Response

datalist of objectsRequired
A list of chunks.

Response Example

Response
{
"data": [
{
"id": "acaa5c49-be5e-4477-bce0-48f4b23b7720",
"datasphere_document_id": "acaa5c49-be5e-4477-bce0-48f4b23b7720",
"project_id": "d369a402-7b43-4512-8735-9d5e1f387814",
"status": "completed",
"tags": [
"sports",
"football",
"game"
],
"content": "This is the content from the original document that was chunked.",
"created_at": "2024-05-06T12:20-12Z",
"updated_at": "2024-05-06T12:20-12Z"
}
],
"links": {
"self": "https://{space_name}.signalwire.com/api/datasphere/documents/{document_id}/chunks?page_number=0&page_size=50",
"first": "https://{space_name}.signalwire.com/api/datasphere/documents/{document_id}/chunks?page_number=0&page_size=50",
"next": "https://{space_name}.signalwire.com/api/datasphere/documents/{document_id}/chunks?page_number=1&page_size=50&page_token=PAbff61159-faab-48b3-959a-3021a8f5beca",
"prev": "https://{space_name}.signalwire.com/api/datasphere/documents/{document_id}/chunks?page_number=0&page_size=50&page_token=PBbff61159-faab-48b3-959a-3021a8f5beca"
}
}

Example

from signalwire.rest import RestClient
client = RestClient(
project="your-project-id",
token="your-api-token",
host="your-space.signalwire.com",
)
chunks = client.datasphere.documents.list_chunks("document-id")
for chunk in chunks.get("data", []):
print(chunk.get("id"), chunk.get("text")[:80])