Python SDK to integrate and interact with Hermes Marketing Automation Platform
Project description
Hermes Messaging SDK
A lightweight Python SDK for integrating with the Hermes Marketing Automation Platform. This SDK provides both synchronous and asynchronous clients for triggering workflows.
Features
- 🚀 Simple API: Easy-to-use client for triggering workflows
- ⚡ Async Support: Full async/await support for high-performance applications
- 🔄 Retry Logic: Built-in exponential backoff retry mechanism
- 🛡️ Error Handling: Comprehensive error handling with custom exceptions
Installation
pip install basalam.hermes-messaging-sdk
Quick Start
Synchronous Usage
from basalam.hermes_messaging_sdk import HermesClient
# Initialize the client
client = HermesClient(access_token="your-access-token-here")
# Trigger a single workflow
client.trigger_workflow(
workflow_id=123,
data={
"user_id": 456,
"product_id": "abc123"
}
)
# Bulk trigger workflows
client.bulk_trigger_workflow(
workflow_id=123,
data=[
{"user_id": 456, "amount": "10,000,000"},
{"user_id": 789, "amount": "1,000,000"}
]
)
Asynchronous Usage
import asyncio
from basalam.hermes_messaging_sdk import AsyncHermesClient
async def main():
client = AsyncHermesClient(access_token="your-access-token")
# Trigger a single workflow
await client.trigger_workflow(
workflow_id=123,
data={
"user_id": 456,
"product_id": "abc123"
}
)
# Bulk trigger workflows
await client.bulk_trigger_workflow(
workflow_id=456,
data=[
{"user_id": 789, "amount": "10,000,000"},
{"user_id": 101, "amount": "4,000,000"}
]
)
asyncio.run(main())
Configuration
Both HermesClient and AsyncHermesClient support the following configuration options:
client = HermesClient(
access_token="your-access-token", # Required: Your Hermes API token
base_url="https://hermes.basalam.com", # Optional: Custom base URL
timeout=30, # Optional: Request timeout in seconds
max_retries=3, # Optional: Maximum retry attempts
retry_delay=1.0 # Optional: Base delay for exponential backoff
)
Retry Configuration
The SDK includes built-in retry logic with exponential backoff:
- max_retries: Number of retry attempts (default: 3)
- retry_delay: Base delay in seconds (default: None, disabled)
- When enabled, uses exponential backoff:
retry_delay * (2 ** attempt)
Error Handling
The SDK provides comprehensive error handling with custom exceptions:
from basalam.hermes_messaging_sdk import (
HermesClient,
HermesError,
HermesAPIError,
HermesConnectionError,
HermesAuthorizationError
)
try:
client = HermesClient(access_token="invalid-token")
client.trigger_workflow(workflow_id=123, data={"test": "data"})
except HermesAuthorizationError as e:
print(f"Authorization failed: {e}")
print(f"Status code: {e.status_code}")
except HermesAPIError as e:
print(f"API error: {e}")
print(f"Status code: {e.status_code}")
except HermesConnectionError as e:
print(f"Connection error: {e}")
except HermesError as e:
print(f"Hermes SDK error: {e}")
API Reference
HermesClient
Methods:
trigger_workflow(workflow_id, data=None)- Trigger a single workflowbulk_trigger_workflow(workflow_id, data)- Trigger multiple workflows
AsyncHermesClient
Async Methods:
async trigger_workflow(workflow_id, data=None)- Trigger a single workflowasync bulk_trigger_workflow(workflow_id, data)- Trigger multiple workflows
Requirements
- Python 3.8+
- httpx 0.24.0+
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- 🐛 Issues: GitHub Issues
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 basalam_hermes_messaging_sdk-0.0.5.tar.gz.
File metadata
- Download URL: basalam_hermes_messaging_sdk-0.0.5.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e8aabf4fbc079feb7623d8d70222868fe281e5fadd0186b2a8b60ada54f8fe
|
|
| MD5 |
042b95c1cf3fac62c79d03970c107514
|
|
| BLAKE2b-256 |
ab31d227acc4ed95a2fb44949cc44250b055615662b37b7a9813eae679c879a9
|
File details
Details for the file basalam_hermes_messaging_sdk-0.0.5-py3-none-any.whl.
File metadata
- Download URL: basalam_hermes_messaging_sdk-0.0.5-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bacf468bfa8f73809660e19a5583769a2d469aa468bfbcbe3f904d09a9d8495e
|
|
| MD5 |
6c877c728609307158a1810cb267b4d6
|
|
| BLAKE2b-256 |
b27c256b8bdc49c66bcd249cf228cf276b6a3f6c49eeccb78b04e0b432660744
|