Skip to main content

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

trycourier-7.12.0.tar.gz (220.7 kB view details)

Uploaded Source

Built Distribution

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

trycourier-7.12.0-py3-none-any.whl (350.3 kB view details)

Uploaded Python 3

File details

Details for the file trycourier-7.12.0.tar.gz.

File metadata

  • Download URL: trycourier-7.12.0.tar.gz
  • Upload date:
  • Size: 220.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for trycourier-7.12.0.tar.gz
Algorithm Hash digest
SHA256 ee0f6b96b33bdbc1782fbb8cb30d880d15112c30d1dda3d4ded5eed81c8d4b1d
MD5 d6880a9dbf6d7d0fab7c49235c99b934
BLAKE2b-256 aca1be1954e5696e325fea2c87dda947b42d102878b46153f324311bc8a60821

See more details on using hashes here.

File details

Details for the file trycourier-7.12.0-py3-none-any.whl.

File metadata

  • Download URL: trycourier-7.12.0-py3-none-any.whl
  • Upload date:
  • Size: 350.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for trycourier-7.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2580fe11e0ed8c88374f77c1a38e72c433118baf5a6c7aca4af72a01c64b96b7
MD5 7cbe2e3a2df6a12f81bc77af1e35cd9b
BLAKE2b-256 a9eb34d0323233707d775a060426917ee63e60bb12c4867eaa56b4798042a2f2

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