11 unstable releases (5 breaking)

0.6.0 Sep 14, 2024
0.5.0 Aug 18, 2024
0.4.0 Dec 14, 2023
0.3.3 May 2, 2023
0.1.2 Nov 10, 2022

#170 in Authentication

Download history 155/week @ 2024-07-29 168/week @ 2024-08-05 238/week @ 2024-08-12 196/week @ 2024-08-19 136/week @ 2024-08-26 151/week @ 2024-09-02 404/week @ 2024-09-09 657/week @ 2024-09-16 261/week @ 2024-09-23 200/week @ 2024-09-30 154/week @ 2024-10-07 190/week @ 2024-10-14 157/week @ 2024-10-21 149/week @ 2024-10-28 156/week @ 2024-11-04 190/week @ 2024-11-11

679 downloads per month
Used in 2 crates

MIT license

18KB
453 lines

Ntfy

crates.io Documentation MIT

Description

Rust library for sending notifications over ntfy.

Example

use ntfy::prelude::*;

#[tokio::main]
async fn main() -> Result<(), NtfyError> {
    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()?; // 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(())
}

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

Donations

⚡ Tips: https://getalby.com/p/yuki

⚡ Lightning Address: yuki@getalby.com

Dependencies

~4–16MB
~197K SLoC