Skip to main content

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

Project description

Memara Python SDK

PyPI version PyPI - Python Version PyPI - Downloads License: MIT Documentation

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

🚀 Quick Start

Installation

pip install memara

Now Available on PyPI! Install with confidence - the package is live and ready to use.

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")

Create Audio Memory (NEW in v0.2.0)

# Upload audio file with automatic transcription
memory = client.create_audio_memory(
    audio_file="meeting.mp3",           # Path to audio file
    content="Team standup meeting",     # Memory title/description
    tags=["meeting", "team"],           # Optional: tags
    importance=7,                       # Optional: importance (1-10)
    category="audio",                   # Optional: category
    space_id="space_uuid"               # Optional: specific space
)

# Access transcription and audio data
print(f"Transcription: {memory.metadata['audio_transcription']}")
print(f"Audio URL: {memory.metadata['audio_url']}")
print(f"Duration: {memory.metadata['audio_metadata']['duration_seconds']}s")

# Supported formats: MP3, M4A, WAV, FLAC, OGG, AAC
# Three input types supported:
#   1. File path (str): "path/to/audio.mp3"
#   2. Path object: Path("audio.mp3")
#   3. Raw bytes: audio_bytes

Audio Memory Features:

  • 🎙️ Automatic Transcription: OpenAI Whisper transcription
  • 🔍 Searchable: Audio transcriptions are fully searchable
  • 📁 Secure Storage: Audio stored in S3 with CDN delivery
  • 📊 Metadata: Duration, format, language, confidence scores
  • 🎚️ Tier Limits: Respects tier-based file size limits

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.2.0.tar.gz (15.3 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.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for memara-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aa55e5cc6fddb41baf1e5af0b8c4c7b68b385e45c769dfc812cbcd597d4f9b44
MD5 83662be05d584e80a0880649780ce6bf
BLAKE2b-256 5852611df46d818fffdb764a1165f3120f3f9bed66404828c6365e0ffbd7dc2d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for memara-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2625bec067abb4cd98e90b7d6ea8e2d55560d358edfbb46032915bade0023c7
MD5 0331fcecef6172106c402973e3fead50
BLAKE2b-256 36fc75a64b5d03949b8571398d9c66267b073c752e2f6fb300fa0cd3f27c116f

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