Skip to content
Ryan G edited this page Sep 20, 2013 · 1 revision

NOTE:: The following API details will only work with the current Master files from GitHub. These changes will be included in the next 3.0.11 master release, but for now, use Git. (https://github.com/devryan/GamePanelX-V3)

Table of Contents

Example Code

The following is example PHP code to hit the GamePanelX V3 API and create a new game server (requires Curl for PHP). Replace <domain> with your domain name. $url = "http://&lt;domain&gt;&lt;/domain&gt&lt;/gpx/api/api.php";&gt;</domain># URL to GamePanelX API file
 $postfields["key"] = $api_key;
 $postfields["class"] = "servers";
 $postfields["action"] = "create";
 $postfields["game"] = "cs_s"; # Internal gamepanelx game name
 $postfields["username"] = "newuser123"; # New user to be created
 $postfields["email"] = "newuseremail123@email.com"; # New user's email
 $postfields["password"] = "somepass123"; # New pass ...
 $postfields["first_name"] = "Test";
 $postfields["last_name"] = "User";
 $postfields["slots"] = "16"; # Max players/slots
 
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_TIMEOUT, 100);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
 $data = curl_exec($ch);
 curl_close($ch);

Current classes that can be specified are "servers" and "users". More will be added later.

HTTP Example

To create a server using the API, make an HTTP call to your server like so:

  http://'''&lt;domain.com&gt;&lt;/domain.com&gt;'''/gpx/api/api.php?key='''&lt;gpx&gt;&lt;/gpx&gt;'''&class=servers&action=create&game='''cs_s'''&username=newguy1&password=pass12345&email=newguy@test.com&first_name=New&last_name=Guy&slots=16

This will create a server, and new user named "newguy1" with the password "pass12345", with the server type being "cs_s" (internal gpx name), which is Counter-Strike: Source. This assumes you already have a cs:s template created successfully. This also specifies a 16 slot/user/player server.

Server API Calls

create

Creates a new server. If you specify a username that doesn't exist, it will be created. A template must exist for this game and be set to Default.

Accepts: id, game, slots, username, password, email, first_name, last_name

How: &class=servers&action=create&game=cs_s&slots=16&username=newguy1&password=pass12345&email=newguy@test.com&first_name=New&last_name=Guy

delete

Delete a server.

Accepts: id

How: &class=servers&action=delete&id=1

restart

Restart a server.

Accepts: id

How: &class=servers&action=restart&id=1

stop

Stop a server.

Accepts: id

How: &class=servers&action=stop&id=1

update

Updates a server to the latest.

Accepts: id

How: &class=servers&action=update&id=1

sendcmd

Allows you to send a Screen command to a running server.

Accepts: id, cmd

How: &class=servers&action=sendcmd&id=1&cmd=status

getinfo

Gives you JSON output with lots of server details.

Accepts: id

How: &class=servers&action=getinfo&id=1

User Account API Calls

create

Creates a new user account.

Accepts: username, password, email, first_name, last_name

How: &class=users&action=create&username=newguy1&password=pass12345&email=newguy@test.com&first_name=New&last_name=Guy

delete

Deletes a user account. Will fail if there are any servers associated with the account.

Accepts: id

How: &class=users&action=delete&id=1

update

Update details of a user account.

Accepts: id, username, password, email, first_name, last_name, language, theme

How: &class=users&action=update&id=1&username=newguy1&password=pass12345&email=newguy@test.com&first_name=New&last_name=Guy&language=english&theme=default