A comprehensive Python client for the HeySol API with MCP protocol support, built by Dexter Hadley, MD/PhD
Project description
HeySol API Client
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 1.2.0 - 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
- Get your API key from HeySol Core
- Set environment variable:
export HEYSOL_API_KEY="your-api-key-here"
- 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,
.envfiles - โ 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
.envfiles 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 memorysearch(query, space_ids=None, limit=10)- Search memoriessearch_knowledge_graph(query, space_id=None)- Graph search
Space Operations:
get_spaces()- List all spacescreate_space(name, description="")- Create new spaceupdate_space(space_id, name=None, description=None)- Update spacedelete_space(space_id, confirm=False)- Delete space
Log Operations:
get_ingestion_logs(space_id=None, limit=100)- Get logscheck_ingestion_status(run_id=None)- Check status
Webhook Operations:
register_webhook(url, events=None, secret="")- Create webhooklist_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
- ๐
quick_start.ipynb- Python API walkthrough - ๐
examples/api_endpoints_demo.ipynb- API endpoints demonstration - ๐
examples/client_types_demo.ipynb- Client types comparison - ๐
examples/comprehensive_client_demo.ipynb- Full client capabilities - ๐
examples/error_handling_demo.ipynb- Error handling patterns - ๐
examples/log_management_demo.ipynb- Log management
Documentation
- ๐ API Documentation - Complete API reference
- ๐ Testing Report - Comprehensive testing documentation
- ๐ API vs MCP Analysis - Protocol comparison guide
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-sourcecommand for filtering logs by source identifier - ๐ฅ๏ธ CLI Enhancement: Added
logs sourcescommand 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
- ๐ง Email: iDrDex@HadleyLab.org
- ๐ Docs: https://docs.heysol.ai/api-reference
- ๐ Issues: https://github.com/HadleyLab/heysol-api-client/issues
- ๐ค Author: Dexter Hadley, MD/PhD (HadleyLab)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file heysol_api_client-1.2.0.tar.gz.
File metadata
- Download URL: heysol_api_client-1.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72bc9d2ad21bbd9c8bcc4f6849069654abf37dcc6c80582cf432f3a40dea3093
|
|
| MD5 |
fd33f5fde6122494b296f3000a8cd490
|
|
| BLAKE2b-256 |
61f12de3990bf264df03eaf3fa7d9e3059d3a6d42b0abe1002a34d58aa64b882
|
File details
Details for the file heysol_api_client-1.2.0-py3-none-any.whl.
File metadata
- Download URL: heysol_api_client-1.2.0-py3-none-any.whl
- Upload date:
- Size: 155.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4689c2465c7951e81b270c78ecd4c9c0ec1d9e162756cc8b4ae23f8d720c03f8
|
|
| MD5 |
fc7ddf2012510bb9ea34ddfb50f6dc92
|
|
| BLAKE2b-256 |
25224433b96b74a20bae2565906c204882efe69fb340ff83c9f6061abd0dc502
|