Aller au contenu

Quick Start

Ce contenu n’est pas encore disponible dans votre langue.

import apprise
apobj = apprise.Apprise()

The add() method registers notification services to your instance.

# Add a single service
apobj.add('json://localhost')
# Add multiple services at once
apobj.add([
'mailto://user:pass@example.com',
'slack://tokenA/tokenB/tokenC'
])

The notify() method sends messages to all registered services.

apobj.notify(
title="Server Alert",
body="CPU usage is at 99%",
)

You can categorize your notifications using NotifyType. This often changes the icon or color of the notification (depending on the receiving service).

from apprise import NotifyType
apobj.notify(
title="Success",
body="Backup completed successfully.",
notify_type=NotifyType.SUCCESS
)
IconTypeDescription
infoNotifyType.INFODefault. General information.
successNotifyType.SUCCESSSuccessful operations.
warningNotifyType.WARNINGIssues that aren’t fatal.
failureNotifyType.FAILURECritical errors.

Tagging allows you to send notifications to specific subgroups of services.

1. Assign Tags

# Assign tags when adding services
apobj.add('slack://...', tag='devops')
apobj.add('mailto://...', tag='management')
apobj.add('discord://...', tag=['devops', 'management']) # Multiple tags

2. Filter by Tags

# Notify ONLY services tagged 'devops'
apobj.notify(title="Deploying", body="...", tag="devops")
# Notify services tagged 'devops' OR 'management'
apobj.notify(title="Update", body="...", tag=["devops", "management"])

You can use the AppriseConfig object to load URLs from external YAML or Text files instead of hardcoding them.

import apprise
# 1. Create the Config Object
config = apprise.AppriseConfig()
# 2. Add configuration sources
config.add('/path/to/my/config.yml')
config.add('https://myserver.com/my/apprise/config')
# 3. Create Apprise instance and ingest the config
apobj = apprise.Apprise()
apobj.add(config)
# 4. Notify as usual (URLs from the file are now loaded)
apobj.notify("Loaded from config!")