Skip to main content
GET
/
v1
/
namespaces
/
{namespace_name}
/
documents
/
fetch-text-data
curl -X GET "https://api.moorcheh.ai/v1/namespaces/my-docs/documents/fetch-text-data?limit=100" \
  -H "x-api-key: YOUR_API_KEY"
{
  "status": "success",
  "message": "Fetched 100 text items from namespace 'my-docs'.",
  "namespace": "my-docs",
  "statistics": {
    "total_items": 100,
    "total_text_chunks": 95,
    "total_summary_chunks": 5,
    "created_at_min": "2025-12-19T18:18:57.370Z",
    "created_at_max": "2025-12-19T18:20:01.120Z",
    "source_counts": {
      "my-docs": 100
    }
  },
  "items": [
    {
      "id": "api-reference_ai_generate_chunk_0",
      "text": "Generate AI-powered answers to questions...",
      "metadata": {
        "chunk_index": 0,
        "heading": "Overview",
        "source": "my-docs",
        "title": "Generate AI Answer - Overview"
      },
      "created_at": "2025-12-19T18:18:57.700Z",
      "is_summary": false
    }
  ],
  "pagination": {
    "limit": 100,
    "has_more": true,
    "next_token": "eyJ1c2VySWQiOiI..."
  },
  "execution_time": 1.381
}

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.

Overview

Get text chunks from a text-type namespace via the public API. Use this to list stored text/summary chunks for display, export, or RAG. 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 a pagination.next_token — pass that token on the next request to fetch the following page.
Only namespaces with type === "text" are supported. Vector-only namespaces are not supported.

Authentication

x-api-key
string
required
Your API key. API Gateway requires a valid API key for this route.

Path Parameters

namespace_name
string
required
Name of the text namespace (e.g. my-docs)

Query Parameters

limit
integer
Maximum number of items to return in this page. Default: 100. Maximum: 100.
next_token
string
Opaque cursor from the previous response’s pagination.next_token. Omit on the first request.
next_token is tied to your API key user and namespace. Do not reuse a token from a different namespace or account.

Pagination

1

First request

GET .../fetch-text-data?limit=100 (or omit limit for the default of 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: GET .../fetch-text-data?limit=100&next_token=<token>
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.
curl -X GET "https://api.moorcheh.ai/v1/namespaces/my-docs/documents/fetch-text-data?limit=100" \
  -H "x-api-key: YOUR_API_KEY"
{
  "status": "success",
  "message": "Fetched 100 text items from namespace 'my-docs'.",
  "namespace": "my-docs",
  "statistics": {
    "total_items": 100,
    "total_text_chunks": 95,
    "total_summary_chunks": 5,
    "created_at_min": "2025-12-19T18:18:57.370Z",
    "created_at_max": "2025-12-19T18:20:01.120Z",
    "source_counts": {
      "my-docs": 100
    }
  },
  "items": [
    {
      "id": "api-reference_ai_generate_chunk_0",
      "text": "Generate AI-powered answers to questions...",
      "metadata": {
        "chunk_index": 0,
        "heading": "Overview",
        "source": "my-docs",
        "title": "Generate AI Answer - Overview"
      },
      "created_at": "2025-12-19T18:18:57.700Z",
      "is_summary": false
    }
  ],
  "pagination": {
    "limit": 100,
    "has_more": true,
    "next_token": "eyJ1c2VySWQiOiI..."
  },
  "execution_time": 1.381
}

Response Fields

Success Response (200)

status
string
Always "success" for 200 responses
message
string
Human-readable summary for this page (e.g. “Fetched N text items from namespace ’…’”)
namespace
string
The requested namespace name
statistics
object
Aggregated counts and timestamps for items in this page only (not the full namespace total)
statistics.total_items
number
Number of items in items on this page
statistics.total_text_chunks
number
Count of non-summary chunks on this page
statistics.total_summary_chunks
number
Count of summary chunks on this page
statistics.created_at_min
string | null
Earliest item timestamp on this page as ISO 8601 (e.g. "2025-12-19T18:18:57.370Z"). Computed by normalizing each item’s stored createdAt (ISO string or Unix s/ms) and converting the minimum back to ISO. null when no item has a parseable date.
statistics.created_at_max
string | null
Latest item timestamp on this page as ISO 8601. Same normalization as created_at_min. null when no item has a parseable date.
statistics.source_counts
object
Map of source name → count on this page. Keys may be file names, upload sources, or namespace identifiers.
items
array
Text chunks for this page (length ≤ limit, max 100)
items[].id
string
Item/chunk identifier
items[].text
string
Text content of the chunk
items[].metadata
object
Arbitrary metadata (e.g. source, heading, chunk_index, page_title)
items[].created_at
string | null
Creation time as an ISO 8601 string (e.g. "2025-12-19T18:18:57.700Z")
items[].is_summary
boolean
true for summary chunks, false for regular text chunks
pagination
object
Cursor pagination metadata for this response
pagination.limit
number
Page size used for this request (≤ 100)
pagination.has_more
boolean
true if additional pages exist after this one
pagination.next_token
string | null
Pass as query param next_token to fetch the next page. null when has_more is false.
execution_time
number
Request processing time in seconds

Limits

Items per page

Up to 100 items per request. Use limit and next_token to walk the full namespace.

Credits & API requests

Each page is one API call and consumes credits toward your plan’s API request limit.

Export all pages (example)

async function fetchAllTextChunks(apiKey, namespace) {
  const base = "https://api.moorcheh.ai/v1";
  const allItems = [];
  let nextToken;

  do {
    const params = new URLSearchParams({ limit: "100" });
    if (nextToken) params.set("next_token", nextToken);

    const res = await fetch(
      `${base}/namespaces/${encodeURIComponent(namespace)}/documents/fetch-text-data?${params}`,
      { headers: { "x-api-key": apiKey } }
    );
    const body = await res.json();
    if (!res.ok) throw new Error(body.message || res.statusText);

    allItems.push(...(body.items || []));
    nextToken = body.pagination?.has_more ? body.pagination.next_token : null;
  } while (nextToken);

  return allItems;
}