ntfy-api

Crates.iontfy-api
lib.rsntfy-api
version0.1.1
sourcesrc
created_at2022-09-17 14:43:48.633
updated_at2022-09-18 10:13:47.523513
descriptionRust bindings for ntfy API
homepage
repositoryhttps://github.com/tomaThomas/ntfy-api
max_upload_size
id668199
size30,944
(tomaThomas)

documentation

README

ntfy-api

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

Usage

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 {
       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(&ntfy_msg).await {
       Ok(_) => println!("Message sent"),
       Err(_) => println!("Error sending message"),
   }
}

Configuration

let api = NtfyApi::new(NtfySettings {
   host: String::from("https://ntfysh/"),
   authorization: Some(NtfyAuthorization {
       username: String::from("username"),
       password: String::from("password"),
   }),
});
Commit count: 4

cargo fmt