Skip to main content

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.

documents.fetch_text_data

Lists stored text and summary chunks for a text namespace. Use it for export, UI, or bulk RAG context loading. Results are returned one page at a time (up to 100 items per page). 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.

Parameters

namespace_name
str
required
The name of the target text namespace.
limit
int
Maximum number of items to return in this page. Must be between 1 and 100. Omit to use the API default (100).
next_token
str
Opaque cursor from the previous response’s pagination.next_token. Omit on the first request. Do not reuse a token from a different namespace or account.
Returns: FetchTextDataResponse — keys are snake_case: status, message, namespace, statistics, items, pagination, execution_time. Raises: NamespaceNotFound, InvalidInputError, AuthenticationError, APIError.

Example (sync, first page)

Fetch Text Data Example
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    data = client.documents.fetch_text_data(namespace_name="my-faq-documents")

    print(data.get("status"), data.get("message"))
    pagination = data.get("pagination") or {}
    print("has_more:", pagination.get("has_more"))

    for item in data.get("items", []):
        print(item.get("id"), item.get("is_summary"), item.get("text", "")[:80])

Example (async)

Fetch Text Data Async Example
from moorcheh_sdk import AsyncMoorchehClient

async def main():
    async with AsyncMoorchehClient() as client:
        data = await client.documents.fetch_text_data(
            namespace_name="my-faq-documents",
            limit=100,
        )
        print(len(data.get("items", [])), "items on this page")

# asyncio.run(main())

Pagination

1

First request

Call without next_token (optionally set limit, max 100).
2

Check pagination

If pagination.has_more is true, more chunks exist in the namespace.
3

Next page

Call again with next_token from the previous response.
4

Stop

Repeat until pagination.has_more is false or next_token is null.
Each page is a separate API call and counts toward your API request usage and credits.
Fetch all pages
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    all_items = []
    next_token = None

    while True:
        page = client.documents.fetch_text_data(
            namespace_name="my-faq-documents",
            limit=100,
            next_token=next_token,
        )
        all_items.extend(page.get("items") or [])

        pagination = page.get("pagination") or {}
        if not pagination.get("has_more"):
            break
        next_token = pagination.get("next_token")

    print(f"Collected {len(all_items)} items across all pages")

Response overview

  • items: Text chunks for this page (length ≤ limit, max 100). Each item has id, text, optional metadata, created_at (ISO 8601 string or null), and is_summary.
  • statistics: Aggregated counts for this page only — e.g. total_items, total_text_chunks, total_summary_chunks, created_at_min, created_at_max, source_counts (created_at_min/created_at_max may be null).
  • pagination: limit, has_more, and next_token (null when there is no next page).
  • message: Human-readable summary for this page (e.g. “Fetched N text items from namespace ’…’”).

Complete example

Fetch Text Data Full Example
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    listing = client.documents.fetch_text_data(
        namespace_name="my-faq-documents",
        limit=50,
    )
    print(listing.get("status"), listing.get("statistics"))
    print(listing.get("pagination"))

    for item in listing.get("items", []):
        print(item.get("id"), item.get("text", "")[:120])

Important Notes

Text namespaces only: Vector-only namespaces are not supported for this route. The API returns an error if the namespace is not text-based.
Per-page statistics: statistics describes only the items in the current items array, not the full namespace total.
vs. Get Documents: Use fetch_text_data to list chunks in the namespace (with pagination); use documents.get with a list of ids when you already know which documents to retrieve in full.

Best practices

  • Treat items as read-only chunks for display or export; use Search for similarity queries.
  • Rely on snake_case keys in Python (is_summary, created_at, next_token, etc.).
  • Pass limit between 1 and 100; invalid values raise InvalidInputError before the request is sent.