Skip to main content

Python SDK for isend.ai - Send emails easily using email connectors like SES, SendGrid, and more

Project description

isend.ai Python SDK

A simple Python SDK for sending emails through isend.ai using various email connectors like AWS SES, SendGrid, Mailgun, and more.

Installation

Using pip

pip install isend-ai

From source

git clone https://github.com/isend-ai/python-sdk.git
cd python-sdk
pip install -e .

Quick Start

from isend import ISendClient

# Initialize the client
client = ISendClient('your-api-key-here')

# Send email using template
email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)
print(response)

Usage

Send Email Using Template

from isend import ISendClient

client = ISendClient('your-api-key-here')

email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)

Custom Configuration

from isend import ISendClient

# Initialize with custom timeout
client = ISendClient('your-api-key-here', config={'timeout': 60})

email_data = {
    'template_id': 124,
    'to': 'hi@isend.ai',
    'dataMapping': {
        'name': 'ISend'
    }
}

response = client.send_email(email_data)

API Reference

ISendClient

Constructor

ISendClient(api_key: str, config: Optional[Dict[str, Any]] = None)

Parameters:

  • api_key (str): Your isend.ai API key
  • config (dict, optional): Additional configuration options
    • timeout (int): Request timeout in seconds (default: 30)

Methods

send_email(email_data: Dict[str, Any]) -> Dict[str, Any]

Sends an email using the provided template and data.

Parameters:

  • email_data (dict): Email data including:
    • template_id (int): The template ID to use
    • to (str): Recipient email address
    • dataMapping (dict): Data mapping for template variables

Returns:

  • dict: Response from the API

Error Handling

The SDK raises exceptions for any errors:

from isend import ISendClient
import requests

try:
    client = ISendClient('your-api-key-here')
    response = client.send_email({
        'template_id': 124,
        'to': 'hi@isend.ai',
        'dataMapping': {
            'name': 'ISend'
        }
    })
    print("Email sent successfully!")
    print(response)
except ValueError as e:
    print(f"Validation error: {e}")
except requests.RequestException as e:
    print(f"Network error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

Examples

See the examples/ directory for complete usage examples.

Development

Setup Development Environment

git clone https://github.com/isend-ai/python-sdk.git
cd python-sdk
pip install -r requirements-dev.txt

Running Tests

# Run all tests
pytest

# Run tests with coverage
pytest --cov=isend

# Run tests with verbose output
pytest -v

Code Formatting

# Format code with black
black .

# Check code style with flake8
flake8 .

# Type checking with mypy
mypy .

Requirements

  • Python 3.6 or higher
  • requests library

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for your changes
  5. Run the test suite
  6. Submit a pull request

Support

For support, email support@isend.ai or create an issue on GitHub.

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

isend_ai-1.0.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

isend_ai-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file isend_ai-1.0.0.tar.gz.

File metadata

  • Download URL: isend_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for isend_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 304b69eaa1c0cb9a417d041fd07249d7feb2e4fdf4cbd5a1fa6182f93ae678d7
MD5 ca3a28a570cb2a5cfe6321f4ebd54d66
BLAKE2b-256 35bd05e961194f820049ab70f968d17819208be740f63f04c92e99558aa3e0b5

See more details on using hashes here.

File details

Details for the file isend_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: isend_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for isend_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cf5fb2c2dfe453bbd3f2c7180d32072126a99c7e5b1be761dd27f3fabd8c326
MD5 e7b621636152cd47873a5855fdc27bb7
BLAKE2b-256 cf7dcad7c18770fe195b19a06af8817d2b5f3098a310613f55152580072d668f

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