use hypixel::HypixelClient;
use hypixel::util::market;
const MAX_PAGES: u32 = 5;
#[tokio::main]
async fn main() -> hypixel::Result<()> {
let query = std::env::args().nth(1).unwrap_or_default().to_lowercase();
let client = HypixelClient::unauthenticated();
let first = client.skyblock_auctions(0).await?;
let pages = (first.total_pages as u32).min(MAX_PAGES);
println!(
"Scanning {pages}/{} pages ({} active auctions)...",
first.total_pages, first.total_auctions
);
let mut auctions = first.auctions;
for page in 1..pages {
auctions.extend(client.skyblock_auctions(page).await?.auctions);
}
let lowest = market::lowest_bin(&auctions);
let mut matches: Vec<_> = lowest
.iter()
.filter(|(name, _)| query.is_empty() || name.to_lowercase().contains(&query))
.collect();
matches.sort_by_key(|(_, price)| **price);
println!(
"Cheapest BINs{}:",
if query.is_empty() {
""
} else {
" matching query"
}
);
for (name, price) in matches.into_iter().take(15) {
println!(" {price:>14} {name}");
}
Ok(())
}