Application Programming Interfaces or APIs for short, have become a defining characteristic of many modern software/web applications. They provide both management and communication functionalities to the application/platform and facilitate communications between other applications and platforms.
With gaming becoming a centerpiece of the internet landscape, the gaming API was developed to provide a standardized way of communicating with the game regardless of the platform or programming language they are built. In this article, we will see how to use Minecraft API with multiple programming languages.
View the Best Minecraft APIs List
What is Minecraft API?
In simplest terms, Minecraft API is an API that provides the ability to interact with Minecraft servers. It can be used to obtain the status and information of a Minecraft instance (PC/MCPE), getting Minecraft service statuses, getting player information, and tracking payment and package information on Texbex.io (Formally known as BuyCraft) and Minecraft Market.
This Minecraft API aims to provide a single API to communicate with Minecraft servers, Minecraft Marketplace, and Tebex.io website to effectively manage the monetization of the game server.
How does the Minecraft API work?
The Minecraft API works on simple principles such as making a request and obtaining the response. The API will request the necessary payload (IP Address, username, market keys, etc…) and authentication (API Keys, Tokens) details. As a result, it will receive the response payload in JSON format.
A response payload will be generated for both successful and unsuccessful requests. The difference between them will be that the successful response payload will include the requested information, while the unsuccessful response payload will include the error details.
Following is a sample JSON response that can be expected when checking for the current status of Minecraft services.
[ { "minecraft.net": "green" }, { "session.minecraft.net": "green" }, { "account.mojang.com": "green" }, { "authserver.mojang.com": "green" }, { "sessionserver.mojang.com": "red" }, { "api.mojang.com": "green" }, { "textures.minecraft.net": "green" }, { "mojang.com": "green" } ]
Target Audience for Minecraft API
Gamers / Streamers
With this API, gamers and streamers can monitor their dedicated Minecraft instances in both the PC (Java) and Bedrock (Minecraft Pocket Edition) editions. It can also be used to obtain information about the server status, player information, and player count to effectively manage the underlying hardware resources and optimize the hardware and network to perform well while the server activity is high. This is essential for game streamers to gauge their audience and plan for community play sessions properly without causing any performance issues.
Modders
Minecraft supports third-party sellers to sell items that are useful in the Minecraft world. These can vary from skin packs, items, or whole worlds and experiences. The Minecraft API provides means to gain information about the products offered in both Texbex.io and Minecraft Marketplace while enabling modders to obtain the sales figures (Payments). This information is valuable in creating new items that have a high demand in the marketplaces.
Business Entities
Online platforms that offer dedicated or shared game servers can utilize this API to monitor the status of servers. When managing many servers, anyone can easily parse and visualize the server details using this API as it provides data in JSON format. Additionally, if the business is offering products such as skins, items, etc., they can utilize the same API to manage sales in Texbex.io and Minecraft Marketplace.
As a whole, anyone who wants to monitor a Minecraft instance, sell in-game items, monitor marketplaces or offer dedicated servers can utilize this API.
How to connect to the Minecraft API Tutorial – Step by Step
Step 1 – Sign up and Get a RapidAPI Account.
RapidAPI is the world’s largest API marketplace which is used by over a million developers. It aims to provide a unified platform (single account, API Key and SDK) to interact with thousands of APIs and manage all those APIs through a single dashboard.
To sign-up for a RapidAPI account, navigate to rapidapi.com and click on the Sign Up icon. RapidAPI provides options for both Single Sign-On (SSO) using Google, GitHub, and Facebook accounts or manually creating a user account.
Step 2 – Search the API Marketplace
Navigate to the Marketplace and search for “Minecraft API.” Then, select the desired API from the search results. There, we will select the Minecraft API (Minecraft API Web Service).
Step 3 – Subscribe to the API
Before using the API, we have to subscribe to it. So navigate to the pricing section of the Minecraft API and subscribe to your preferred plan. In this instance, we select the free plan of the Minecraft API. Then, simply click on the “Connect Now” button to activate the subscription.
Step 4 – Test the API
After subscribing to the API, navigate to the Endpoints section of the API screen. This section describes all the available endpoints for the API and offers code snippets in multiple languages, which helps to integrate the API with any application.
Then, select the endpoint you want to test and add the required details there. Finally, click on the “Test Endpoint” Button to test the API.
Minecraft API Endpoints
The Minecraft API provides a whole host of endpoints. They can be categorized into two main sections: server monitoring endpoints and marketplace monitoring endpoints(Tebex.io (BuyCraft) and Minecraft Marketplace). Let’s have a look at each section in detail.
Server Monitoring
Minecraft API provides the necessary endpoints to monitor the status of Minecraft installations on both a PC server and an MCPE server. On top of that, this API allows monitoring player information and Minecraft service status. The following table displays all the available endpoints for server monitoring.
Endpoint | Usage | Parameters |
getPCServerStatus | Get the status of a PC server. | IP address and the port of the server. |
getSinglePCServerInfo | Get information about a PC server. | IP address and the port of the server. |
getPCServersExtensiveInfo | Get extensive information about a PC server. | IP address and the port of the server. |
getPCServersInfo | Get information about multiple PC servers. | An array of IP addresses and ports. |
getPCServerMOTD | Get the MOTD (Message of the Day) of a PC server. | IP address and the port of the server. |
getPCServerPlayersAmount | Get the number of players on the Minecraft server. | IP address and the port of the server. |
getPCServerFavicon | Get PC server favicon. | IP address and the port of the server. |
getSingleMCPEServerInfo | Get information about an MCPE server. | IP address and the port of the server. |
getSinglePCServerExtensiveInfo | Get extended information about an MCPE server. | IP address and the port of the server. |
getMCPEServersInfo | Get information about multiple MCPE servers. | An array of IP addresses and ports. |
getPlayersAvatar | Get the player avatar. | Player username helm (Boolean value to enable/disable helm layer rendering) and size (image size) |
getPlayersSkin | 2D image of players’ skin. | Player username helm (Boolean value to enable/disable helm layer rendering) and size (image size) |
getPlayerSkinFile | Raw skin file of a player. | Player username |
getBlockedServers | Get a list of servers blocked by Mojang. | |
getMinecraftServicesStatus | Check the status of core Minecraft services. | |
checkIsUp | Check the status of IP/Domain | IP address or domain name |
checkDomainDNS | Check DNS of a domain | Domain to check the DNS |
Marketplace Monitoring
The API offers the functionality to track recent payments, shop information, and available packages in Tebex.io (BuyCraft) and Minecraft Marketplaces.
Endpoint | Usage | Parameters |
getBuycraftRecentPayments | Get the recent payment transactions of the shop. | Unique Key for each server associated with the shop. (Generated by Tebex/BuyCraft) |
getBuycraftPackages | Get available packages in the shop. | Unique Key for each server associated with the shop. (Generated by Tebex/BuyCraft) |
getBuycraftShopInfo | Get information about the shop. | Unique Key for each server associated with the shop. (Generated by Tebex/BuyCraft) |
getMinecraftMarketPayments | Get recent payment transactions made in the marketplace. | Unique Key for each server generated by Minecraft Market. |
getMinecraftMarketPackages | Get packages viewable in-game. | Unique Key for each server generated by Minecraft Market. |
Integrating Minecraft API to an Application
In this section, we will see how to integrate the Minecraft API into a software application using different programming languages such as Python, PHP, Ruby, and Javascript. An important fact to note here is that you have to configure the proper programming environments for each language to execute the code snippet successfully.
We will be using the “getPCServerStatus” endpoint for all the code snippets. Each request generated by the code snippets will require two parameters. They are the RapidAPI API key indicated by <<<API_KEY>>> and the IP address of the targeted PC server (address). These parameters will vary from endpoint to endpoint.
Python Code Snippet (requests)
import requests url = "https://minecraftstefan-skliarovv1.p.rapidapi.com/getPCServerStatus" payload = "address=%3CREQUIRED%3E" headers = { 'content-type': "application/x-www-form-urlencoded", 'x-rapidapi-key': "<<<API_KEY>>>", 'x-rapidapi-host': "Minecraftstefan-skliarovV1.p.rapidapi.com" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
PHP Code Snippet (HTTP v2)
<?php $client = new http\Client; $request = new http\Client\Request; $body = new http\Message\Body; $body->append(new http\QueryString([ 'address' => '<REQUIRED>' ])); $request->setRequestUrl('https://minecraftstefan-skliarovv1.p.rapidapi.com/getPCServerStatus'); $request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders([ 'content-type' => 'application/x-www-form-urlencoded', 'x-rapidapi-key' => '<<<API_KEY>>>', 'x-rapidapi-host' => 'Minecraftstefan-skliarovV1.p.rapidapi.com' ]); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
Ruby (net::http)
require 'uri' require 'net/http' require 'openssl' url = URI("https://minecraftstefan-skliarovv1.p.rapidapi.com/getPCServerStatus") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["content-type"] = 'application/x-www-form-urlencoded' request["x-rapidapi-key"] = '<<<API_KEY>>>' request["x-rapidapi-host"] = 'Minecraftstefan-skliarovV1.p.rapidapi.com' request.body = "address=%3CREQUIRED%3E" response = http.request(request) puts response.read_body
Javascript (Axios)
import axios from "axios"; const options = { method: 'POST', url: 'https://minecraftstefan-skliarovv1.p.rapidapi.com/getPCServerStatus', headers: { 'content-type': 'application/x-www-form-urlencoded', 'x-rapidapi-key': '<<<API_KEY>>>', 'x-rapidapi-host': 'Minecraftstefan-skliarovV1.p.rapidapi.com' }, data: {address: '<REQUIRED>'} }; axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); });
Benefits of the Minecraft API
Extensive Functionality.
The Minecraft API functionality is not limited to a single functionality as it offers both server, player, and marketplace monitoring as a single API. With support for both PC and MCPE editions, this API covers almost all the possible Minecraft installations. Moreover, its monitoring functionality for both Tebex and Minecraft marketplaces enables users to build a comprehensive monitoring application without depending on other APIs.
Customization
The Minecraft API provides the option to customize the endpoint targets (request payload), enabling developers to specify targets to capture the required data. (IP, Port, Username, Marketplace Key, etc…)
Ease of Use
The simple endpoint structure and well-documented requirements (request parameters) of this API enhance its user-friendliness. Additionally, with the comprehensive code snippets for multiple programming languages, the API can be picked up even by a novice developer to integrate with their applications.
Alternative to Minecraft API
- MCServerInf – A simple API to gather server information from Minecraft instances.
- Minecraft-Forge-Optifine – Retrieve the version lists and downloads for Minecraft, Forge, and Optifine.
- MineBans – Global banning system for Minecraft servers.
Summary
The Minecraft API acts as a comprehensive monitoring solution that would suit any amount of Minecraft monitoring scenarios under a single API. In this article, we have covered the basic structure of the Minecraft API, its available endpoints and functionality, and sample code snippets showcasing how to integrate it into an application.
Leave a Reply