?

What tutorial should I do this for next?

  1. How to make a Hypixel API website with JavaScript

  2. How to make a Hypixel API iPhone app

Results are only viewable after voting.
  1. [​IMG]
    Hello guys, I'm HoogleyBoogley! I had been a web developer for about 5 years now, so I would like to show you guys a really useful feature called the Hypixel API.​

    [​IMG]
    The Hypixel API is a very useful tool, it is used to check stats of players on the server. We all used websites such as plancke.io before to check stats, but how does it work? Well, it used something called the Hypixel API!

    [​IMG]
    To get started, you first have to go in game and type in the following command. /api You will be greeted with something called an API key. Doing so should greet you with something that looks like this in chat.
    [​IMG]
    Make sure you write this down and save it somewhere since it is required to link your site with the server to see the stats! If you lost it, you can do /api new and it should greet you with a new API key. After this, you can create your website. Create a file named index.php and stats.php.

    You will also need download some files to make sure our site works. You can download them here.

    Don't worry if you had never seen PHP before. It like any other programing language and used for more advanced things like database connection. IF you are familiar with a programing language, you should understand this pretty well.

    [​IMG]
    This is for people who would like to know a little bit about PHP. If know a lot about PHP, feel free to skip and go to the next section. PHP has to be run on a server like XXAMP or MAMP as it is server side. If you are an advanced user, you can just install Apache like what I did.
    [​IMG]
    I am using my custom Apache server but it should work the same as XXAMP or MAMP as we are just making PHP and not anything else besides that. If you do not know how to set up XXAMP, I have a tutorial about it when I go ahead and explain how to do it. If you need any help ask me down below on these forums.


    [​IMG]
    So the first thing we will do is create the home page. If we look on plancke.io we can see that if we want to view our stats, it will show a text box where you can type in your username. If you would like that, follow on, but if you want something that just shows the stats of your guild members or just a personal website, you can skip this step. For those who want something like Plancke's website, follow along!

    In your index.php file that we created earlier, make the basic HTML structure. Copy and paste in the following code.​
    HTML:
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>Hypixel Stats Viewer</title>
        </head>
        <body>
    
        </body>
    </html>
    
    One you do that, add your search form in between the body elements. Here is an example.​
    HTML:
    <form action="stats.php" method="get">
        <input type="text" name="ign" placeholder="Player's Username">
    </form>
    When typing out this code, they three most important things are the form action, the form method, and the input name. This is how we tell the PHP what stats to look up. You may style this as you wish, however, for the sake of this tutorial, I will not style it.

    [​IMG]
    The whole point of this website is to view that stats. So lets get started on our stats viewer. I am only going to do the stats on my favorite game, Mega Walls but you can change this.

    First you will want to open PHP in your stats.php file. You can do so by doing the following.​
    PHP:
    <?php

    ?>
    Once you do that, you need to declare your variables. That is where we look at the form we made. We need the input name. Where you put that field will be marked with a INPUT GOES IN HERE.
    PHP:
    $ign $_GET['INPUT GOES IN HERE'];
    The "$ign" can be whatever you want but make sure you remember it. I would recommend that you use "$ign" to make it easier to follow along.

    To make sure our variable works, you will want to add the following under that line of code.
    PHP:
    echo $ign;
    By going to your index.php and typing a username in the text box. It should greet you with whatever you just typed in the box as soon as you tap enter on your keyboard.

    Make sure you include the Hypixel PHP. You can do that by adding in this code.
    PHP:
    include_once('HypixelPHP.php');
    Remember that API key we got a while ago? Yeah, we need that. We will declare our API key with a variable as we did up above. You will replace API KEY HERE with your actual API key.
    PHP:
    $HypixelPHP = new HypixelPHP\HypixelPHP(['api_key' => 'API KEY HERE']);
    Now it is time for the last variable we have to declare. It is the player. Do you remember when we declared "$ign"? If you don't go ahead and look at your code. Because we will need it. Add in the following line of code.​
    PHP:
    $player $HypixelPHP->getPlayer([\HypixelPHP\KEYS::PLAYER_BY_NAME => $ign]);
    if (
    $player != null) { ?>

    We can get on to the fun part now! We show the player information! If you would like to style the site, close PHP and use HTML "div" tags as shown in this example.
    Code:
    <div id="name">
        <?php
            echo $player->getFormattedName(true, true);
            echo '<br>';
        ?>
    </div>
    <div id="title">
        <?php
            echo '<h1>GAME STATS</h1>'; ?>
    </div>


    Displaying the player's name would probley be useful, so that you know who's stats you are viewing. Do that by adding to following.​
    Code:
    <?php
        echo $player->getFormattedName(true, true);
        echo '<br>';
    ?>

    We wanted to make this site to view stats, so lets do that. Chose your game, it can be anything a long as you know what it is called. In our example, Mega Walls's is "WALLS3" so you can replace that with something like "BSG". Here is the code for something like coins.
    PHP:
    echo 'Coins: ' $player->getStats()->getGameFromID(\HypixelPHP\GameTypes::WALLS3)->getInt('coins');
    You can see at the end there is something that says 'coins', you can change this to display what you want. For example, you can show wins.
    PHP:
    echo 'Wins: ' $player->getStats()->getGameFromID(\HypixelPHP\GameTypes::WALLS3)->getInt('wins');
    Once you got one down, the rest is easy. You can just copy and paste these lines of code, style them, and then you are done!

    [​IMG]
    I hoped that this guide helped you create your website. If it did, please subscribe to my YouTube channel as I do programing and Hypixel. Here is a image of what the final site should look like if you took the time to style it with CSS.
    [​IMG]
    If you go to that index.php file in your web browser and enter your username, you should end up with your stats and all your information. If it does not work, copy and paste all your code down below and I will help you out.

    There are many uses for this, and if you are good at PHP like me, you can make a system for guild recruitment when you store all stats to variables and use booleans to test their required stats.

    I made this guide because when I was making an API site, I found very little tutorials that helped. If you like this, please give it a like and maybe we can get this thread pinned to help others.


    Need help? Please post your questions in this thread instead of PMing me. Thank you!

    I hope this works for you guys and good luck!

    Sorry @Plancke your site traffic may be lower soon!:p

    If you guys like this tutorial. I started to make more programing tutorials on my YouTube!​
     
    #1
    Last edited: Apr 13, 2018
    • Like Like x 21
    • Useful Useful x 4
    • Creative Creative x 2
    • Helper Lapis Helper Lapis x 1
  2. Wow thats amazing how you put alot of effort in this. I will personally be using this soon :D
     
    #2
  3. Thanks!
     
    #3
  4. I would advise to check your inputs before using them.
     
    #4
    • Useful Useful x 1
  5. What do you mean by that?
     
    #5
  6. You're not checking if the GET-parameter is set, this could result in errors :p
     
    #6
    • Useful Useful x 1
  7. Thank you for your help!
     
    #7
    • Like Like x 1
  8. This is lit! :) Hoog I fna
     
    #8
    • Like Like x 1
  9. Nice! ;)
     
    #9
  10. Great job on making this tutorial! I've been wanting to do something with the Hypixel API for a while now but haven't found a decent tutorial. I'm away right now but once I get home I'll be sure to have a go.
    Thanks!
     
    #11
    • Like Like x 1
    • Agree Agree x 1
  11. Thanks for the feedback!
    If something goes wrong, feel free to ask me about it!
     
    #12
    • Like Like x 1
  12. XEnderGamer

    XEnderGamer Well-Known Member

    Messages:
    926
    Can you make a tutorial on how to code pls?
     
    #13
  13. I think he got an Youtube channel with tutorials ;)
     
    #14
    • Dislike Dislike x 1
  14. Yeah of course!
     
    #15
  15. Randomness-

    Randomness- Well-Known Member

    Randomness
    MVP+
    Messages:
    2,696
    Thanks for the guide and being awesome. Planning to code more seriously now, helped a lot!
     
    #16
  16. theballercanadian

    theballercanadian New Member

    Messages:
    2
    can we play know i confused on what you do to start the walls game
     
    #17
    • Funny Funny x 1
  17. Randomness-

    Randomness- Well-Known Member

    Randomness
    MVP+
    Messages:
    2,696
    Wrong thread.
     
    #18
  18. theballercanadian

    theballercanadian New Member

    Messages:
    2
    huh what do u mean i just want to play walls but cant find the link
     
    #19
  19. mc.hypixel.net?
     
    #20

Share This Page