hypixel-api-rust

Latest Version This is a Rust implementation of the Hypixel API.

Hypixel's Public API imposes a default limit of 120 requests/minute. This crate offers a wrapper around this dynamic limit that's fully asynchronous and can query any data type that implements DeserializeOwned from serde.

Getting started

As explained in the Hypixel Public API, an ApiKey is required to query most of the endpoints in the API.

The heart of this crate is the RequestHandler.\ Internally, it keeps track of how many requests the program has sent in the past minute, keeps an overflow of requests pending when necessary and always stays synchronized with the internal clock of the Hypixel REST API.

A response from the API can be deserialized into any data structure that implements DeserializeOwned by serde.

Basic example

```rust use hypixelapi::RequestHandler; use hypixelapi::StatusReply;

let apikey = Uuid::fromstr("your-api-key").unwrap(); // get your ApiKey let requesthandler = RequestHandler::new(apikey); // initialize a new RequestHandler

let response = request_handler.request::("status?uuid=069a79f4-44e9-4726-a5be-fca90e38aaf5", true); // query the status of Notch // send more requests ...

let data: StatusReply = response.await.unwrap().unwrap(); // use data ... `` AnyResult::Okresponse by this crate will guarantee to be a200 OK` response from the API and thus by consequence guarantee to be deserializable into a corresponding data struct.

Currently, many example response data structures are unimplemented. This does not impact this crate's ability to still query that data. Simply define your own data structure and use it with [RequestHandler] like usual. You could even replace all pre-made data structures and go fully custom. (Feel free to contribute to this repository!!)

See the documentation for more examples.

Features


License

Licensed under either of

at your option.

Contribution

Please feel free to contribute, every attempt counts!

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