Skip to main content

namespaces.list

Retrieves a list of all namespaces accessible by your API key. Returns: Dict[str, Any] - A dictionary containing a list of namespace objects under the namespaces key. Raises: AuthenticationError, APIError.

Example

List Namespaces Example
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    all_namespaces = client.namespaces.list()
    
    print(f"Found {len(all_namespaces.get('namespaces', []))} namespaces:")
    for ns in all_namespaces.get('namespaces', []):
        print(f"- Namespace: {ns['namespace_name']}, Type: {ns['type']}, Items: {ns['itemCount']}")

Response Structure

The response contains a namespaces array with the following fields for each namespace:
  • namespace_name (str): Unique name of the namespace
  • type (str): Namespace type: “text” or “vector”
  • vector_dimension (int | None): Vector dimension (null for text namespaces)
  • itemCount (int): Total number of items in the namespace
  • createdAt (str): ISO 8601 timestamp of creation

Complete Example

Complete Example
from moorcheh_sdk import MoorchehClient

with MoorchehClient() as client:
    # List all namespaces
    namespaces = client.namespaces.list()
    
    # Process the results
    text_namespaces = []
    vector_namespaces = []
    
    for ns in namespaces.get('namespaces', []):
        if ns['type'] == 'text':
            text_namespaces.append(ns)
        else:
            vector_namespaces.append(ns)
    
    print(f"Text namespaces: {len(text_namespaces)}")
    print(f"Vector namespaces: {len(vector_namespaces)}")
    
    # Display namespace details
    for ns in namespaces.get('namespaces', []):
        print(f"\n{ns['namespace_name']}:")
        print(f"  Type: {ns['type']}")
        print(f"  Items: {ns['itemCount']}")
        print(f"  Created: {ns['createdAt']}")

Use Cases

  • Dashboard Display: Show namespace overview with usage statistics
  • Data Management: Monitor storage usage and document counts
  • Namespace Selection: Populate dropdowns for namespace selection in applications
  • Usage Analytics: Track namespace growth and activity over time
  • Resource Planning: Understand storage and document distribution across namespaces