This library contains async rust bindings for the ntfy API. It uses reqwest as HTTP client.
Features implemented: - [X] Publish as JSON - [ ] Post directly to topic - [ ] File attachments - [ ] Websockets
## Usage
Cargo.toml
:
toml
[dependencies]
ntfy-types = "^0.1"
ntfy-api = "^0.1"
```rust use ntfyapi::NtfyApi; use ntfytypes::NtfyMsg;
fn main() { let api = NtfyApi::default(); let ntfymsg = NtfyMsg { topic: String::from("alerts"), message: Some(String::from("Message body")), title: Some(String::from("New Message")), tags: None, priority: None, attach: None, filename: None, click: None, action: None, }; match api.post().await { Ok() => println!("Message sent"), Err(_) => println!("Error sending message"), } } ```
rust
let api = NtfyApi::new(NtfySettings {
host: String::from("https://ntfysh/"),
authorization: Some(NtfyAuthorization {
username: String::from("username"),
password: String::from("password"),
}),
});