Query

API - Query

Obtention des informations du serveur
<?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;
?>
Réponse de l'API
Plain texte:

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" ...}

Obtention du nom d'hôte
<?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;
?>
Réponse de l'API
Plain texte:

Asylyus

JSON:

{"hostname": "Asylyus"}

Obtention du nombre de joueur connecté
<?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;
?>
Réponse de l'API
Plain texte:

250

JSON:

{"online": "250"}

Obtention du nombre de joueur admis par le serveur
<?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;
?>
Réponse de l'API
Plain texte:

500

JSON:

{"maxplayers": "500"}

Obtention de la 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;
?>
Réponse de l'API
Plain texte:

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"}