minehut 1.0.1

Simple Rust wrapper for the Minehut API
Documentation
use crate::request;
use crate::models::{
    PlayerDistribution,
    HomePageStats,
    SimpleStats
};

pub use crate::handlers::{
    servers,
    products
};

pub(crate) const API_BASE: &str = "https://api.minehut.com";

/// Gets simple stats from Minehut asynchronously.
/// 
/// # Examples
/// 
/// ```
/// async fn print_stats() {
///     let stats = minehut::simple_stats().await;
/// 
///     println!("{} players are on", stats.player_count);
///     println!("{} hosted servers", stats.server_count);
/// }
/// ```
pub async fn simple_stats() -> SimpleStats {
    request::get_data::<SimpleStats>("/network/simple_stats").await
}

/// Gets player and server distribution from Minehut asynchronously.
/// 
/// # Examples
/// 
/// ```
/// #[tokio::main]
/// async fn main() {
///     let dist = minehut::player_distribution().await;
/// 
///     println!("{} java players", dist.java_total); // total java players on Minehut
///     println!("{} bedrock servers", dist.bedrock_player_server);
/// }
/// ```
pub async fn player_distribution() -> PlayerDistribution {
    request::get_data::<PlayerDistribution>("/network/players/distribution").await
}

/// Gets home page states from Minehut asynchronously.
/// 
/// # Examples
/// 
/// ```
/// #[tokio::main]
/// async fn main() {
///     let home = minehut::home_page_stats().await;
/// 
///     println!("{} users, {} server", home.user_count, home.server_count);
/// }
/// ```
pub async fn homepage_stats() -> HomePageStats {
    request::get_data::<HomePageStats>("/network/homepage_stats").await
}