hypixel 0.1.0

Rust wrapper for the Hypixel public API.
Documentation
use serde::Deserialize;

/// Represents the response from the skyblock skills endpoint.
#[derive(Deserialize)]
pub struct SkillsResponse {
    /// Actual data.
    pub skills: Skills
}

/// Skills object containing all skill categories and associated skill.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct Skills {
    pub farming: Skill,
    pub mining: Skill,
    pub combat: Skill,
    pub foraging: Skill,
    pub fishing: Skill,
    pub enchanting: Skill,
    pub alchemy: Skill,
    pub carpentry: Skill,
    pub runecrafting: Skill,
    pub social: Skill,
    pub taming: Skill
}

/// Skill object from the Hypixel skyblock skills endpoint.
#[derive(Debug, Deserialize)]
pub struct Skill {
    /// Name of the skill, usually the category.
    pub name: String,
    /// Short description of the ability.
    pub description: String,
    /// Highest level for the skill.
    #[serde(rename = "maxLevel")]
    pub max_level: usize,
    /// List of levels and their information.
    pub levels: Vec<SkillLevel>
}

/// Levels object for skyblock skills.
#[derive(Debug, Deserialize)]
pub struct SkillLevel {
    /// Level.
    pub level: usize,
    /// Total experience required to get to this level.
    pub total_exp_required: Option<usize>,
    /// List of unlocks.
    pub unlocks: Vec<String>
}

/// Represents response from Hypixel skyblock items endpoint.
#[derive(Deserialize)]
pub struct ItemsResponse {
    /// Actual data.
    pub items: Vec<Item>
}

/// Item object from Hypixel skyblock items endpoint.
#[derive(Debug, Deserialize)]
pub struct Item {
    /// ID of the item.
    pub id: String,
    /// Bukkit material of the item.
    pub material: String,
    /// Name of the item.
    pub name: String,
    /// Tier of the item.
    pub tier: Option<String>,
    /// Category of the item.
    pub category: Option<String>,
    /// Price an NPC will sell you for the item.
    pub npc_sell_price: Option<f32>,
    /// Skin ID for item. Only for skull items.
    pub skin: Option<String>, 
    /// What generator it is. Only applicable to generators.
    pub generator: Option<String>,
    /// Tier of the generator. If it is one.
    pub generator_tier: Option<usize>,
    /// RGB color code of an item. Applicable only to leather pieces.
    pub color: Option<String>,
    /// Stats upon wearing an armor item.
    pub stats: Option<ItemStats>
}

/// Item stats object.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct ItemStats {
    /// Defense the armor provides.
    pub defense: Option<isize>,
    /// Health increase upon equipment.
    pub health: Option<isize>,
    /// Magic find.
    pub magic_find: Option<isize>,
    /// Intelligence increase on equipment.
    pub intelligence: Option<isize>,
    /// Walk speed increase.
    pub walk_speed: Option<isize>,
    /// Damage.
    pub damage: Option<isize>,
    /// Strength.
    pub strength: Option<isize>,
    /// Weapon ability damage.
    pub weapon_ability_damage: Option<isize>,
    /// Critical damage.
    pub critical_damage: Option<isize>
}

/// Represents the response from the Hypixel election endpoint.
#[derive(Deserialize)]
pub struct ElectionResponse {
    /// Mayor data.
    pub mayor: Mayor,
    /// Current election.
    pub current: Election
}

/// Mayor object from the elections endpoint.
#[derive(Debug, Deserialize)]
pub struct Mayor {
    /// Name of the mayor.
    pub name: String,
    /// Key.
    pub key: String,
    /// Perks the mayor provides.
    pub perks: Vec<Perk>,
    /// Past election where the mayor was chosen.
    pub election: Election
}

/// Perk object.
#[derive(Debug, Deserialize)]
pub struct Perk {
    /// Name of the perk.
    pub name: String,
    /// Description of the perk.
    pub description: String
}

/// Candidate object from the Hypixel election response.
#[derive(Debug, Deserialize)]
pub struct Candidate {
    /// Name of the candidate.
    pub name: String,
    /// Key.
    pub key: String,
    /// Perks the candidate provides.
    pub perks: Vec<Perk>,
    /// Votes the candidate has received.
    pub votes: usize
} 

/// Election object from the Hypixel election endpoint.
#[derive(Debug, Deserialize)]
pub struct Election {
    /// Year of the election.
    pub year: usize,
    /// List of candidates.
    pub candidates: Vec<Candidate>
}

/// Represents response object from the Hypixel active bingo endpoint.
#[derive(Deserialize)]
pub struct BingoResponse {
    /// Actual data.
    pub goals: Vec<Bingo>
}

/// Bingo object from the Hypixel active bingo endpoint.
#[derive(Debug, Deserialize)]
pub struct Bingo {
    /// ID of the goal.
    pub id: String,
    /// User friendly name.
    pub name: String
}

/// Represents response from Hypixel active auctions endpoint.
#[derive(Deserialize)]
pub struct ActiveAuctionsResponse {
    /// Actual data.
    pub auctions: Vec<Auction>
}

/// Auction item object from the Hypixel active auctions endpoint.
#[derive(Debug, Deserialize)]
pub struct Auction {
    /// UUID of the auctioneer.
    pub uuid: String,
    /// Auctioneer.
    pub auctioneer: String,
    /// Profile ID of the auctioneer.
    pub profile_id: String,
    /// CO-OP.
    pub coop: Vec<String>,
    /// When the auction started.
    pub start: usize,
    /// End of the auction.
    pub end: usize,
    /// Name of the item.
    pub item_name: String,
    /// Lore of the item.
    pub item_lore: String,
    /// Category of the item.
    pub category: String,
    /// Tier of the item.
    pub tier: String,
    /// Starting bid of the item.
    pub starting_bid: usize,
    /// Item was claimed.
    pub claimed: bool,
    /// Highest bid amount yet.
    pub highest_bid_amount: usize,
    /// Item UUID.
    pub item_uuid: Option<String>,
    /// List of the item's bids.
    pub bids: Vec<AuctionBid>
}

/// Bids object for the auction item object.
#[derive(Debug, Deserialize)]
pub struct AuctionBid {
    /// Auction ID.
    pub auction_id: String,
    /// Bidder's UUID.
    pub bidder: String,
    /// Bidder's profile ID.
    pub profile_id: String,
    /// Amount.
    pub amount: usize,
    /// When the bid was made.
    pub timestamp: usize
}

/// Represents the response from the Hypixel recently ended auctions endpoint.
#[derive(Deserialize)]
pub struct EndedAuctionsResponse {
    /// Actual data.
    pub auctions: Vec<EndedAuction>
}

/// Ended auction object from the Hypixel recently ended auctions endpoint.
#[derive(Debug, Deserialize)]
pub struct EndedAuction {
    /// Auction ID.
    pub auction_id: String,
    /// UUID of seller.
    pub seller: String,
    /// Profile ID of the seller.
    pub seller_profile: String,
    /// UUID of buyer.
    pub buyer: String,
    /// When the auction ended.
    pub timestamp: usize,
    /// Amount it was sold for.
    pub price: usize
}

/// Represents response from Hypixel bazaar endpoint.
#[derive(Deserialize)]
pub struct Bazaar {
    /// Actual product.
    pub products: serde_json::Value
}