13 releases (7 breaking)

0.8.0 Oct 26, 2025
0.7.0 Jan 13, 2025
0.6.0 Sep 14, 2024
0.4.0 Dec 14, 2023
0.3.1 Nov 23, 2022

#311 in Authentication

Download history 169/week @ 2025-10-22 8/week @ 2025-10-29 10/week @ 2025-11-05 3/week @ 2025-11-12 13/week @ 2025-11-19 126/week @ 2025-11-26 248/week @ 2025-12-03 78/week @ 2025-12-10 63/week @ 2025-12-17 51/week @ 2025-12-24 67/week @ 2025-12-31 52/week @ 2026-01-07 59/week @ 2026-01-14 84/week @ 2026-01-21 62/week @ 2026-01-28 60/week @ 2026-02-04

272 downloads per month
Used in 3 crates

MIT license

30KB
726 lines

Ntfy

crates.io Documentation MIT

Description

Rust library for sending notifications over ntfy.

Example

use ntfy::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let dispatcher = dispatcher::builder("https://ntfy.sh")
        .credentials(Auth::credentials("username", "password")) // Add optional credentials
        //.proxy("socks5h://127.0.0.1:9050") // Add optional proxy (requires "socks" feature)
        .build_async()?; // Build dispatcher

    let action = Action::new(
        ActionType::Http,
        "Turn down",
        Url::parse("https://api.nest.com")?,
    );

    let payload = Payload::new("mytopic")
        .message("Hello, **World**!") // Add optional message
        .title("Alert") // Add optiona title
        .tags(["warning"]) // Add optional tags
        .priority(Priority::High) // Edit priority
        .actions([action]) // Add optional actions
        .click(Url::parse("https://example.com")?) // Add optional clickable url
        .attach(Url::parse("https://example.com/file.jpg")?) // Add optional url attachment
        .delay("30min") // Add optional delay
        .markdown(true); // Use markdown

    dispatcher.send(&payload).await?;

    Ok(())
}

Crate Feature Flags

The following crate feature flags are available:

Feature Default Description
async Yes Use reqwest as dispatcher client
blocking No Use ureq as dispatcher client
socks No Enables socks proxy support
rustls Yes Enables rust TLS
native-tls No Enables native TLS (openssl)

More examples can be found in the examples directory.

License

This project is distributed under the MIT software license - see the LICENSE file for details

Dependencies

~3–20MB
~203K SLoC