#### [](HEADER)
<div align="center" width="100%">
<p>
<a href="https://github.com/BigBoot/AutoKuma/actions"><img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/BigBoot/AutoKuma/docker-build-push.yml?style=flat&logo=rust&link=https%3A%2F%2Fgithub.com%2FBigBoot%2FAutoKuma%2Factions"></a>
<a href="https://github.com/BigBoot/AutoKuma/releases/latest"><img alt="GitHub Tag" src="https://img.shields.io/github/v/tag/BigBoot/AutoKuma?logo=github&label=latest"></a>
<a href="https://ghcr.io/bigboot/autokuma"><img alt="GHCR Tag" src="https://img.shields.io/github/v/tag/BigBoot/AutoKuma?logo=docker&logoColor=white&label=GHCR"></a>
</p>
<p>
<b>
<a href="https://crates.io/crates/autokuma">AutoKuma</a>
  
<a href="https://crates.io/crates/kuma-cli">Kuma CLI</a>
  
<a href="https://crates.io/crates/kuma-client">Kuma Client</a>
  
<a href="https://autokuma.bigboot.dev/dev/">Documentation</a>
  
<a href="https://autokuma-playground.bigboot.dev">Playground</a>
</b>
</p>
</div>
`kuma-client` is a Rust crate that provides a client library for interacting with the Uptime Kuma SocketIO API.
## Examples
```rust
use kuma_client::{Client, Config, Url};
#[tokio::main()]
async fn main() {
let client = Client::connect(Config {
url: Url::parse("http://localhost:3001").expect("Invalid URL"),
username: Some("Username".to_owned()),
password: Some("Password".to_owned()),
..Default::default()
})
.await
.expect("Failed to connect to server");
let monitors = client.get_monitors().await.expect("Failed to get monitors");
println!("{:?}", monitors);
}
```
```rust
use kuma_client::{
monitor::{MonitorGroup, MonitorHttp},
notification::Notification,
tag::{Tag, TagDefinition},
Client, Config, Url,
};
#[tokio::main()]
async fn main() {
// Connect to the server
let client = Client::connect(Config {
url: Url::parse("http://localhost:3001").expect("Invalid URL"),
username: Some("Username".to_owned()),
password: Some("Password".to_owned()),
..Default::default()
})
.await
.expect("Failed to connect to server");
// Create a tag
let tag_definition = client
.add_tag(TagDefinition {
name: Some("example_tag".to_owned()),
color: Some("red".to_owned()),
..Default::default()
})
.await
.expect("Failed to add tag");
// Create a group
let group = client
.add_monitor(MonitorGroup {
name: Some("Example Group".to_owned()),
tags: vec![Tag {
tag_id: tag_definition.tag_id,
value: Some("example_group".to_owned()),
..Default::default()
}],
..Default::default()
})
.await
.expect("Failed to add group");
// Createa a notification
let notification = client
.add_notification(Notification {
name: Some("Example Notification".to_owned()),
config: Some(serde_json::json!({
"webhookURL": "https://webhook.site/304eeaf2-0248-49be-8985-2c86175520ca",
"webhookContentType": "json"
})),
..Default::default()
})
.await
.expect("Failed to add notification");
// Create a monitor
client
.add_monitor(MonitorHttp {
name: Some("Monitor Name".to_owned()),
url: Some("https://example.com".to_owned()),
parent: group.common().id().clone(),
tags: vec![Tag {
tag_id: tag_definition.tag_id,
value: Some("example_monitor".to_owned()),
..Default::default()
}],
notification_id_list: Some(
vec![(
notification.id.expect("No notification ID").to_string(),
true,
)]
.into_iter()
.collect(),
),
..Default::default()
})
.await
.expect("Failed to add monitor");
let monitors = client.get_monitors().await.expect("Failed to get monitors");
println!("{:?}", monitors);
}
```