Skip to main content

A Python Package for communicating with the Courier REST API.

Project description

trycourier

This Python Package helps you send notifications through Courier, the smartest way to design & deliver notifications. Design your notifications once using our drag & drop editor, then deliver to any channel through one API. Email, mobile push, SMS, Slack — you name it!

Installation

Install from PyPI using pip:

$ pip install trycourier

Python 3.5 or later is required.

Usage

Using Token Auth

from trycourier import Courier

client = Courier(auth_token="your-auth-token") #or set via COURIER_AUTH_TOKEN env var

resp = client.send(
    event="your-event-id",
    recipient="your-recipient-id",
    profile={
        "email": "example@example.com",
        "phone_number": "555-867-5309"
    },
    data={
      "world": "Python!"
    }
)
print(resp['messageId'])

Using Basic Auth

from trycourier import Courier

client = Courier(username="your-username", password="your-password")

resp = client.send(
    event="your-event-id",
    recipient="your-recipient-id",
    profile={
        "email": "example@example.com",
        "phone_number": "555-867-5309"
    },
    data={
      "world": "Python!"
    }
)
print(resp['messageId'])

Advanced Usage

from trycourier import Courier

client = Courier(auth_token="your-auth-token")

"""
Example: send a message
"""
resp = client.send(
    event="your-event-id",
    recipient="your-recipient-id",
    profile={}, # optional
    data={}, # optional
    preferences={}, # optional
    override={} # optional
)
print(resp['messageId'])

"""
Example: replace or create a recipient's profile
"""
resp = client.replace_profile(
  recipient_id,
  {
    "email": "example@example.com"
  }
)
print(resp['status'])

"""
Example: merge or create a recipient's profile
"""
resp = client.merge_profile(
  recipient_id,
  {
    "phone_number": "+15555555555"
  }
)
print(resp['status'])

"""
Example: get a recipient's profile
"""
resp = client.get_profile(recipient_id)
print(resp)

"""
Example: fetch the statuses of messages you've previously sent.
"""
resp = client.get_messages(
  cursor="MTU4OTQ5NTI1ODY4NywxLTVlYmRjNWRhLTEwODZlYWFjMWRmMjEwMTNjM2I0ZjVhMA", # optional
  recipient=recipient_id, # optional
)

"""
Example: fetch the status of a message you've previously sent
"""
resp = client.get_message(message_id)

"""
Example: fetch the list of events
"""
resp = client.get_events()

"""
Example: fetch a specific event by event ID
"""
resp = client.get_event(event_id)

"""
Example: create or replace an event map
"""
resp = client.replace_event(
  event_id,
  notification_id="GRPVB5P0BHMEZSNY6TP2X7TQHEBF",
  type="notificaton" ## optional, defaults to notification
)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/trycourier/courier-python. See CONTRIBUTING.md for more info.

License

The package is available as open source under the terms of the MIT License.

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-1.2.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

trycourier-1.2.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trycourier-1.2.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for trycourier-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e363a26b364f076e9560da2624603326067d1acdf475920f0388d2456fa0463e
MD5 4aa7125fc13b7afa34ad50712ac2bd9e
BLAKE2b-256 43b7a6001f90f28ec96701e11e478486e9cc94842225e2dd6ff6204bcde99bb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trycourier-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for trycourier-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 669005a132f66fb25c4b8200ea14dc561bc9da89965b4d4edf10af7b0c1175fb
MD5 2321fc05de2ca1c8e10a5dfa3edbc067
BLAKE2b-256 398a40012497f58f641d71ca089636b900d5fdfc4d4c5623c317a00265070726

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