Official Python SDK for Unosend - Email API Service
Project description
unosend
Official Python SDK for Unosend - Email API Service.
Installation
pip install unosend
Quick Start
from unosend import Unosend
unosend = Unosend("un_your_api_key")
# Send an email
response = unosend.emails.send(
from_address="hello@yourdomain.com",
to="user@example.com",
subject="Hello from Unosend!",
html="<h1>Welcome!</h1><p>Thanks for signing up.</p>"
)
if response.error:
print(f"Failed to send: {response.error.message}")
else:
print(f"Email sent: {response.data.id}")
Features
- 📧 Emails - Send transactional emails with HTML/text content
- 🌐 Domains - Manage and verify sending domains
- 👥 Audiences - Create and manage contact lists
- 📇 Contacts - Add, update, and remove contacts
API Reference
Emails
# Send an email
response = unosend.emails.send(
from_address="you@yourdomain.com",
to=["user1@example.com", "user2@example.com"],
subject="Hello!",
html="<h1>Hello World</h1>",
text="Hello World", # Optional plain text version
reply_to="support@yourdomain.com",
cc=["cc@example.com"],
bcc=["bcc@example.com"],
headers={"X-Custom-Header": "value"},
tags=[{"name": "campaign", "value": "welcome"}]
)
# Get email by ID
response = unosend.emails.get("email_id")
# List emails
response = unosend.emails.list(limit=10, offset=0)
Domains
# Add a domain
response = unosend.domains.create("yourdomain.com")
# Verify domain DNS records
response = unosend.domains.verify("domain_id")
# List domains
response = unosend.domains.list()
# Delete domain
response = unosend.domains.delete("domain_id")
Audiences
# Create an audience
response = unosend.audiences.create("Newsletter Subscribers")
# List audiences
response = unosend.audiences.list()
# Get audience
response = unosend.audiences.get("audience_id")
# Delete audience
response = unosend.audiences.delete("audience_id")
Contacts
# Add a contact
response = unosend.contacts.create(
"audience_id",
email="user@example.com",
first_name="John",
last_name="Doe"
)
# List contacts in an audience
response = unosend.contacts.list("audience_id")
# Update a contact
response = unosend.contacts.update(
"contact_id",
first_name="Jane",
unsubscribed=False
)
# Delete a contact
response = unosend.contacts.delete("contact_id")
Error Handling
All methods return an ApiResponse with data and error attributes:
response = unosend.emails.send(...)
if response.error:
print(f"Error {response.error.code}: {response.error.message}")
else:
print(f"Success: {response.data}")
# Or use tuple unpacking
data, error = unosend.emails.send(...)
if error:
print(f"Failed: {error.message}")
Configuration
# Custom base URL (for self-hosted instances)
unosend = Unosend(
"un_your_api_key",
base_url="https://your-instance.com/api/v1"
)
Context Manager
with Unosend("un_your_api_key") as unosend:
response = unosend.emails.send(...)
# Client is automatically closed
License
MIT
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
unosend-1.0.0.tar.gz
(4.8 kB
view details)
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 unosend-1.0.0.tar.gz.
File metadata
- Download URL: unosend-1.0.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a8bbca02cb3179816ddb7547f13ba3c627eb7d2abd0e568fb0b6b1f9b6f96e
|
|
| MD5 |
19fa037cf942f5b8fa6b953754563688
|
|
| BLAKE2b-256 |
08decc513d83abb8fd602e7cfffc2728b1aa2268f5bd7a820b123f59f27f4525
|
File details
Details for the file unosend-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unosend-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b86eee61e7e92c2b6d96609ba2375a5aef72efefab7acf392dea3d3405a70934
|
|
| MD5 |
44e31eac5e8f8e840313a4b788cd7d38
|
|
| BLAKE2b-256 |
9bf124e5e354655ae3e67c5edc465c69761b7d28f2549fe3b6a85cec55aa41c8
|