Apprise: Universal Push Notifications

1.9.9 · active · verified Thu Apr 09

Apprise is a Python library that provides a common, simple interface for sending push notifications to almost any platform. It supports a vast array of services, including Slack, Discord, email, SMS, Telegram, and many more, allowing developers to integrate notifications without platform-specific code. It maintains an active development pace with several releases per year, continuously adding new services and improving existing ones. The current version is 1.9.9.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize Apprise, add a notification service URL, and send a basic notification. It also shows how to include a dummy URL for testing output to stdout. For real services, replace `APPRISE_SLACK_URL` with your actual service URL, retrieved from environment variables for security. Remember to install extra dependencies if your chosen service requires them.

import apprise
import os

# Create an Apprise instance
apobj = apprise.Apprise()

# Add a service URL.
# Use a real service URL or a dummy one like 'pypi://' for stdout output.
# Example for Slack: 'slack://tokenA/tokenB/tokenC'
# Example for Telegram: 'tgram://bottoken/chatid'
# Replace with your actual URL. Using os.environ.get for security.
slack_url = os.environ.get('APPRISE_SLACK_URL', 'pypi://')
apobj.add(slack_url)

# Send a notification
apobj.notify(
    body='Hello from Apprise!',
    title='Apprise Quickstart',
    notify_type='info' # info, success, warning, failure
)

print(f"Notification sent (or printed to stdout if using pypi://): {slack_url}")

# Example with a file attachment (requires AppriseAsset and a valid service)
# from apprise import AppriseAsset
# try:
#    with open('example.txt', 'w') as f:
#        f.write('This is an example attachment.')
#    apobj.add('mailto://user@example.com') # Example service supporting attachments
#    apobj.notify(
#        body='Message with an attachment.',
#        attach=AppriseAsset('example.txt')
#    )
# except IOError: # mailto will silently fail without a server
#    print("Could not create example.txt or send attachment.")

view raw JSON →