Giter Site home page Giter Site logo

grizzlt / hypixel-api-rust Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 81 KB

A simple rate-limiting wrapper around the Hypixel API, written in Rust.

License: Apache License 2.0

Rust 96.29% HTML 3.71%
api async asynchronous hypixel hypixel-api mc minecraft rate-limiting rust

hypixel-api-rust's Introduction

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

use hypixel_api::RequestHandler;
use hypixel_api::StatusReply;

let api_key = Uuid::from_str("your-api-key").unwrap(); // get your ApiKey
let request_handler = RequestHandler::new(api_key); // initialize a new RequestHandler

let response = request_handler.request::<StatusReply>("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 ...

Any Result::Ok response by this crate will guarantee to be a 200 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

  • util - enables the utility functions to process data returned by the Hypixel Public API
  • reply - (depends on util) - enables ready-to-use data structures as responses from the Hypixel Public API

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.

hypixel-api-rust's People

Contributors

grizzlt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.