A python library allowing the user to get stats from Hypixel in Minecraft.
Project description
minecraftstats
Minecraftstats is an API wrapper for the Minecraft server Hypixel. The library only currently allows the user to get duel and bedwars stats.
installation
using pip
pip install minecraftstats
using setup.py to install
git clone https://github.com/justbennnn/minecraftstats.git
cd minecraftstats
python setup.py install
usage
The following examples show all of the current available functions in minecraftstats.
Important: An API key can be obtained by logging onto the Hypixel server, and typing /api new
.
Note: The main framework for this project is Pydantic.
duels
This example shows how to get stats from the duels lobby.
import minecraftstats as ms
ms.set_username("your_username")
ms.set_api_key("your_api_key")
data = ms.get_user_stats()
duelData = data["Duels"]
overallStats = ms.OverallDuelStats(**duelData)
print(list(overallStats.__fields__.keys())) #show all available stats for the OverallDuelStats class
print("Total wins:", overallStats.wins)
print("Total kills:", overallStats.kills)
print("Most recent game mode played:", overallStats.recent_games[0])
Remember to use the ["Duels"] key to filter the data before you enter it.
Any stats that return hearts are measured in halves.
The easiest way to retrieve stats is by getting the data returned by the API with get_user_stats()
, and then passing
that as a kwarg into the desired class. Then you can access the stats as attributes to the class.
The next example shows getting stats from an individual game mode in the duels lobby.
uhcStats = ms.UHCDuelStats(**duelData)
print(list(uhcStats.__fields__.keys())) #show all available stats for the UHCDuelStats class
print("UHC wins:", uhcStats.wins)
print("Best UHC winstreak:", uhcStats.best_winstreak)
print("UHC golden apples eaten", uhcStats.golden_apples_eaten)
bedwars
This example shows how to get stats from the bedwars lobby.
bedwarsData = data["Bedwars"]
overallStats = ms.OverallBedwarsStats(**bedwarsData)
print(list(overallStats.__fields__.keys())) #show all available stats for the OverallBedwarsStats class
print("Total wins:", overallStats.wins)
print("Total kills:", overallStats.kills)
print("Total beds broken:", overallStats.beds_broken)
As shown above, most of the key concepts are the same as the duels stats example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for minecraftstats-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5037f3233e1f0afdb787afde69061d9ab8427ff47a1eac3655edc08608654466 |
|
MD5 | f4a96aa14f963ad53023bbf972121c32 |
|
BLAKE2b-256 | a25b77381fc28819e605d307ef757fd8983039fd08d41919e7edbbac9838152a |