| Crates.io | ntfy |
| lib.rs | ntfy |
| version | 0.7.0 |
| created_at | 2022-11-08 10:33:47.148892+00 |
| updated_at | 2025-01-13 11:26:23.249855+00 |
| description | Library for sending notifications over ntfy |
| homepage | https://github.com/shadowylab/ntfy |
| repository | https://github.com/shadowylab/ntfy.git |
| max_upload_size | |
| id | 707965 |
| size | 68,916 |
Rust library for sending notifications over ntfy.
use ntfy::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Error> {
let dispatcher = dispatcher::builder("https://ntfy.sh")
.credentials(Auth::credentials("username", "password")) // Add optional credentials
.proxy("socks5h://127.0.0.1:9050") // Add optional proxy
.build_async()?; // Build dispatcher
let action = Action::new(
ActionType::Http,
"Turn down",
Url::parse("https://api.nest.com")?,
);
let payload = Payload::new("mytopic")
.message("Hello, **World**!") // Add optional message
.title("Alert") // Add optiona title
.tags(["warning"]) // Add optional tags
.priority(Priority::High) // Edit priority
.actions([action]) // Add optional actions
.click(Url::parse("https://example.com")?) // Add optional clickable url
.attach(Url::parse("https://example.com/file.jpg")?) // Add optional url attachment
.delay(1639194738) // Add optional delay
.markdown(true); // Use markdown
dispatcher.send(&payload).await?;
Ok(())
}
The following crate feature flags are available:
| Feature | Default | Description |
|---|---|---|
async |
Yes | Use reqwest as dispatcher client |
blocking |
No | Use ureq as dispatcher client |
More examples can be found in the examples directory.
This project is distributed under the MIT software license - see the LICENSE file for details