-
Notifications
You must be signed in to change notification settings - Fork 148
Using the API with Java
This page provides examples of how to use the Hypixel PublicAPI in a Java program. It is assumed that you have already configured your IDE and downloaded PublicAPI on your own machine.
In order to follow along with this tutorial, you will need the following:
- A live internet connection
- A licensed copy of Minecraft installed on your local machine
- A Java IDE (we will be using IntelliJ for this tutorial)
- Maven (if not already built into your IDE)
To use the PublicAPI, you will first need to have an API key. The Hypixel API uses keys to keep track of how frequently a user is sending requests, as well as to determine if your API key is compromised.
To obtain your personal API key, you must own a valid Minecraft account and have the Minecraft Launcher installed.
- Launch Minecraft on release 1.8.0 or later (snapshot versions will not work)
- Open the
MultiplayerGUI and connect tomc.hypixel.net - Once you are connected, open up the chat bar (this can be done by pressing the
Tkey by default) - In the chat bar, type
/api newand press enter. You should receive a message in chat saying,Your new API key is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx(with your API key in place of the x's) - When you click on that message, your API key should be copied to your clipboard. Paste that somewhere safe for later
NOTE: Your API key is to be treated just like a password. You should never share your API key with anyone, or else it could be used for malicious purposes.
To start using the Java API, you will first need to open up a Java IDE of your choice. For this tutorial, we will be using IntelliJ IDEA (2020.1.1).
1. Firstly, you will need to create a new project. In IntelliJ, there is a button for this on the welcome screen:
2. Then, select the Maven project option and click Next:
3. Type in the name of your project and press the Finish button. This will create your new Maven project with that name:
4. In the Project window that appears, click on the folder with your project's name and double-click the pom.xml file:
5. At the end of this file (before the </project> tag), paste the following:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.HypixelDev.PublicAPI</groupId>
<artifactId>Java</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>NOTE: If some of the text is colored red, you may need to use the Load Maven Changes button in the top right (see screenshot)
If all goes well, you now should be able to use the Hypixel API in your very own Java project! See below for more information on using the API in various projects [coming soon; for now, see here for various examples].
- Add example usage in a plain java program
- Add example usage in a Forge mod
- Add example usage in a Bukkit plugin




