Skip to main content

documents.fetch_text_data

Lists stored text and summary chunks for a text namespace (up to 100 items per response). This calls the Moorcheh Fetch Text Data HTTP API (GET .../documents/fetch-text-data). Use it for export, UI, or RAG-style listing.

Parameters

namespace_name
str
required
The name of the target text namespace.
Returns: Dict[str, Any] — Response keys are snake_case (e.g. status, message, namespace, statistics, items, execution_time). Each item may include id, text, metadata, created_at, is_summary. Raises: NamespaceNotFound, InvalidInputError, AuthenticationError, APIError.

Example (sync)

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"))
    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")
        print(len(data.get("items", [])), "items")

# asyncio.run(main())

Response overview

  • items: List of chunks; each has at least id and text; summaries use is_summary: true when present.
  • statistics: Aggregated counts (e.g. total_items, total_text_chunks, total_summary_chunks, source_counts) when returned by the API.
  • created_at: May be an ISO string or a numeric timestamp depending on backend version; always under the snake_case key created_at.

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")
    print(listing.get("status"), listing.get("statistics"))
    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.
Pagination: The public API returns at most 100 items per successful response. If you need full history beyond that, coordinate with Moorcheh product/API roadmap for pagination or use Get Documents when you know IDs.
vs. Get Documents: Use fetch_text_data to list chunks in the namespace; 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, etc.).