Gameserver

The gameserver api request handles your gameserver. Multiple options are available

  • Get information about your gameserver(s)
  • Shutdown/restart/start your gameserver

Version

1.0.0

Request Parameters

Parameter Valid Input Default Required Description
customer_id unsigned integer - yes The customer_id the data should be requested for
token string - yes The token generated for this request. See token for more information
pw boolean true no Include passwords for servers
ftp boolean true no Include ftp information for servers including passwords
server_id unsigned integer null no The server_id, needed to run a command on your gameserver
(Use either in URL or as JSON command)
command string null no The command for your gameserver, possibilities: (shutdown|restart|start)

Examples

For all examples we are using GuzzleHttpClient.

Get gameserver from customer_id 1

<?php 

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

function getGameserver() {
    try {
        $client = new Client();
        $response = $client->post('https://my.ngz.net/api/gameserver',
            array(
                'json' => array(
                    'customer_id' => 1,
                    'token' => 'C9FBFB090B8E6BBB1EED94D2259F94D98CDBCB57A710558DA0'
                )
            )
        );
    } catch (ClientException $e) {
        throw new Exception($e->getResponse()->getBody()->getContents(), $e->getResponse()->getStatusCode());
    }
    if(is_object($response) && $response->getStatusCode() == 200) {
        $reply = json_decode($response->getBody()->getContents());
    }
    return $reply;
}

Sample output

Array 
(
    [0] => stdClass Object
    (
        [id] => 101101
        [product_id] => 202202
        [name] => "Counter-Strike: Global Offensive"
        [ftp] => stdClass Object
        (
            [url] => "ftpnew.ngz-server.de"
            [user] => "server101101"
            [pw] => "password"
        )
        [server] => stdClass Object
        (
            [ip] => "11.22.333.444"
            [port] => 27015
            [type] => "CLAN"
            [name] => "Your Gameserver Name"
            [server_pw] => "password"
            [admin_pw] => "password"                                                                                                                                                                                                                      
            [status] => "running"                                                                                                                                                                                                                               
            [players] => stdClass Object
            (                                                                                                                                                                                                                          
                [max] => "10"                                                                                                                                                                                                                                  
            )                                                                                                                                                                                                                                                 
        )                                                                                                                                                                                                                                                   
    )                                                                                                                                                                                                                                                     
) 

Restart gameserver from customer_id 1 with server_id 101101

<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

function restartGameserver() {
    try {
        $client = new Client();
        $response = $client->post('https://my.ngz.net/api/gameserver/101101',
            array(
                'json' => array(
                    'customer_id' => 1,
                    'token' => 'C9FBFB090B8E6BBB1EED94D2259F94D98CDBCB57A710558DA0',
                    'command' => 'restart',
                    'server_id' => 101101
                )
            )
        );
    } catch (ClientException $e) {
        throw new Exception($e->getResponse()->getBody()->getContents(), $e->getResponse()->getStatusCode());
    }
    if(is_object($response) && $response->getStatusCode() == 202) {
        $reply = json_decode($response->getBody()->getContents());
    }
}

Sample output

(
    "Accepted"
)   
Copyright 2016 by United Gameserver GmbH. Alle Rechte vorbehalten.V3.1.5.1337