A comprehensive Python client for the HeySol API with MCP protocol support
Project description
HeySol API Client
A comprehensive Python client for the HeySol API with MCP protocol support, memory management, and CLI tools.
Version 0.9.1 - Pre-release with full API coverage.
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
- ๐ก๏ธ 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/heysol/heysol-python-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
# Profile
heysol-client profile get
# Spaces
heysol-client spaces list
heysol-client spaces create "My Space" --description "Data space"
# Memory operations
heysol-client memory ingest "Clinical data" --space-id <space-id>
heysol-client memory search "cancer research" --limit 10
# Logs
heysol-client logs list --status success
heysol-client 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
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)
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/integration_test_demo.ipynb- Integration testing - ๐
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/heysol/heysol-python-client.git
cd heysol-python-client
pip install -e ".[dev]"
pre-commit install
Changelog
v0.9.1 (2025-09-24)
- ๐ Pre-release with full API coverage and stability
- ๐ฆ PyPI Publication of 0.9.1 version
- ๐ง Version alignment across all configuration files
- ๐ Documentation updates with correct repository links
v0.9.0 (2025-09-23)
- โจ Client-side status filtering for logs CLI commands
- ๐ 6 new comprehensive example notebooks in
examples/directory - ๐ง Enhanced CLI with improved log management capabilities
- ๐งช 95%+ test coverage with comprehensive testing suite
- ๐ฆ PyPI publication ready for production use
- ๐๏ธ Pre-1.0 release with stable API
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: dev@heysol.ai
- ๐ Docs: https://docs.heysol.ai/api-reference
- ๐ Issues: https://github.com/heysol/heysol-python-client/issues
- ๐ค Author: iDrDex (HadleyLab)