Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 982 Bytes

README.md

File metadata and controls

40 lines (34 loc) · 982 Bytes

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::builder("topic").message("Hello world!").build();
   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://ntfy.sh/"),
   authorization: Some(NtfyAuthorization::new(String::from("username"), String::from("password"))),
});