Skip to main content

hypixel/endpoints/
skyblock.rs

1use crate::client::HypixelClient;
2use crate::error::Result;
3use crate::models::skyblock::*;
4
5impl HypixelClient {
6    /// Fetch all SkyBlock profiles for a player by UUID. Requires an API key.
7    pub async fn skyblock_profiles(&self, uuid: &str) -> Result<Vec<SkyBlockProfile>> {
8        let resp: ProfilesResponse = self
9            .request("/v2/skyblock/profiles", &[("uuid", uuid)], true)
10            .await?;
11        Ok(resp.profiles.unwrap_or_default())
12    }
13
14    /// Fetch a single SkyBlock profile by its profile id. Requires an API key.
15    pub async fn skyblock_profile(&self, profile: &str) -> Result<Option<SkyBlockProfile>> {
16        let resp: ProfileResponse = self
17            .request("/v2/skyblock/profile", &[("profile", profile)], true)
18            .await?;
19        Ok(resp.profile)
20    }
21
22    /// Fetch a profile's museum data by profile id. Requires an API key.
23    pub async fn skyblock_museum(&self, profile: &str) -> Result<Option<Museum>> {
24        let resp: MuseumResponse = self
25            .request("/v2/skyblock/museum", &[("profile", profile)], true)
26            .await?;
27        Ok(resp.profile)
28    }
29
30    /// Fetch a profile's garden data by profile id. Requires an API key.
31    pub async fn skyblock_garden(&self, profile: &str) -> Result<Option<Garden>> {
32        let resp: GardenResponse = self
33            .request("/v2/skyblock/garden", &[("profile", profile)], true)
34            .await?;
35        Ok(resp.garden)
36    }
37
38    /// Fetch a player's bingo participation by UUID. Requires an API key.
39    pub async fn skyblock_bingo(&self, uuid: &str) -> Result<Vec<serde_json::Value>> {
40        let resp: BingoEventsResponse = self
41            .request("/v2/skyblock/bingo", &[("uuid", uuid)], true)
42            .await?;
43        Ok(resp.events)
44    }
45
46    /// Fetch the active auctions of a player, profile, or single auction.
47    /// Provide exactly one of `uuid`, `player`, or `profile`. Requires an API key.
48    pub async fn skyblock_auction(
49        &self,
50        uuid: Option<&str>,
51        player: Option<&str>,
52        profile: Option<&str>,
53    ) -> Result<Vec<SkyBlockAuction>> {
54        let mut query = Vec::new();
55        if let Some(v) = uuid {
56            query.push(("uuid", v));
57        }
58        if let Some(v) = player {
59            query.push(("player", v));
60        }
61        if let Some(v) = profile {
62            query.push(("profile", v));
63        }
64        let resp: AuctionResponse = self.request("/v2/skyblock/auction", &query, true).await?;
65        Ok(resp.auctions)
66    }
67
68    /// Fetch one page of the global active-auction listing. Keyless.
69    pub async fn skyblock_auctions(&self, page: u32) -> Result<AuctionsPage> {
70        let page = page.to_string();
71        self.request("/v2/skyblock/auctions", &[("page", &page)], false)
72            .await
73    }
74
75    /// Fetch the most recently ended auctions. Keyless.
76    pub async fn skyblock_auctions_ended(&self) -> Result<Vec<EndedAuction>> {
77        let resp: EndedAuctionsResponse = self
78            .request("/v2/skyblock/auctions_ended", &[], false)
79            .await?;
80        Ok(resp.auctions)
81    }
82
83    /// Fetch the current bazaar order books for every product. Keyless.
84    pub async fn skyblock_bazaar(&self) -> Result<Bazaar> {
85        self.request("/v2/skyblock/bazaar", &[], false).await
86    }
87
88    /// Fetch the currently scheduled fire sales. Keyless.
89    pub async fn skyblock_firesales(&self) -> Result<Vec<FireSale>> {
90        let resp: FireSalesResponse = self.request("/v2/skyblock/firesales", &[], false).await?;
91        Ok(resp.sales)
92    }
93
94    /// Fetch the latest SkyBlock news posts. Keyless.
95    pub async fn skyblock_news(&self) -> Result<Vec<NewsItem>> {
96        let resp: NewsResponse = self.request("/v2/skyblock/news", &[], false).await?;
97        Ok(resp.items)
98    }
99}