rs-pixel

Crates.iors-pixel
lib.rsrs-pixel
version0.2.0
sourcesrc
created_at2022-07-25 15:54:36.29682
updated_at2023-07-22 14:48:21.696534
descriptionA complete, rate-limiting, asynchronous Rust implementation of the Hypixel Public API with extensive SkyBlock support
homepage
repositoryhttps://github.com/kr45732/rs-pixel
max_upload_size
id632667
size94,979
(kr45732)

documentation

README

rs-pixel   Build Status Latest Version Discord

A complete, rate-limiting, asynchronous Rust implementation of the Hypixel Public API with extensive SkyBlock support.

[dependencies]
rs-pixel = "0.2.0"

Getting started

You will need a Hypixel Api Key to access most endpoints (official documentation).

Creating an Instance

Use the default configuration

let mut api = RsPixel::new("API KEY").await.unwrap();

Or configure the client, Minecraft username/UUID API type, and the rate limit strategy

let config = ConfigBuilder::default()
    .client(surf::Config::new().try_into().unwrap())
    .minecraft_api_type(ApiType::PlayerDb)
    .rate_limit_strategy(RateLimitStrategy::Error)
    .into();
let mut api = RsPixel::from_config("API KEY", config).await.unwrap();

Examples

Print a player's name and rank

let uuid = &api.username_to_uuid("USERNME").await.unwrap().uuid;
let response = api.get_player(uuid).await.unwrap();

println!(
    "{} has the {} rank",
    response.get_name().unwrap(),
    response.get_rank()
);

Print a skyblock player's statistics

let uuid = &api.username_to_uuid("USERNME").await.unwrap().uuid;
let response = api.get_skyblock_profiles(uuid).await.unwrap();
let profile = response.get_selected_profile().unwrap();

println!(
    "Enderman Slayer XP: {}\nCombat Skill Level: {}\nCatacombs LeveL: {}",
    profile.get_slayer(uuid, "enderman").unwrap().current_exp,
    profile.get_skill(uuid, "combat").unwrap().level,
    profile.get_catacombs(uuid).unwrap().level
);

Print a skyblock player's inventory contents (NBT parsed to JSON)

let uuid = "UUID";
let response = api.get_skyblock_profiles(uuid).await.unwrap();
let profile = response.get_selected_profile().unwrap();

println!("Inventory Contents:  {}", profile.get_inventory(uuid).unwrap());

Get the first page and print the first auction

let response = api.get_skyblock_auctions(0).await.unwrap();
let auction = response.auctions.get(0).unwrap();

println!(
    "The starting bid for a {} is {} coins",
    auction.item_name, auction.starting_bid
);

Todo

  • Documentation
  • More examples

License & Contributing

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 68

cargo fmt