Was this helpful for you?

  1. Yes

    83 vote(s)
  2. No

    8 vote(s)
  3. I don't use hypixel api

    16 vote(s)
  1. TrollC

    TrollC Active Member

    This is probably going to be the longest article I have ever written.
    Here, I am going to show you how to use every type of api from hypixel server.

    To begin, you need two link, and an optional one:
    1. https://api.hypixel.net (to use hypixel api)
    2. https://ss.gameapis.net/profile/UUID (for getting player's username from UUID)
    3. https://cravatar.eu/head/UUID.png (for player heads on your website, optional)
    First thing you need to do, is to go to hypixel server and do /api new.
    Once you are done, the result will look something like this: https://imgur.com/CKsd8ks
    Press on the key in the chat to put it in your chatbox. Then press Ctrl+a and ctrl+c.

    So, now, you are ready to start.

    Player API
    The first thing we will look at is player api.
    Firstly, go to this link: https://api.hypixel.net/player?key=your_key&name=your_name
    If it works fine, then start your php code:
    $name = 'Troll_C';
    $key = '11847674-7ddd-432f-b05f-50d752465702'; // i have changed this key
    $json = file_get_contents('https://api.hypixel.net/player?key='.$key.'&name='.$name;
    $player = json_decode($json, true);
    print_r ($player);
    This will show you a huge array list.
    To get a function, I would recommend to use an array beautifier.

    So, let's say, you want to get a player's bedwars level.

    //change from print_r($player);
    print_r ($player['player']['achievements']['bedwars_level']);
    This will return a value, in my case it is 27.
    If you want to get the person's rank, use this:
    if (isset($player['player']['newPackageRank'])) {
    print_r ($player['player']['newPackageRank']);
    if (isset($player['player']['monthlyPackageRank'])) {
    print_r ('MVP++');
    if (isset($player['player']['rank'])) {
    // checks for a rank such as moderator, admin, or youtuber
    print_r ($player['player']['rank']);
    If you want player's head to display, add <img src="https://cravatar.eu/head/"<?php echo $name; ?>".png" alt="Head">

    You can go through the whole array list or use ctrl+f to find the functions you need.

    Added on: 17.04.2018:
    Decided to edit this and show you guys how to get the player's hypixel level.

    All you need to do, is create a function which you can then use in your further code.
    So here it goes:
    function getLevel(float $exp) {
            $REVERSE_PQ_PREFIX = -3.5;
            $REVERSE_CONST = 12.25;
            $GROWTH_DIVIDES_2 = 0.0008;
            return $exp < 0 ? 1 : floor(1 + $REVERSE_PQ_PREFIX + sqrt($REVERSE_CONST + $GROWTH_DIVIDES_2 * $exp));
    Every variable is constant except from $exp.

    So, let's say, you need to get a player's level and already created this function.
    Now, all you need to do, is do the following code:

    echo 'Hypickle level: ' . getLevel($player['player']['networkExp']);
    Thanks to @Aaron1998ish for giving me this function :)

    Guild API

    First thing you need to do, is to find a guild.
    This is used by method findGuild on hypixel api, which returns the guild id.
    An example of a query would be this:
    To get a player's UUID, go to this website: https://mcuuid.net/ and type your name.
    So, as a result, it will show you something like this: 5a89d1420******5fc3da8f (with no stars)

    Now, you can use the guild API:
    $id = '5a89d1420******5fc3da8f';
    $key = '11847674-7ddd-432f-b05f-50d752465702'; // i have changed this key
    $json = file_get_contents('https://api.hypixel.net/guild?key='.$key.'&id='.$id;
    $guild = json_decode($json, true);
    print_r ($guild);
    To see all the members, do this:
    foreach($guild['guild']['members'] as $members) {
    print_r ('UUID: '.$members['uuid']);
    print_r ('<br>Rank: '.$members['rank']);
    To get the player's name from UUID, use this function:
    function uuid_to_username($uuid) {
        if (is_string($uuid)) {
            $json = file_get_contents('https://ss.gameapis.net/profile/'.$uuid);
            if (!empty($json)) {
                $dat = json_decode($json, true);
                return $dat["name"];
        return false;
    So, to get the player's name do this in your foreach cycle:
    print_r (uuid_to_username($members['uuid']));
    You can get the amount of guild coins by doing:
    print_r ('Coins: '.$guild['guild']['coins'];
    If you need something else from a guild, just go through that arraylist and find what you need.

    Keys API:
    $key = '11847674-7ddd-432f-b05f-50d752465702'; // i have changed this key
    $json = file_get_contents('https://api.hypixel.net/key?key='.$key;
    $key = json_decode($json, true);
    print_r ($key);
    This will return something like this:
    You can also use this any of these parameters to decode and compare.
    You could also use uuid_to_username($uuid) function to change ownerUuid to username.

    Boosters API

    I have no clue why you would need it.
    But to get it, just do this:
    $key = '11847674-7ddd-432f-b05f-50d752465702'; // i have changed this key
    $json = file_get_contents('https://api.hypixel.net/boosters?key='.$key;
    $boosters = json_decode($json, true);
    print_r ($boosters);
    The arraylist is huge, but you can get what you need from it.

    Friends API

    To get a person's friend list, you can use hypixel api as well.
    What you need to do is this:
    $uuid = 'YOUR_UUID';
    $key = '11847674-7ddd-432f-b05f-50d752465702'; // i have changed this key
    $json = file_get_contents('https://api.hypixel.net/friends?key='.$key.'&uuid='.$uuid;
    $friends = json_decode($json, true);
    print_r ($friends);
    For every friend it returns something like this:
    You can get very friend of a person using foreach():
    foreach($friends['records'] as $f) {
    //do something
    You can also use uuid_to_username() function to print the friend's name.

    I am now very tired, since it took me over an hour to write this.
    Please do leave a 'useful' rating if you found this helpful.
    Feel free to PM me.
    Also, I will do watchdog stats, leaderboard and player session once we hit a certain number of likes :)
    Last edited: Apr 17, 2018
    • Like Like x 20
    • Useful Useful x 14
  2. why not bump this
    • Like Like x 1
  3. ImASadBoy

    ImASadBoy Member

    You should use cUrl and not file_get_contents
    • Agree Agree x 1
  4. TrollC

    TrollC Active Member

    Well, there are different ways to do it :p
  5. KiaTheMinecrafter

    KiaTheMinecrafter Active Member

    I know this is probably obvious to you guys, but I'm a beginner, so my question is:
    Where am I supposed to "start my php code"? I pasted the code in the array beautifier, changed the username part to my username, and changed the key part to my key,
    $key '[I put my key here]'// i have changed this key
    $json file_get_contents('https://api.hypixel.net/player?key='.$key.'&name='.$name;
    $player json_decode($jsontrue);
    print_r ($player);
    but it doesn't put anything in the beautified code view section, all it does is put the following code into the Serialized Object section:
    = \'KiaDaTowncrafter\';
    $key = \'[I put my key here]\'; // i have changed this key
    $json = file_get_contents(\'https://api.hypixel.net/player?key=\'.$key.\'&name=\'.$name;
    $player = json_decode($json, true);
    print_r ($player);
    What should I do?
    Thanks for any help I get on this subject!
  6. TrollC

    TrollC Active Member

    Second version of your code with \' is not right. Use the first one.
    Use the beautifier http://phillihp.com/toolz/php-array-beautifier/
    Then find the object you need and left click it. It will give you a response of an array object, for example if I need player's networkExp it will show $data['player']['networkExp']. Then paste this string in your code but replace $data with your variable's name, in this case your variable is called $player.
  7. hi i want a code thats when user enter player name change it to uuid and then put it http://api.hypixel.net/guild?key=******&uuid=HERE and then echo guild tag so how please help me dude and thx !

  8. Hey, I'll not give you the code because there are a lot of ways to do this and as Bugfroggy said you before, you need to do it by yourself if you want to learn the code ;)
    So before, you need to know that it's not possible to get the guild with the guild command. You need to enter the guild id like this: api.hypixel.net/guild?key=***&id=5687d71c0cf245173363d973.
    So if you want to find the guild id you need at least another request from the player or the findGuild command:
    • api.hypixel.net/findGuild?key=***&byUuid=c30ef18f85a6492b8ad6d3df445c4575
    • api.hypixel.net/player?key=***&uuid=c30ef18f85a6492b8ad6d3df445c4575
    Once you get the guild id you can put it on the first link ;)
    Finaly to get the guild tag you need to extract the tag value :)
  9. So, I'm pretty new to programming, and I've got one BIG problem preventing me from doing what I need to do. The project I'm working on (a Discord bot) requires that I use JavaScript; it's also the language I'm mainly focusing on currently. I was wondering if you might be able to aid me in somehow doing this in JavaScript, since what I've researched about JS to PHP and PHP to JS has not been very helpful, and really doesn't seem like a viable option. Or, if you can't, would you be willing to point me in the direction of someone who might be able to?

  10. TrollC

    TrollC Active Member

    Sure you can. Just use your own key, it will work :D
  11. This thread is really useful, hence deserves a good ol' bump.

    You should continue :p
  12. Opsect

    Opsect Well-Known Member

    Being the stupid person I am, what does an API do?
  13. API stands for Application Programming Interface. It's basically a set of functions and procedures allowing the creation of applications that access the features or data of an operating system, application, or other service. (source: Google translator lol). APIs are not directly usable by users, however developers use them to create applications. Take for example, discord.js. It's an API which you can use to create a discord bot, but a non-developer really isn't to benefit from it.
  14. Opsect

    Opsect Well-Known Member

    :O I still only understand a portion of it lol but thanks :D
    • Like Like x 1
  15. TrollC

    TrollC Active Member

    Thanks for the kind words :D
    • Like Like x 1
  16. Basically, @Opsect , an API is like a translator between two people who speak different languages. In the example above, using the Discord.js API, there are two "languages": 1 for Discord and 1 for JavaScript. The API can be seen as the translator or bridge that connects those two languages together to use on an application (in this instance, that application is Discord).

    For example, the official Discord API (which can be found here), has an instruction called "Create Reaction". That is an event defined by the Discord API that can be used when coding your Discord bot in any language supported by the Discord API.

    It's kind of hard to explain but I hope that made some sort of sense. I'll try to explain this better in a PM if you have any additional questions.

    Best regards,
    Anx :)
  17. Opsect

    Opsect Well-Known Member

    Thanks ;D
    • Like Like x 1
  18. Hello
    I'm getting Error 500. Is it from the host cuz im using a free one from infinity free or something from the code ??
  19. An error 500 means that you have an internal servor error. This is mainly cause when you have an error in your code. If you are running it on your localhost be sure to enable the display error in your php.ini file so you will know where is the error.
  20. Thanks for replying but im not on localhost. And I don't know where to find that php.ini file

Share This Page