LinuxCommandLibrary

ntfy

Send push notifications to devices

TLDR

Send a message to the security topic

$ ntfy pub security "[Front door has been opened.]"
copy

Send with a title, priority and tags
$ ntfy publish --title="[Someone bought your item]" --priority=[high] --tags=[duck] [ebay] "[Someone just bought your item: Platypus Sculpture]"
copy

Send at 8:30am
$ ntfy pub --at=8:30am [delayed_topic] "[Time for school, sleepyhead...]"
copy

Trigger a webhook
$ ntfy trigger [my_webhook]
copy

Subscribe to a topic ( to stop listening)
$ ntfy sub [home_automation]
copy

Display help
$ ntfy --help
copy

SYNOPSIS

ntfy [flags] [topic]

PARAMETERS

-attach
    Attach a file to the notification.

-base-url
    Specify a custom base URL of your ntfy server.

-cache-file
    Path to the file where subscription information is cached (default: ~/.cache/ntfy/cache.json).

-delay
    Delay sending notification to avoid bursts (e.g. 5s, 1m, 2h). Defaults to 0s.

-default-prefix
    The prefix used when no title is specified

-debug
    Enable debug output.

-encrypt
    Enable encryption.

-input-format
    Format of the input: raw (default) or json.

-message
    Override the message body. If not specified, stdin is used.

-priority
    Set the priority of the notification (1-5, default: 3).

-server
    ntfy server URL (default: ntfy.sh).

-title
    Set the title of the notification.

-tags
    Add tags to the notification (comma-separated).

-topic
    Specify the topic to subscribe to or publish on. This can also be provided as an argument.

-version
    Show version and exit.

-help
    Show help message and exit.

DESCRIPTION

The `ntfy` command-line tool allows users to subscribe to push notifications from a server, enabling real-time alerts on various platforms. Unlike traditional polling mechanisms, `ntfy` leverages a publish-subscribe (pub/sub) model for efficient delivery. A user publishes a message to a specific topic on an ntfy server, and any client subscribed to that topic receives the message instantly as a push notification. This eliminates the need for constant background checks, saving resources and providing immediate updates. The command line interface is designed to be minimalistic and easy to use.
You can either publish (send messages) or subscribe (receive messages). The real power is when used together with other tools to push notifications when something happens. Common usage scenarios include monitoring server status, receiving alerts from scripts, and building custom automation workflows. It supports various platforms including Android, iOS, web browsers, and desktop clients. `ntfy` is designed with security in mind, offering options for encryption and authentication to protect sensitive information. Furthermore, you can host you own ntfy server.

EXAMPLE

To send a notification with the message "Hello, world!" to the topic "mytopic", you would use:
echo "Hello, world!" | ntfy mytopic
To subscribe:
ntfy subscribe mytopic

Copied to clipboard