Query

API - Query

Getting information from the server
<?php
$infos = file_get_content('https://minecraft-api.com/api/query/{ip}/{port}');
$json = file_get_content('https://minecraft-api.com/api/query/{ip}/{port}/json');
echo $infos;
echo $json;
?>
Response from API
Plain text:

Array([HostName] => Asylyus [GameType] => SMP [GameName] => MINECRAFT [Version] => 1.8.x, 1.9.x, 1.10.x, 1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x [Plugins] => [Map] => World [Players] => 250 [MaxPlayers] => 500 [HostPort] => 25565 [HostIp] => 0.0.0.0 [Software] => Vanilla)

JSON:

{"HostName": "Asylyus" ...}

Obtaining the host name
<?php
$hostname = file_get_content('https://minecraft-api.com/api/query/hostname/{ip}/{port}');
$json = file_get_content('https://minecraft-api.com/api/query/hostname/{ip}/{port}/json');

echo $hostname;
echo $json;
?>
Response from API
Plain text:

Asylyus

JSON:

{"hostname": "Asylyus"}

Obtaining the number of connected players
<?php
$online = file_get_content('https://minecraft-api.com/api/query/online/{ip}/{port}');
$json = file_get_content('https://minecraft-api.com/api/query/online/{ip}/{port}/json');

echo $online;
echo $json;
?>
Response from API
Plain text:

250

JSON:

{"online": "250"}

Obtaining the number of players admitted by the server
<?php
$maxplayers = file_get_content('https://minecraft-api.com/api/query/maxplayers/{ip}/{port}');
$json = file_get_content('https://minecraft-api.com/api/query/maxplayers/{ip}/{port}/json');

echo $maxplayers;
echo $json;
?>
Response from API
Plain text:

500

JSON:

{"maxplayers": "500"}

Getting the version
<?php
$version = file_get_content('https://minecraft-api.com/api/query/version/{ip}/{port}');
$json = file_get_content('https://minecraft-api.com/api/query/version/{ip}/{port}/json');

echo $version;
echo $json;
?>
Response from API
Plain text:

1.8.x, 1.9.x, 1.10.x, 1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x

JSON:

{"version": "1.8.x, 1.9.x, 1.10.x, 1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x"}