1. Hello!
    In this thread I will be showing you (IMO) the easiest
    way to use the hypixel API even if you have never written
    a single line of code!


    In This tutorial I will be using the following:
    Python 3 (make sure to select install pip when installing)
    Atom (any program will do)
    Snuggle's api wrapper


    ALSO, NOTE THAT I AM NOT THAT GOOD AT TUTORIALS BUT I WAS LOST NOT ABLE TO FIGURE OUT HOW TO USE THE API AND NOW I WANT TO HELP OTHERS
    Step 1. Download then extract the snuggle api anywhere you'd like!
    Step 2. Create a new .txt file in the folder and name it anything you'd like but make sure to add .py to the end
    Step 3. Open the file in your program
    Step 4. Oops almost forgot! make sure you join hypixel and type /api new and save that key because we will need it! Never give anyone your key!
    step

    Actually coding:
    directory.png

    click on that and type "cmd" and that will open command prompt, then type "pip install hypixel" and the computer will do the rest!
    Once it's done you can open your .py file and at the top of the file type "import hypixel"
    Code:
    import hypixel
    then we need an api key input! thanks to our api wrapper it isn't hard
    Code:
    API_KEYS = ['e06f57fd-4ge5-4921-a403-a02e674f6e28']
    hypixel.setKeys(API_KEYS)
    then for the player input, we need a simple
    Code:
    Player = hypixel.Player('Need_Not')
    ok now we have set our player and api key! now let's get into stats!

    I want to get a player's level! so if "Player.getLevel()" is a player's level but we need it to be represented in a 1 world form we can do
    Code:
    PlayerLevel = Player.getLevel()
    and that will make it so PlayerLevel means the player's level
    now to make it output it we will need a print function!
    but if we do
    Code:
    Print(PlayerLevel)
    we will get a decimal that is very gross and long so that's why we need to add a format by doing
    Code:
    PlayerLevel = Player.getLevel()
    lPlayerLevel = '{:,.2f}'.format(PlayerLevel)
    print('Level' + ": ", end='')
    print(PlayerLevel)
    then this will format it so it will commas and stop decimal points from going back more than 2 digits!

    So here is what we got so far!
    Code:
    import hypixel
    
    API_KEYS = ['Put ur own plz']
    hypixel.setKeys(API_KEYS)
    Player = hypixel.Player('Need_Not')
    
    PlayerLevel = Player.getLevel()
    PlayerLevel = '{:,.2f}'.format(PlayerLevel)
    print('Level' + ": ", end='')
    print(PlayerLevel)
    and this out puts
    Code:
    Level: 80.13

    Ok so that's the basic parts now let's say we want the play's rank, karma, quests, or more importantly actual game stats!
    well, that's where it gets a little complicated for a few reasons so i'll walk you through it step by step!
    Now the way I just did the level only works for Names, ranks, and levels so for the other stuff we have to be a little but more advanced and to do so we have to open a new tab in chrome or whatever and go to
    https://api.hypixel.net/player?key=PUTKEYHERE&name=Need_Not
    and i'd also recommend this browser plugin that IMO helps find things faster!
    So now that we are at the api page we can search for the stat we want like if i want a total # of quests I would do ctrl + f and type quest now i will say quests are hard to find so the exact name is "general_quest_master"
    so now you're like... so what now? i got this title what do i do with it? Simple!
    make a new line of code and add:
    Code:
    def getInfo(json, param):
      try:
        return int(json['achievements']['general_quest_master'])
      except:
        return 0
    
    Quests = ("Quests Completed: {:,}".format(getInfo(Player.JSON, ['general_quest_master'])))
    print(Quests)
    now I know what you're thinking what the heck is that code for? well i'll tell you! so yes there are mroe simple ways to print the quests but they won't put a 0 if the api returns as an error and here is what i mean.

    If someone like alexsie who has never done a quest the api doesn't say general_quest_master: 0,
    in fact it won't even be there so if you are putting any sort of stat that some players don't have you will have to put something to catch it then replace it with 0.

    now don't worry when it comes to games you can have 1 thing to catch all the errors

    so now that we have done karma let's do rank and name then we have move on to games!
    for rank we will do
    Code:
    PlayerName = Player.getName()
    
    PlayerRank = Player.getRank()['rank']
    print('[' + PlayerRank, end='] ')
    print(PlayerName)
    this will grab the player rank and name then slap some square brackets to them!
    and this will give us
    Level: 80.13
    Quests Completed: 900
    [MVP+] Need_Not
    ik it's kinda backwards but whatever
    also i forgot to mention that the funny modarator who made this wrapper calls people without ranks nons so if you don't want nons to have the non rank then you can go to line 233 of hypixel.py and remove the text non but make sure to leave the '' or else it will cause errors!

    now for the games!
    so for this, I am just going to do basic bedwars stats like overall, solo, and then levels, coins etc.

    so I am going go to a new line and put add a print("bedwars")
    just so it looks nicer! :)

    Ok so for this first part I will make it so this

    Bedwars

    Bedwars Level:
    Bedwars Coins:
    Winstreak:

    Iron Collected:
    Gold Collected:
    Diamonds Collected:
    Emeralds Collected:

    then after we will do solo stats and then i will show you how to make overall stats and stuff

    ok so for the bedwars level we will need to do something like the quests:
    1. go in your browser again and go to the api site and search for bedwars_level in the "achievements" tab ik it's odd!

    then we will put a thing to catch the error
    Code:
    def getInfo(json, param):
      try:
        return int(json['achievements']['bedwars_level'])
      except:
        return 0
    print("Bedwars Level: {:,}".format(getInfo(Player.JSON, "achievements""bedwars_level")))
    
    this will print out the bedwars level in a commaed format!

    then we do the same for coins and win streak!
    Code:
    def getInfo(json, param):
      try:
        return int(json['stats']['Bedwars']['coins'])
      except:
        return 0
    
    print("Bedwars Coins: {:,}".format(getInfo(Player.JSON, "bedwars""coins")))
    
    def getInfo(json, param):
      try:
        return int(json['stats']['Bedwars']['winstreak'])
      except:
        return 0
    
    print("Winstreak: {:,}".format(getInfo(Player.JSON, "bedwars""winstreak")))
    
    print('')
    now this will output the coins, level and win streaks with a nice comma format!
    now I will add resources collected thing

    Code:
    def getInfo(json, param):
      try:
        return int(json['stats']['Bedwars'][param])
      except:
        return 0
    
    print("Iron Collected: {:,}".format(getInfo(Player.JSON, "iron_resources_collected_bedwars")))
    
    print("Gold Collected: {:,}".format(getInfo(Player.JSON, "gold_resources_collected_bedwars")))
    
    print("Diamonds Collected: {:,}".format(getInfo(Player.JSON, "diamond_resources_collected_bedwars")))
    
    print("Emeralds Collected: {:,}".format(getInfo(Player.JSON, "emerald_resources_collected_bedwars")))
    
    now in case you don't know what the heck we are doing and you aren't learning anything you can look at the code this way

    we see that in the thing that catches the errors it's looking in the ['stats']['Bedwars'][param]
    and the stats is the tab you will see in the api with the title stats and then inside the stats tab you will see the tab with the name bedwars and then ther param is a place holder for any stat inside the bedwars tab so if you needed skywars you would change bedwars to skywars or if you needed things in other tabs of the api you can add, remove, or edit any of the tabs to your needing!

    ok now back to the tutorial!
    we want to add stats like kills, deaths ect. so we need to edit some things like...
    instead of 'iron_resources_collected_bedears"
    let's change it to "eight_one_deaths_bedwars" it will make it show deaths
    Code:
    print('')
    print("Solo Deaths: {:,}".format(getInfo(Player.JSON, "eight_one_deaths_bedwars")))
    print("Solo Kills: {:,}".format(getInfo(Player.JSON, "eight_one_kills_bedwars")))
    
    so that's kills and deaths then to do finals you just do "eight_one_final_deaths_bedwars"
    and same with everything else
    To get a kdr we do
    Code:
    print("K/D: %.2f" % (getInfo(Player.JSON, "eight_one_kills_bedwars")/max(getInfo(Player.JSON, "eight_one_deaths_bedwars"), 1)))
    ok so now i gtg this will give a basic example of the stats and other stuff but i will update it more later!
    if you have any questions just reply to this or add me to Need_Not#1049
     
    #1
    Last edited: Feb 3, 2020
    • Like Like x 1
    • Useful Useful x 1
  2. Where did you get all this info??
    I looked at the github page for it but I can't find the docs containing everything.
     
    #2
  3. The git hub, other people, python discord, and just myself except then error catcher that was from ltt forums
     
    #3
    Last edited: Feb 5, 2020
  4. Or a single request.get line or aiohttp session can do this lol
     
    #4
  5. Actually yeah but when I made this a week ago I didn't find a need to learn that because everything I had was here but I didn't realize how much better it is to use requests
     
    #5

Share This Page