Skip to main content

Python SDK to integrate and interact with Hermes Marketing Automation Platform

Project description

Hermes Messaging SDK

Python Version License

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 workflow
  • bulk_trigger_workflow(workflow_id, data) - Trigger multiple workflows

AsyncHermesClient

Async Methods:

  • async trigger_workflow(workflow_id, data=None) - Trigger a single workflow
  • async 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

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

basalam_hermes_messaging_sdk-0.0.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

basalam_hermes_messaging_sdk-0.0.4-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file basalam_hermes_messaging_sdk-0.0.4.tar.gz.

File metadata

File hashes

Hashes for basalam_hermes_messaging_sdk-0.0.4.tar.gz
Algorithm Hash digest
SHA256 abb904e3d36fd3113a77a2822088a7dd5ee3695a439c0a133e1e691eb171448f
MD5 157ba0db1961e9735b14f9578d2f1946
BLAKE2b-256 ef145b2ea0ced1a864fd5fb75d0674d2ecbba11aeae64ab677412ddd18fdd417

See more details on using hashes here.

File details

Details for the file basalam_hermes_messaging_sdk-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for basalam_hermes_messaging_sdk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7adfaec8b21fd39b7faa50a3eab82341389779d8f28722349fa7d090ebc2ff45
MD5 ef5f55de8dcc54c1011c8656b3c32646
BLAKE2b-256 82ee18aa40a2529aa79d19aedc9e968bfd736c6611d1dc7dfa2db0d3fa2fb89c

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