Skip to main content

A comprehensive Python client for the HeySol API with MCP protocol support, built by Dexter Hadley, MD/PhD

Project description

HeySol API Client

PyPI version Python versions License: MIT

A comprehensive Python client for the HeySol API with MCP protocol support, memory management, and CLI tools. Built by Dexter Hadley, MD/PhD for HeySol.ai integration.

Version 0.9.2 - Production-ready with full API coverage and CLI tools.

Features

  • ๐Ÿš€ Full API Coverage: Complete HeySol API endpoints with client-side status filtering
  • ๐Ÿ” Authentication: API key and Bearer token support
  • ๐Ÿ“ Memory Management: Ingest, search, and manage memory spaces
  • ๐Ÿ—๏ธ Multi-Instance Registry: Email-based registry for managing multiple HeySol instances
  • ๐Ÿ”„ Cross-Instance Operations: Move and copy logs between different instances
  • ๐Ÿ›ก๏ธ Error Handling: Robust exception hierarchy with retries
  • ๐Ÿ“Š Rate Limiting: Built-in throttling and rate limiting
  • ๐Ÿ–ฅ๏ธ CLI Interface: Command-line tools for all operations
  • ๐Ÿ“š Type Hints: Full type annotation support
  • ๐Ÿงช Well Tested: Comprehensive test suite with 95%+ coverage
  • ๐Ÿ“– Rich Documentation: Interactive notebooks and examples

Installation

pip install heysol-api-client

For development (from source):

git clone https://github.com/HadleyLab/heysol-api-client.git
cd heysol_api_client
pip install -e ".[dev]"

Quick Start

  1. Get your API key from HeySol Core
  2. Set environment variable:
    export HEYSOL_API_KEY="your-api-key-here"
    
  3. Try the quick start:
    python quick_start.py
    

Basic Usage

from heysol import HeySolClient

# Initialize client
client = HeySolClient(api_key="your-api-key")

# Create a space
space_id = client.create_space("Research", "Clinical data")

# Ingest data
client.ingest("New treatment shows promise", space_id=space_id)

# Search
results = client.search("treatment", space_ids=[space_id])
print(results["episodes"])

client.close()

CLI Usage

# Registry Management (NEW!)
heysol registry list                                    # List all registered instances
heysol registry show iDrDex@MammoChat.com              # Show instance details
heysol registry use iDrDex@MammoChat.com               # Set active instance
heysol registry register                               # Load instances from .env file

# Multi-Instance Memory Operations (NEW!)
heysol memory move iDrDex@gmail.com HadleyLaboratory@gmail.com --confirm
heysol memory copy iDrDex@MammoChat.com iDrDex@gmail.com --confirm
heysol memory search iDrDex@MammoChat.com "cancer research" --limit 10
heysol memory ingest iDrDex@MammoChat.com "Clinical data" --space-id <space-id>

# Traditional Operations
heysol profile get
heysol spaces list
heysol spaces create "My Space" --description "Data space"
heysol logs list --status success
heysol logs delete-by-source "source-name" --confirm

Configuration

โš ๏ธ IMPORTANT: API keys must be loaded from environment variables only. Never store them in config files.

Environment Variables (Recommended)

Set environment variables for secure configuration:

export HEYSOL_API_KEY="your-key"
export HEYSOL_BASE_URL="https://core.heysol.ai/api/v1"
export HEYSOL_SOURCE="my-app"

.env File Support

Alternatively, create a .env file in your project root:

# .env
HEYSOL_API_KEY=your-key-here
HEYSOL_BASE_URL=https://core.heysol.ai/api/v1
HEYSOL_SOURCE=my-app

Multi-Instance Registry (NEW!)

For managing multiple HeySol instances, use the registry system with email-based identifiers:

# .env with multiple instances
# iDrDex@MammoChat.com
HEYSOL_API_KEY=your-api-key-here

# HadleyLaboratory@gmail.com
HEYSOL_API_KEY=your-api-key-here

# iDrDex@gmail.com
HEYSOL_API_KEY=your-api-key-here

The registry automatically parses email comments and associates them with API keys for easy multi-instance management.

Strict Loading Policy

  • โœ… Allowed: Environment variables, .env files
  • โŒ Not Allowed: JSON config files, hardcoded keys
  • ๐Ÿ”’ Security: HeySolConfig.from_env() only reads from environment variables
  • ๐Ÿšซ No Fallback: Config files are never loaded automatically

Programmatic Configuration

from heysol import HeySolClient, HeySolConfig

# Load from environment (recommended)
client = HeySolClient()  # Uses HeySolConfig.from_env() automatically

# Or load explicitly
config = HeySolConfig.from_env()
client = HeySolClient(config=config)

Registry System (NEW!)

The HeySol API Client now includes a powerful registry system for managing multiple HeySol instances using email-based identifiers.

Registry Features

  • ๐Ÿ“ง Email-Based Identifiers: Use human-readable email addresses instead of cryptic API keys
  • ๐Ÿ”„ Cross-Instance Operations: Move and copy logs between different instances
  • ๐Ÿ—๏ธ Automatic Resolution: Registry automatically resolves emails to API keys and base URLs
  • ๐Ÿ”’ Secure Storage: API keys stored securely in .env files with email associations
  • ๐Ÿ–ฅ๏ธ CLI Integration: Full command-line interface for registry management

Registry CLI Commands

# List all registered instances
heysol registry list

# Show details for a specific instance
heysol registry show iDrDex@MammoChat.com

# Set active instance
heysol registry use iDrDex@MammoChat.com

# Load instances from .env file
heysol registry register

Cross-Instance Memory Operations

# Copy logs from one instance to another
heysol memory copy iDrDex@MammoChat.com HadleyLaboratory@gmail.com --confirm

# Move logs between instances
heysol memory move iDrDex@gmail.com iDrDex@MammoChat.com --confirm

# Search logs in a specific instance
heysol memory search iDrDex@MammoChat.com "cancer research" --limit 10

# Ingest data into a specific instance
heysol memory ingest iDrDex@MammoChat.com "Clinical findings" --space-id "research"

Registry Configuration

Create a .env file with multiple instances:

# .env
# iDrDex@MammoChat.com
HEYSOL_API_KEY=your-api-key-here

# HadleyLaboratory@gmail.com
HEYSOL_API_KEY=your-api-key-here

# iDrDex@gmail.com
HEYSOL_API_KEY=your-api-key-here

The registry automatically parses the email comments and associates them with the corresponding API keys.

API Reference

Core Methods

Memory Operations:

  • ingest(message, space_id=None) - Add data to memory
  • search(query, space_ids=None, limit=10) - Search memories
  • search_knowledge_graph(query, space_id=None) - Graph search

Space Operations:

  • get_spaces() - List all spaces
  • create_space(name, description="") - Create new space
  • update_space(space_id, name=None, description=None) - Update space
  • delete_space(space_id, confirm=False) - Delete space

Log Operations:

  • get_ingestion_logs(space_id=None, limit=100) - Get logs
  • check_ingestion_status(run_id=None) - Check status

Webhook Operations:

  • register_webhook(url, events=None, secret="") - Create webhook
  • list_webhooks(space_id=None) - List webhooks

Error Handling

from heysol import HeySolError, AuthenticationError

try:
    result = client.search("query")
except AuthenticationError:
    print("Check your API key")
except HeySolError as e:
    print(f"API error: {e}")

Examples & Documentation

Interactive Notebooks

Documentation

Testing

pytest                    # Run all tests
pytest --cov=heysol      # With coverage
pytest -m "unit"         # Unit tests only

Development

git clone https://github.com/HadleyLab/heysol-api-client.git
cd heysol-api-client
pip install -e ".[dev]"
pre-commit install

Changelog

v0.9.2 (2025-09-28) - GitHub Preparation Release

  • ๐Ÿ–ฅ๏ธ CLI Enhancement: Added logs get-by-source command for filtering logs by source identifier
  • ๐Ÿ–ฅ๏ธ CLI Enhancement: Added logs sources command to list all unique sources from memory logs
  • ๐Ÿ“‹ Log Management: Enhanced log filtering capabilities with dedicated source-based queries
  • ๐Ÿ”ง CLI Commands: Renamed log commands to follow API naming conventions
  • ๐Ÿ“š Documentation: Refreshed all documentation for GitHub presentation
  • ๐Ÿ”ง Version Alignment: Synchronized version numbers across all configuration files

v0.9.1 (2025-09-24) - Registry System Release

  • ๐Ÿ—๏ธ Multi-Instance Registry System - Email-based registry for managing multiple HeySol instances
  • ๐Ÿ”„ Cross-Instance Operations - Move and copy logs between different instances
  • ๐Ÿ“ง Email-Based Identifiers - Human-readable email addresses instead of cryptic API keys
  • ๐Ÿ–ฅ๏ธ Enhanced CLI - Registry-aware commands for all memory operations
  • ๐Ÿ“š Updated Documentation - Comprehensive registry system documentation and examples
  • ๐Ÿ”’ Secure Configuration - Multi-instance support in .env files with email associations

v0.9.0 (2025-09-23)

  • ๐Ÿ–ฅ๏ธ CLI Tool: Complete command-line interface for all operations (heysol-client)
  • ๐Ÿ” Source Filtering: MCP-based source filtering for logs and search operations
  • ๐Ÿ”„ MCP Protocol Support: Full Model Context Protocol integration with 100+ tools
  • ๐Ÿ“ Memory Management: Ingest, search, and manage memory spaces
  • ๐Ÿ—๏ธ Space Operations: Complete CRUD operations for memory spaces
  • ๐Ÿ“Š Log Management: Get, list, and delete ingestion logs with source filtering
  • ๐Ÿ‘ค User Profile: Get current user profile information
  • ๐Ÿ›ก๏ธ Error Handling: Comprehensive exception hierarchy with retry mechanisms
  • โš™๏ธ Configuration: Flexible configuration via environment variables, files, or parameters

v0.8.0 (2025-09-22)

  • ๐Ÿš€ Full HeySol API coverage with MCP protocol support
  • ๐Ÿ–ฅ๏ธ Complete CLI interface for all operations
  • ๐Ÿ“ Memory space management with search and ingestion
  • ๐Ÿ›ก๏ธ Robust error handling with validation
  • ๐Ÿ“Š Rate limiting and performance optimizations

License

MIT License - see LICENSE file for details.

Support

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

heysol_api_client-0.9.2.tar.gz (132.8 kB view details)

Uploaded Source

Built Distribution

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

heysol_api_client-0.9.2-py3-none-any.whl (155.0 kB view details)

Uploaded Python 3

File details

Details for the file heysol_api_client-0.9.2.tar.gz.

File metadata

  • Download URL: heysol_api_client-0.9.2.tar.gz
  • Upload date:
  • Size: 132.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for heysol_api_client-0.9.2.tar.gz
Algorithm Hash digest
SHA256 bb2a0a577356a0ac2d0e2e8e303c9feefaa77dca20511ea13f1d74bd74abc09b
MD5 c39a9bb5311016831ccf8b4b3d587a9f
BLAKE2b-256 73c83353a8430554a165d09573ed75bc02bf179a7484e201dd833e2c8ac07169

See more details on using hashes here.

File details

Details for the file heysol_api_client-0.9.2-py3-none-any.whl.

File metadata

File hashes

Hashes for heysol_api_client-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d03bdfa398f94eae519b62115262802e3c6c858b4eef799b889068563df433e4
MD5 7dc1ab23de7ae31a305c705e55e70e73
BLAKE2b-256 7921971c32477a541dd6ad6dda3585a518be62bd02f95a1eca6b2f362b425fe3

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