12 releases (6 breaking)

new 0.7.0 Jan 13, 2025
0.6.0 Sep 14, 2024
0.5.0 Aug 18, 2024
0.4.0 Dec 14, 2023
0.3.1 Nov 23, 2022

#140 in Authentication

Download history 252/week @ 2024-09-24 198/week @ 2024-10-01 175/week @ 2024-10-08 170/week @ 2024-10-15 154/week @ 2024-10-22 148/week @ 2024-10-29 157/week @ 2024-11-05 181/week @ 2024-11-12 68/week @ 2024-11-19 46/week @ 2024-11-26 29/week @ 2024-12-03 86/week @ 2024-12-10 49/week @ 2024-12-17 50/week @ 2024-12-24 109/week @ 2024-12-31 127/week @ 2025-01-07

349 downloads per month
Used in 2 crates

MIT license

29KB
707 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
        .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(1639194738) // 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

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–15MB
~173K SLoC