Get Chunks

GEThttps://api.filesearch.dev/v3/collections/:collection_name/chunks

List chunks for a document with pagination and optional regions or metadata.

Path parameters

collection_namestringRequired

Query parameters

document_idstringRequired
limitintegerOptional1-500Defaults to 100
cursorintegerOptional>=0Defaults to 0
include_regionsbooleanOptionalDefaults to false
include_metadatabooleanOptionalDefaults to true

Response

List Chunks response.

collection_namestring
document_idstring
total_resultsinteger
limitinteger
chunkslist of objectsOptional
cursorintegerOptionalDefaults to 0
next_cursorinteger or nullOptional
warningslist of stringsOptional

Errors

GET/v3/collections/:collection_name/chunks
import json
import requests

BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"
COLLECTION_NAME = "my_documents"

headers = {
    "Authorization": f"Bearer {API_KEY}",
}

params = {
    "document_id": "example_document_id",
    "limit": 10,
    "cursor": 0,
    "include_regions": False,
    "include_metadata": True
}

response = requests.get(
    f"{BASE_URL}/v3/collections/{COLLECTION_NAME}/chunks",
    headers=headers,
    params=params,
    timeout=30.0
)

print(json.dumps(response.json(), indent=2))
200
{
  "collection_name": "research_library",
  "document_id": "doc_climate_agriculture_2024",
  "total_results": 42,
  "limit": 2,
  "chunks": [
    {
      "chunk_id": "chunk_agri_report_001",
      "document_id": "doc_climate_agriculture_2024",
      "text": "Recent studies show that climate change affects crop yields through heat stress, shifting precipitation, and more frequent extreme weather events.",
      "location": {
        "page_start": 12,
        "page_end": 13,
        "chunk_index": 4,
        "parent_chunk_index": 1
      },
      "regions": [
        {
          "type": "text",
          "text": "Projected maize yield declines under high temperature scenarios",
          "page": 12,
          "bbox": {
            "x": 0.18,
            "y": 0.24,
            "width": 0.62,
            "height": 0.08
          },
          "confidence": "high"
        },
        {
          "type": "chart",
          "page": 13,
          "bbox": {
            "x": 0.12,
            "y": 0.31,
            "width": 0.76,
            "height": 0.42
          },
          "confidence": "medium",
          "image_url": "https://storage.example.com/previews/climate-agriculture-chart-p13.png",
          "description": "Chart comparing projected crop yield changes by region."
        }
      ],
      "custom_metadata": {
        "review_status": "peer_reviewed",
        "topic": "agriculture"
      },
      "metadata": {
        "section": "Projected yield impacts",
        "page_count": 2
      }
    },
    {
      "chunk_id": "chunk_agri_report_002",
      "document_id": "doc_climate_agriculture_2024",
      "text": "Adaptation measures include drought resistant seed varieties, improved irrigation scheduling, and soil moisture monitoring.",
      "location": {
        "page_start": 14,
        "page_end": 14,
        "chunk_index": 5,
        "parent_chunk_index": 1
      },
      "regions": [
        {
          "type": "text",
          "text": "Adaptation measures include drought resistant seed varieties",
          "page": 14,
          "bbox": {
            "x": 0.16,
            "y": 0.19,
            "width": 0.68,
            "height": 0.06
          },
          "confidence": "high"
        }
      ],
      "custom_metadata": {
        "review_status": "peer_reviewed",
        "topic": "adaptation"
      },
      "metadata": {
        "section": "Adaptation strategies"
      }
    }
  ],
  "cursor": 0,
  "next_cursor": 2,
  "warnings": []
}
Was this page helpful?