Notifiers

1.3.6 · active · verified Tue Apr 14

Notifiers is a Python library that provides a unified and simple interface for sending notifications through various providers like Pushover, Slack, Email, and Telegram. It aims to simplify the process of integrating notifications into applications and scripts without needing to implement individual provider APIs. The current version is 1.3.6, with releases occurring periodically, focusing on new provider additions, bug fixes, and maintenance.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to send a notification using the 'pushover' provider. It fetches credentials from environment variables (or placeholders) and uses the `get_notifier` function. It also explicitly sets `raise_on_errors=True` for robust error handling.

import os
from notifiers import get_notifier

pushover_token = os.environ.get('NOTIFIERS_PUSHOVER_TOKEN', 'YOUR_PUSHOVER_API_TOKEN')
pushover_user = os.environ.get('NOTIFIERS_PUSHOVER_USER', 'YOUR_PUSHOVER_USER_KEY')

if pushover_token and pushover_user:
    pushover = get_notifier('pushover')
    try:
        # Ensure required parameters are provided. Check pushover.required or pushover.schema
        # for details. Using raise_on_errors=True for explicit error handling.
        response = pushover.notify(
            token=pushover_token,
            user=pushover_user,
            message='Hello from notifiers!',
            title='Python Notification',
            raise_on_errors=True
        )
        if response.status == 'success':
            print(f"Pushover notification sent successfully: {response.data}")
        else:
            print(f"Pushover notification failed: {response.errors}")
    except Exception as e:
        print(f"An error occurred while sending notification: {e}")
else:
    print("Pushover API token and user key not set. Please set NOTIFIERS_PUSHOVER_TOKEN and NOTIFIERS_PUSHOVER_USER environment variables or hardcode them.")

view raw JSON →