Skip to main content

Official Python SDK for the Memara API - Give your AI a perfect memory

Project description

Memara Python SDK

PyPI version Python 3.9+ License: MIT

The official Python SDK for the Memara API - Give your AI a perfect memory.

🚀 Quick Start

Installation

pip install memara

Basic Usage

from memara import Memara

# Initialize the client
client = Memara(api_key="your_api_key_here")

# Create a memory
memory = client.create_memory(
    content="Important meeting notes from today",
    tags=["work", "meeting", "important"],
    importance=8
)

# Search memories
results = client.search_memories(
    query="meeting notes",
    limit=10
)

# List all memories
memories = client.list_memories(page=1, size=20)

# Close the client when done
client.close()

# Or use as a context manager (recommended)
with Memara(api_key="your_api_key") as client:
    memory = client.create_memory("Hello from Python SDK!")

📖 Documentation

Authentication

Get your API key from Memara Dashboard and set it either:

  1. As environment variable (recommended):
export MEMARA_API_KEY="your_api_key_here"
  1. Or pass directly:
client = Memara(api_key="your_api_key_here")

Configuration

# Full configuration options
client = Memara(
    api_key="your_api_key",           # Your Memara API key
    base_url="https://api.memara.io", # API base URL (optional)
    timeout=30.0                      # Request timeout in seconds
)

Memory Operations

Create Memory

memory = client.create_memory(
    content="The content of your memory",
    tags=["tag1", "tag2"],           # Optional: list of tags
    source="my_app",                 # Optional: source identifier  
    importance=7,                    # Optional: 1-10 importance level
    space_id="space_uuid"            # Optional: specific space ID
)

Search Memories

# Basic search
results = client.search_memories("your search query")

# Advanced search
results = client.search_memories(
    query="meeting notes",
    limit=20,                        # Max results to return
    space_id="specific_space_id",    # Search within specific space
    cross_space=False               # Search across all spaces
)

Get Memory by ID

memory = client.get_memory("memory_uuid")

# With space context
memory = client.get_memory("memory_uuid", space_id="space_uuid")

Delete Memory

result = client.delete_memory("memory_uuid")

Space Operations

List Spaces

spaces = client.list_spaces()
for space in spaces:
    print(f"Space: {space.name} ({space.memory_count} memories)")

Create Space

space = client.create_space(
    name="My Project Space",
    icon="🚀",                      # Optional: emoji icon
    color="#6366F1",               # Optional: hex color
    template_type="work"           # Optional: template type
)

🔧 Advanced Usage

Error Handling

from memara import Memara, MemaraAPIError, MemaraAuthError

try:
    with Memara() as client:
        memory = client.create_memory("Test memory")
except MemaraAuthError:
    print("Authentication failed - check your API key")
except MemaraAPIError as e:
    print(f"API error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Environment Variables

Set these environment variables for easier configuration:

export MEMARA_API_KEY="your_api_key_here"
export MEMARA_API_URL="https://api.memara.io"  # Optional: custom API URL

Async Usage (Coming Soon)

Future versions will include async support:

# Coming in v0.2.0
from memara import AsyncMemara

async with AsyncMemara(api_key="your_key") as client:
    memory = await client.create_memory("Async memory!")

🛠️ Development

Contributing

  1. Clone the repository
  2. Install development dependencies: pip install -e .[dev]
  3. Run tests: pytest
  4. Format code: black memara/
  5. Type check: mypy memara/

Running Tests

# Install with dev dependencies
pip install -e .[dev]

# Run tests
pytest

# Run tests with coverage
pytest --cov=memara

🔗 Links

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support


Give your AI a perfect memory with Memara 🧠✨

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memara-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memara-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file memara-0.1.0.tar.gz.

File metadata

  • Download URL: memara-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for memara-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c43c0f3437160d0ce31e97218c3099b28b494c898d2a84d3fd5ed86e59e8560
MD5 ae9f781650d0b29354f1f9377ac1ed40
BLAKE2b-256 352f97f8d40c9558bde5b0f4038a2c51d7ce616f289df83516353bf931b5b417

See more details on using hashes here.

File details

Details for the file memara-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memara-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.13

File hashes

Hashes for memara-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16770ed04756d5a52ef96927b964d66c5ad826601f3122f31c7b516d9a786041
MD5 11ec48d6eab81a0b57467d6d710d38cf
BLAKE2b-256 a8c67b691c6246d5ba98f113798624fb70b82d0fec403f75504ab55eff196091

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page