API get server infos


Published on 2019-09-02




With this API, you can get your server informations like name of connected players, players count, numbers of votes...

The information depends on your server type. The information collected is the same as that of the widget visible in banners tab.

 
 Get server informations

You can get your server infos in JSON format by using this link. Replace XXXXXX with your server id. You will find your server id in the server edit form.

https://api.trackyserver.com/widget/index.php?id=XXXXXX

API response Definition

playerslist *

Get a list of all nickname connected on your server

playerscount

Current players count and max players (if the server is offline, this variable = OFFLINE)

country

Get the host country code
category

Server category name

map *

Server map name

version *

Server version

resources *

Mods list installed on the server (string with seperator)

votes

Number of votes on trackyserver

ip

IP and server port

name *

Server name

 * if available
 
 Example with PHP cURL

// Replace XXXXXX by your server id on Trackyserver.com
$server_id = "XXXXXX";

// Execute curl and get server informations
$url="https://api.trackyserver.com/widget/index.php?id=".$server_id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=json_decode(curl_exec($ch), true);
curl_close($ch);

if ($result){
  // Example to print playerscount
  echo $result['playerscount'];	
  // Example to loop players list  
  foreach ($result['playerslist'] as $player){   
echo $player['name']; 
} // Use print_r($result); to print all informations array } else { echo "server not found"; }