Difference between revisions of "Lobby HTTP API"

From Soldat Community Wiki
Jump to: navigation, search
(add http api docs)
(No difference)

Revision as of 08:54, 1 September 2017

Recently, we added a standard json-based REST HTTP API to make getting the list of Soldat servers much easier for third party applications.

URL: http://api.soldat.pl (https is also supported) CORS headers are present so this can be used via ajax.

List all servers, with filters

http://api.soldat.pl/v0/servers

List all Soldat servers. You can provide a combination of these GET parameters as filters:

 ?os=linux|mac|windows
 ?gamestyle=DM|PM|TM|CTF|RM|INF|HTF
 ?country=US|DE|...
 ?version=1.7.1|1.6.1|...
 ?empty=yes|no
 ?full=yes|no
 ?bots=yes|no
 ?private=yes|no
 ?realistic=yes|no
 ?survival=yes|no
 ?advanced=yes|no

Example response:

{
   "Servers": [
       {
           "AC": false,
           "Advanced": false,
           "BonusFreq": 0,
           "ConnectionType": 3,
           "Country": "FR",
           "CurrentMap": "Blox",
           "Dedicated": true,
           "GameStyle": "DM",
           "IP": "5.135.160.192",
           "Info": "GamingCrew.pl",
           "MaxPlayers": 5,
           "Name": "GamingCrew.pl[1vs1]#2",
           "NumBots": 0,
           "NumPlayers": 0,
           "OS": "linux",
           "Port": 23078,
           "Private": false,
           "Realistic": false,
           "Respawn": 0,
           "Survival": false,
           "Version": "1.7.1",
           "WM": false
       }]
}

Get data on server

http://api.soldat.pl/v0/server/$ip/$port

Example response:

{
   "AC": false,
   "Advanced": false,
   "BonusFreq": 0,
   "ConnectionType": 3,
   "Country": "US",
   "CurrentMap": "Island2k5",
   "Dedicated": true,
   "GameStyle": "DM",
   "IP": "207.152.134.13",
   "Info": "Eat Moar Chik'n",
   "MaxPlayers": 10,
   "Name": "Drop a Penny",
   "NumBots": 0,
   "NumPlayers": 0,
   "OS": "windows",
   "Port": 23073,
   "Private": false,
   "Realistic": true,
   "Respawn": 0,
   "Survival": false,
   "Version": "1.7.1",
   "WM": false
}

Get players for a server

http://api.soldat.pl/v0/server/$ip/$port/players

This will make the lobby use the file download protocol to grab that server's gamestat.txt file and parse and display the players currently in the server. FYI: This makes use of caching to prevent abuse.

Example response:

{
   "Players": [
       "/././a.d.i.d.a.s/././",
       "Alvarez",
       "Freedom Fighter",
       "Guenther Gummibrot",
       "summer camp",
       "|TPF. GottenSikici"
   ]
}