The official Python library for the Courier API
Project description
Courier Python SDK
The Courier Python SDK provides typed access to the Courier REST API from any Python 3.9+ application. It includes synchronous and asynchronous clients, Pydantic response models, TypedDict request params, and automatic retries.
Installation
pip install trycourier
Also available via poetry add trycourier and pipenv install trycourier.
Quick Start
from courier import Courier
client = Courier()
response = client.send.message(
message={
"to": {"email": "you@example.com"},
"content": {
"title": "Hello from Courier!",
"body": "Your first notification, sent with the Python SDK.",
},
},
)
print(response.request_id)
The client reads COURIER_API_KEY from your environment automatically. You can also pass it explicitly: Courier(api_key='your-key').
Async usage
Import AsyncCourier instead of Courier and use await:
import asyncio
from courier import AsyncCourier
client = AsyncCourier()
async def main():
response = await client.send.message(
message={
"to": {"email": "you@example.com"},
"content": {
"title": "Hello from Courier!",
"body": "Sent from the async Python client.",
},
},
)
print(response.request_id)
asyncio.run(main())
Common Operations
# Check message delivery status
message = client.messages.retrieve("message-id")
print(message.status)
# Create or update a user profile
client.profiles.create("user_123", profile={
"email": "jane@example.com",
"name": "Jane Doe",
})
# Issue a JWT for client-side SDK auth
result = client.auth.issue_token(
scope="user_id:user_123 inbox:read:messages inbox:write:events",
expires_in="2 days",
)
Documentation
Full documentation: courier.com/docs/sdk-libraries/python
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 trycourier-7.11.2.tar.gz.
File metadata
- Download URL: trycourier-7.11.2.tar.gz
- Upload date:
- Size: 204.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f742a33792f71244008fa1c8c750b6ac34e5a6e639da9d65abeba319e7324834
|
|
| MD5 |
faf2b87d7ab323b9e76d2daee9bb1ef4
|
|
| BLAKE2b-256 |
02d4cd839c1c79cc0e79d31c9fba11eaa8477fd486d4784ce81dcba33f17b234
|
File details
Details for the file trycourier-7.11.2-py3-none-any.whl.
File metadata
- Download URL: trycourier-7.11.2-py3-none-any.whl
- Upload date:
- Size: 313.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7122b15e436e330b6a35e40c3cb71c01ed9434aa2249012906a68b038b11e31
|
|
| MD5 |
18bf9485e2c957dbf7efb1d6357f7d8c
|
|
| BLAKE2b-256 |
9b6164a6b189073e4a21012cc5e51e0f44af3d95c47d4f1ad289173e18b553c7
|