Skip to main content

Official Python SDK for Memory Machines API

Project description

Memory Machines Python SDK

Official Python SDK for the Memory Machines API.

Installation

pip install memorymachines

Or install from source:

git clone https://github.com/memorymachines/memorymachines-sdk.git
cd memorymachines-sdk
pip install -e .

Quick Start

# One-time login (saves to ~/.memorymachines/config.yaml)
memorymachines login
from memorymachines import MemoryClient

# No API key needed - auto-discovered from config file
client = MemoryClient()

# Ingest content
client.ingest("Had a great meeting about Q4 goals today")

# Search memories
memories = client.search("what did we discuss about Q4?")
for memory in memories:
    print(memory['content'])

Getting an API Key

  1. Sign up at memorymachines.com
  2. Go to your dashboard
  3. Copy your API key (starts with mm_sk_)

Authentication

The SDK auto-discovers your API key in this order:

  1. Explicit api_key parameter
  2. MM_API_KEY environment variable
  3. ~/.memorymachines/config.yaml file

CLI Login (Recommended)

# Save your API key securely
memorymachines login

# Check who's logged in
memorymachines whoami

# List profiles
memorymachines profiles

# Logout
memorymachines logout

Programmatic Login

from memorymachines import login, logout

# Save token
login("mm_sk_...")

# Remove token
logout()

Multiple Profiles

# Save multiple accounts
memorymachines login --profile personal
memorymachines login --profile work

# Switch profiles
memorymachines use work
# Use specific profile
client = MemoryClient(profile="work")

Usage

Initialize Client

from memorymachines import MemoryClient

# Auto-discover API key (recommended)
client = MemoryClient()

# Or explicit API key
client = MemoryClient(api_key="mm_sk_...")

# Or specific profile
client = MemoryClient(profile="work")

# Custom endpoint (for development)
client = MemoryClient(base_url="http://localhost:8080")

Ingest Data

# Single item
client.ingest(
    content="Meeting notes from today...",
    source="notes",
    metadata={"date": "2024-10-24"}
)

# Batch ingestion
items = [
    {'content': 'Email from client...', 'source': 'email'},
    {'content': 'Meeting notes...', 'source': 'notes'}
]
client.ingest_batch(items)

Search Memories

# Natural language search
memories = client.search("what did I discuss last week?", limit=10)

# List all memories with filters
response = client.list_memories(
    limit=50,
    source="email",
    since=datetime(2024, 10, 1)
)

Manage Memories

# Get specific memory
memory = client.get_memory(memory_id="mem_123")

# Delete memory
client.delete_memory(memory_id="mem_123")

# Check connected services
services = client.get_connected_services()  # ['gmail', 'slack']

Examples

See the examples/ directory for more usage examples:

API Reference

MemoryClient

__init__(api_key: str, base_url: str = "https://api.memorymachines.com")

Initialize the client.

ingest(content: str, source: str = "custom", metadata: dict = None) -> dict

Ingest text content to extract memories.

ingest_batch(items: List[dict]) -> dict

Ingest multiple items at once.

search(query: str, limit: int = 10) -> List[dict]

Search memories with natural language.

list_memories(limit: int = 50, offset: int = 0, source: str = None, since: datetime = None) -> dict

List memories with filters.

get_memory(memory_id: str) -> dict

Get a specific memory by ID.

delete_memory(memory_id: str) -> dict

Delete a memory.

get_connected_services() -> List[str]

Get list of connected OAuth services.

health_check() -> bool

Check if API is accessible.

Development

Setup

git clone https://github.com/memorymachines/memorymachines-sdk.git
cd memorymachines-sdk
pip install -e ".[dev]"

Run Examples

export MEMORY_MACHINES_API_KEY="mm_sk_..."
python examples/basic_usage.py

Support

License

Apache 2.0 - see LICENSE file for details.

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

memorymachines-0.1.4.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

memorymachines-0.1.4-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file memorymachines-0.1.4.tar.gz.

File metadata

  • Download URL: memorymachines-0.1.4.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for memorymachines-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b776b36d098435f2d881e3d7d5114a39ff0de09dd85b3082d05a5655e9522d95
MD5 60e51083ad5e78290c0e4da4e2e2ccd6
BLAKE2b-256 49a2b59eb9e282cd82483ca6677c698e6c9c2a3e937c2e802d19be6f5dc9e361

See more details on using hashes here.

File details

Details for the file memorymachines-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: memorymachines-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for memorymachines-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 89a4b6c09f4f800d690e36dccc4f630c97b68cc4f43752022b22b596013173cd
MD5 b53045f01c92c7d81ca221987d470184
BLAKE2b-256 789c6faae5eb4665ffcd1daa1df9a18232be0687683a33f7feb6211d0233ebee

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