Skip to main content

A Python package for sending notifications via the very fabolous ntfy from CLI or Python code with stored credentials

Project description

ntfy-notify

Installation

Using pip

pip install ntfy-notify

Using Poetry

poetry add ntfy-notify

Configuration

Create a configuration file at ~/.config/ntfy-notify/config.toml with your ntfy credentials:

# Required: Your ntfy server URL
server = "https://ntfy.server"

# Required: Your access token (if using ntfy with authentication)
token = "your_token_here"

# Required: Default topic to send notifications to
default_topic = "your_topic_here"

# Optional: Default message priority (default: "default")
# Valid values: "min", "low", "default", "high", "max"
default_priority = "default"

Usage

Python API

from ntfy_notify.core import send_notification

# Basic notification
send_notification("Hello from Python!")

# With title and priority
send_notification(
    "This is an important message",
    title="Important Update",
    priority="high"
)

# With custom topic
send_notification("This goes to a custom topic", topic="custom_topic")

# With additional options
send_notification(
    "Check out our website!",
    title="Website",
    click_url="https://example.com",
    tags=["globe_with_meridians", "link"]
)

Command Line Interface

ntfy_notify    --message "${BASH_SOURCE}:33 message" \
    --topic "topic" \
	--title "title" \
	--priority "default" \
	--tags "test_tube, building_construction" \
	--click "https://server.com/click" \
    --actions "view, act1, https://server.com/act1; \
       view, act2, https://server.com/act2"

If you want to run ntfy-notify as a root user, you may call it with the explicit path to the python interpreter:

# get the path
which ntfy_notify

# run with sudo
sudo /path/to/python/ntfy_notify --message "Test message" --topic "topic" --title "Test Title" --priority "default" --tags "test" --click "https://example.com"

Command Line Options

Usage: ntfy_notify [OPTIONS] [MESSAGE]

  Send a notification via ntfy

  If MESSAGE is not provided, reads from stdin.

Options:
  -m, --message TEXT       The message to send (required if not reading from
                          stdin)
  -t, --topic TEXT         Topic to send to (overrides config)
  --title TEXT             Message title
  -p, --priority [min|low|default|high|max]
                          Message priority
  --click-url TEXT         URL to open when notification is clicked
  --tags TEXT              Comma-separated list of tags/emojis
  --config FILE            Path to config file
  --version                Show the version and exit.
  --help                   Show this message and exit.

License

This project is licensed under the EUPL-1.2 - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Running Tests

The test suite uses pytest and can be run with:

# Install test dependencies
poetry install --with test

# Run tests
poetry run pytest -v tests/

Development

  1. Clone the repository
  2. Install dependencies:
    poetry install
    
  3. Create a test configuration file at ~/.config/ntfy-notify/config.toml
  4. Run tests to verify your setup

License

EUPL-1.2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntfy_notify-0.1.7.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

ntfy_notify-0.1.7-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file ntfy_notify-0.1.7.tar.gz.

File metadata

  • Download URL: ntfy_notify-0.1.7.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ntfy_notify-0.1.7.tar.gz
Algorithm Hash digest
SHA256 23fdb2c163effbee87aed568a418b02461b6d6745f583f818cb59bec9e7c8f78
MD5 2cba1204f9216f39fde541ec4f31f9a0
BLAKE2b-256 94a9412a020303fd137d0b0e3115a3b96d52a5ed2fd3e338578e6b0db63506f9

See more details on using hashes here.

File details

Details for the file ntfy_notify-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ntfy_notify-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ntfy_notify-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d5495d071b8267e4e01e2a0fcd54afc206198e537dfd823c91b27152fcb9731c
MD5 d620f6a757a6d0ecfaecf0fb80c01794
BLAKE2b-256 8cd1b0f370605ad86f623c1248f489a7642bf35f5229cecd49b634313200f023

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