This library contains async rust bindings for the ntfy API. It uses reqwest as HTTP client.
Features implemented:
- Publish as JSON
- Post directly to topic
- File attachments
- Websockets
Cargo.toml
:
[dependencies]
tokio = { version = "1", features = ["full"] }
ntfy-api = "^0.1.1"
use ntfy_api::{NtfyApi, NtfyMsg};
#[tokio::main]
async fn main() {
let api = NtfyApi::default();
let ntfy_msg = NtfyMsg::builder("topic").message("Hello world!").build();
match api.post(&ntfy_msg).await {
Ok(_) => println!("Message sent"),
Err(_) => println!("Error sending message"),
}
}
let api = NtfyApi::new(NtfySettings {
host: String::from("https://ntfy.sh/"),
authorization: Some(NtfyAuthorization::new(String::from("username"), String::from("password"))),
});