Apprise: Universal Push Notifications

raw JSON →
1.9.9 verified Wed May 13 auth: no python install: verified

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.

pip install apprise
error ModuleNotFoundError: No module named 'apprise'
cause The 'apprise' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install apprise'.
error AttributeError: module 'apprise' has no attribute 'Apprise'
cause Incorrect import statement; 'Apprise' is a class within the 'apprise' module.
fix
Use the correct import: 'from apprise import Apprise'.
error TypeError: notify() missing 1 required positional argument: 'body'
cause The 'notify()' method requires at least the 'body' argument to be provided.
fix
Ensure to pass the 'body' argument: 'apobj.notify(body='Your message here')'.
error ValueError: Invalid URL: 'mailto://user:pass@example.com'
cause The notification service URL is incorrectly formatted or contains invalid credentials.
fix
Verify and correct the URL format and credentials: 'apobj.add('mailto://user:pass@example.com')'.
error RuntimeError: There is no current event loop in thread 'Thread-2'.
cause Attempting to use asynchronous methods without an active event loop.
fix
Ensure an event loop is running: 'import asyncio; asyncio.run(main())'.
breaking Version 1.9.4 introduced a major code refactor for Python 3.9+ compatibility. While efforts were made to maintain backward compatibility, users running older Python versions (pre-3.9) might experience unexpected behavior or require adjustments to their code.
fix Ensure your environment uses Python 3.9 or newer. Review your code for any reliance on internal APIs or behaviors that might have changed during the refactor.
gotcha Many notification services have specific optional dependencies that are not installed by default with `pip install apprise`. Forgetting to install these can lead to runtime `ImportError` exceptions when trying to use certain services.
fix Install Apprise with the specific extras needed for your services (e.g., `pip install 'apprise[slack,telegram]'`) or install all optional dependencies with `pip install 'apprise[all]'`.
gotcha Notification service URLs are critical for Apprise functionality. Incorrectly formatted URLs, missing authentication tokens, or invalid endpoints are common sources of errors that can prevent notifications from being sent.
fix Always refer to the official Apprise documentation (AppriseIt.com) for the correct URL syntax and required parameters for each service. Utilize environment variables or a secure configuration management system for sensitive credentials.
gotcha The `Apprise` object is designed to be initialized once and reused throughout your application's lifecycle. Repeatedly creating new `Apprise` instances (e.g., inside a loop or for every notification) can lead to unnecessary overhead and inefficient resource usage.
fix Initialize `Apprise` once, typically at application startup, and reuse the `apobj` instance for all subsequent notifications. Call `apobj.add()` for each unique service URL.
pip install 'apprise[all]'
python os / libc variant status wheel install import disk mem side effects
3.10 alpine (musl) all wheel - 0.72s 33.5M 12.9M clean
3.10 alpine (musl) all - - 0.72s 32.8M 12.8M -
3.10 alpine (musl) apprise wheel - 0.72s 33.5M 12.9M clean
3.10 alpine (musl) apprise - - 0.70s 32.8M 12.8M -
3.10 slim (glibc) all wheel 3.0s 0.67s 35M 12.9M clean
3.10 slim (glibc) all - - 0.72s 34M 12.8M -
3.10 slim (glibc) apprise wheel 2.9s 0.65s 35M 12.9M clean
3.10 slim (glibc) apprise - - 0.72s 34M 12.8M -
3.11 alpine (musl) all wheel - 1.11s 37.5M 14.3M clean
3.11 alpine (musl) all - - 1.25s 36.7M 14.3M -
3.11 alpine (musl) apprise wheel - 1.13s 37.5M 14.3M clean
3.11 alpine (musl) apprise - - 1.24s 36.7M 14.3M -
3.11 slim (glibc) all wheel 3.1s 1.01s 39M 14.3M clean
3.11 slim (glibc) all - - 0.97s 38M 14.3M -
3.11 slim (glibc) apprise wheel 2.9s 1.04s 39M 14.3M clean
3.11 slim (glibc) apprise - - 1.02s 38M 14.3M -
3.12 alpine (musl) all wheel - 1.16s 29.0M 14.4M clean
3.12 alpine (musl) all - - 1.22s 28.1M 14.4M -
3.12 alpine (musl) apprise wheel - 1.24s 29.0M 14.4M clean
3.12 alpine (musl) apprise - - 1.25s 28.1M 14.4M -
3.12 slim (glibc) all wheel 2.8s 1.24s 30M 14.4M clean
3.12 slim (glibc) all - - 1.26s 29M 14.4M -
3.12 slim (glibc) apprise wheel 2.8s 1.25s 30M 14.4M clean
3.12 slim (glibc) apprise - - 1.34s 29M 14.4M -
3.13 alpine (musl) all wheel - 1.11s 28.8M 14.7M clean
3.13 alpine (musl) all - - 1.31s 27.8M 14.7M -
3.13 alpine (musl) apprise wheel - 1.13s 28.8M 14.7M clean
3.13 alpine (musl) apprise - - 1.21s 27.8M 14.7M -
3.13 slim (glibc) all wheel 3.0s 1.18s 30M 14.7M clean
3.13 slim (glibc) all - - 1.25s 29M 14.7M -
3.13 slim (glibc) apprise wheel 2.9s 1.12s 30M 14.7M clean
3.13 slim (glibc) apprise - - 1.36s 29M 14.7M -
3.9 alpine (musl) all wheel - 0.49s 32.9M 12.7M clean
3.9 alpine (musl) all - - 0.52s 32.3M 12.7M -
3.9 alpine (musl) apprise wheel - 0.48s 32.9M 12.7M clean
3.9 alpine (musl) apprise - - 0.56s 32.3M 12.7M -
3.9 slim (glibc) all wheel 3.7s 0.50s 34M 12.7M clean
3.9 slim (glibc) all - - 0.46s 33M 12.7M -
3.9 slim (glibc) apprise wheel 3.6s 0.47s 34M 12.7M clean
3.9 slim (glibc) apprise - - 0.53s 33M 12.7M -

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.")