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 keyconfig(dict, optional): Additional configuration optionstimeout(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 useto(str): Recipient email addressdataMapping(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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for your changes
- Run the test suite
- Submit a pull request
Support
For support, email support@isend.ai or create an issue on GitHub.
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304b69eaa1c0cb9a417d041fd07249d7feb2e4fdf4cbd5a1fa6182f93ae678d7
|
|
| MD5 |
ca3a28a570cb2a5cfe6321f4ebd54d66
|
|
| BLAKE2b-256 |
35bd05e961194f820049ab70f968d17819208be740f63f04c92e99558aa3e0b5
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cf5fb2c2dfe453bbd3f2c7180d32072126a99c7e5b1be761dd27f3fabd8c326
|
|
| MD5 |
e7b621636152cd47873a5855fdc27bb7
|
|
| BLAKE2b-256 |
cf7dcad7c18770fe195b19a06af8817d2b5f3098a310613f55152580072d668f
|