Ntfy SDK

Description
Ntfy client library to send notifications from Rust.
Example
chrono = "0.4"
ntfy = "0.4"
tokio = { version = "1", features = ["full"] }
url = "2"
use chrono::{Duration, Local};
use ntfy::payload::{Action, ActionType};
use ntfy::{Auth, Dispatcher, NtfyError, Payload, Priority};
use url::Url;
#[tokio::main]
async fn main() -> Result<(), NtfyError> {
let dispatcher = Dispatcher::builder("https://ntfy.sh")
.credentials(Auth::new("username", "password")) .proxy("socks5h://127.0.0.1:9050") .build()?;
let action = Action::new(
ActionType::Http,
"Turn down",
Url::parse("https://api.nest.com")?,
);
let payload = Payload::new("mytopic")
.message("Hello, **World**!") .title("Alert") .tags(vec!["warning".into()]) .priority(Priority::High) .actions([action]) .click(Url::parse("https://example.com")?) .attach(Url::parse("https://example.com/file.jpg")?) .delay(Local::now() + Duration::minutes(1)) .markdown(true);
dispatcher.send(&payload).await.unwrap();
Ok(())
}
More examples can be found in the examples directory.
Crate Feature Flags
The following crate feature flags are available:
| Feature |
Default |
Description |
blocking |
No |
Needed if you want to use this library in not async/await context |
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