Python SDK for IndiePitcher
Project description
IndiePitcher Python SDK
Official Python SDK for IndiePitcher
Installation
# Install with pip
pip install indiepitcher
# Or install with uv (recommended)
uv pip install indiepitcher
Quick Start
from indiepitcher import IndiePitcherClient, SendEmail, EmailBodyFormat
# Initialize the client with your API key
client = IndiePitcherClient(api_key="your_api_key")
# or for async environments
# client = IndiePitcherAsyncClient(api_key="your_api_key")
# Send a transactional email
email = SendEmail(
to="recipient@example.com",
subject="Hello from IndiePitcher!",
body="This is a **markdown** email sent via the IndiePitcher Python SDK.",
body_format=EmailBodyFormat.MARKDOWN
)
response = client.send_email(email)
print(f"Email sent successfully: {response.success}")
Features
- Sync and async variants for all requests
- Send transactional emails with Markdown or HTML content
- Create and manage contacts
- Send emails to contacts or mailing lists
- Create portal sessions for users to manage their subscriptions
Documentation
For detailed documentation, visit docs.indiepitcher.com.
Working with Contacts
from indiepitcher import IndiePitcherClient, CreateContact
client = IndiePitcherClient(api_key="your_api_key")
# Create a new contact
contact = CreateContact(
email="user@example.com",
name="Example User",
subscribed_to_lists=["newsletter"],
custom_properties={"favorite_color": "blue"}
)
response = client.create_contact(contact)
# Get a contact
contact = client.get_contact("user@example.com")
print(contact.data.name) # "Example User"
# List contacts with pagination
contacts = client.list_contacts(page=1, per_page=50)
for contact in contacts.data:
print(contact.email)
Sending Emails to Mailing Lists
from indiepitcher import IndiePitcherClient, SendEmailToMailingList, EmailBodyFormat
from datetime import datetime, timedelta
client = IndiePitcherClient(api_key="your_api_key")
# Send an email to a mailing list
email = SendEmailToMailingList(
subject="Newsletter #1",
body="# Welcome to our newsletter\n\nThanks for subscribing!",
body_format=EmailBodyFormat.MARKDOWN,
list="newsletter",
track_email_opens=True,
track_email_link_clicks=True,
# Schedule the email for future delivery
delay_until_date=datetime.now() + timedelta(days=1)
)
response = client.send_email_to_mailing_list(email)
Async Support
The SDK also provides an asynchronous client for use in async applications:
import asyncio
from indiepitcher import IndiePitcherAsyncClient, SendEmail, EmailBodyFormat
async def send_email_example():
async with IndiePitcherAsyncClient(api_key="your_api_key") as client:
# Send a transactional email
email = SendEmail(
to="recipient@example.com",
subject="Hello from IndiePitcher!",
body="This is a **markdown** email sent via the IndiePitcher Python SDK.",
body_format=EmailBodyFormat.MARKDOWN
)
response = await client.send_email(email)
return response.success
# Run in an async context
success = asyncio.run(send_email_example())
print(f"Email sent successfully: {success}")
The async client supports all the same methods as the synchronous client, but requires the await keyword and should be used within an async context.
Development
Setting Up the Development Environment
For fast dependency installation, we recommend using UV:
# Install UV if you don't have it
pip install uv
# Create a virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
# Run tests
uv run pytest
Testing
# Run tests
pytest
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
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 indiepitcher-0.1.0.tar.gz.
File metadata
- Download URL: indiepitcher-0.1.0.tar.gz
- Upload date:
- Size: 35.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f70681d55e9ed752f169a90c48cec149e9bfd801b95c4072360890e20d6f32b
|
|
| MD5 |
8ce6b2a9af157b087bdac8e9de0c4b6f
|
|
| BLAKE2b-256 |
1b54d4493a1d04e1b9d90c5ee14f2591b256992cc6d8b34e6313cbe12a969e1e
|
File details
Details for the file indiepitcher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: indiepitcher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6e40ceac8f73923eed0c89371459e07a9b05fdc97693f6a70a1e951df65b35f
|
|
| MD5 |
38880a7787135a31862e409c3f93c0be
|
|
| BLAKE2b-256 |
f7e7f9e43a9fc16a470909125620c59cf1c88cd538541b363ef734237430bfa6
|