> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moorcheh.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Fetch Text Data

> List text and summary chunks from a text namespace with cursor pagination.

## Overview

Get text chunks from a **text-type** namespace. Use this to list stored text and summary chunks for display, export, or bulk RAG context loading.

Results are returned **one page at a time**. Each page returns up to **100** items. When more data exists, the response includes `pagination.has_more` and `pagination.next_token` — pass that token on the next request to fetch the following page.

<Info>
  Only namespaces with `type === "text"` are supported. Vector-only namespaces are not supported.
</Info>

## Path parameters

<ParamField path="namespace_name" type="string" required>
  Name of the text namespace (e.g. `my-documents`)
</ParamField>

## Query parameters

<ParamField query="limit" type="integer">
  Maximum number of items to return in this page. Default: **100**. Maximum: **100**.
</ParamField>

<ParamField query="next_token" type="string">
  Opaque cursor from the previous response's `pagination.next_token`. Omit on the first request.
</ParamField>

<Note>
  `next_token` is tied to the requested namespace. Do not reuse a token from a different namespace.
</Note>

## Pagination

<Steps>
  <Step title="First request">
    `GET .../fetch-text-data?limit=100` (or omit `limit` for the default of 100).
  </Step>

  <Step title="Check pagination">
    If `pagination.has_more` is `true`, more chunks exist in the namespace.
  </Step>

  <Step title="Next page">
    Call again with `next_token` from the previous response:
    `GET .../fetch-text-data?limit=100&next_token=<token>`
  </Step>

  <Step title="Stop">
    Repeat until `pagination.has_more` is `false` or `next_token` is `null`.
  </Step>
</Steps>

<RequestExample>
  ```bash Fetch first page theme={null}
  curl -X GET "http://localhost:8080/namespaces/my-documents/documents/fetch-text-data?limit=100"
  ```

  ```bash Fetch next page theme={null}
  curl -X GET "http://localhost:8080/namespaces/my-documents/documents/fetch-text-data?limit=100&next_token=PASTE_TOKEN_FROM_PREVIOUS_RESPONSE"
  ```
</RequestExample>

## Response fields

<ResponseField name="status" type="string">
  `"success"` for 200 responses.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable summary for **this page** (e.g. "Fetched N text items from namespace '...'").
</ResponseField>

<ResponseField name="namespace" type="string">
  The requested namespace name.
</ResponseField>

<ResponseField name="statistics" type="object">
  Aggregated counts and timestamps for **items in this page only** (not the full namespace total).
</ResponseField>

<ResponseField name="statistics.total_items" type="number">
  Number of items in `items` on this page.
</ResponseField>

<ResponseField name="statistics.total_text_chunks" type="number">
  Count of non-summary chunks on this page.
</ResponseField>

<ResponseField name="statistics.total_summary_chunks" type="number">
  Count of summary chunks on this page.
</ResponseField>

<ResponseField name="statistics.created_at_min" type="string | null">
  Earliest item timestamp on this page as ISO 8601. `null` when the page is empty.
</ResponseField>

<ResponseField name="statistics.created_at_max" type="string | null">
  Latest item timestamp on this page as ISO 8601. `null` when the page is empty.
</ResponseField>

<ResponseField name="statistics.source_counts" type="object">
  Map of source name → count on this page.
</ResponseField>

<ResponseField name="items" type="array">
  Text chunks for this page (length ≤ `limit`, max 100).
</ResponseField>

<ResponseField name="items[].id" type="string">
  Item/chunk identifier.
</ResponseField>

<ResponseField name="items[].text" type="string">
  Text content of the chunk.
</ResponseField>

<ResponseField name="items[].metadata" type="object">
  Arbitrary metadata (e.g. `source`, `heading`, `chunk_index`).
</ResponseField>

<ResponseField name="items[].created_at" type="string">
  Creation time as ISO 8601.
</ResponseField>

<ResponseField name="items[].is_summary" type="boolean">
  `true` for summary chunks, `false` for regular text chunks.
</ResponseField>

<ResponseField name="pagination.limit" type="number">
  Page size used for this request (≤ 100).
</ResponseField>

<ResponseField name="pagination.has_more" type="boolean">
  `true` if additional pages exist after this one.
</ResponseField>

<ResponseField name="pagination.next_token" type="string | null">
  Pass as query param `next_token` to fetch the next page. `null` when `has_more` is `false`.
</ResponseField>

<ResponseField name="execution_time" type="number">
  Request processing time in seconds.
</ResponseField>

## Example response

```json theme={null}
{
  "status": "success",
  "message": "Fetched 2 text items from namespace 'my-documents'.",
  "namespace": "my-documents",
  "statistics": {
    "total_items": 2,
    "total_text_chunks": 2,
    "total_summary_chunks": 0,
    "created_at_min": "2025-12-19T18:18:57.370Z",
    "created_at_max": "2025-12-19T18:20:01.120Z",
    "source_counts": {
      "document.pdf": 2
    }
  },
  "items": [
    {
      "id": "abc123_chunk_0",
      "text": "Overview section content...",
      "metadata": {
        "chunk_index": 0,
        "source": "document.pdf"
      },
      "created_at": "2025-12-19T18:18:57.700Z",
      "is_summary": false
    }
  ],
  "pagination": {
    "limit": 100,
    "has_more": false,
    "next_token": null
  },
  "execution_time": 0.012
}
```

## Errors

| Status | Message (examples)                                              |
| ------ | --------------------------------------------------------------- |
| 400    | `Bad Request: Namespace '...' is not a text-based namespace.`   |
| 400    | `Invalid limit: must be a positive integer.`                    |
| 400    | `Invalid next_token: token does not match requested namespace.` |
| 404    | `Namespace '...' not found.`                                    |
| 500    | `Internal Server Error during namespace validation.`            |

## Related

* [Get items by ID](/on-prem/api-references/items/get) — retrieve specific documents by id
* [Upload documents](/on-prem/api-references/data/upload-documents) — add text documents to a namespace
* [Search](/on-prem/api-references/search/query) — semantic search over namespace content
