Lobby HTTP API

From Soldat Community Wiki
Revision as of 22:38, 16 April 2018 by Nosejj (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

  • URL: http://api.soldat.pl (https is also supported)
  • CORS headers are present so this can be used via ajax.
  • Forum thread where this was originally announced. Feel free to comment on this thread with feature requests.


List all servers, with filters

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

List all Soldat servers. You can provide a combination of the following GET parameters as filters. The pipes represent unique options, and the 3 dots represent other options which you can guess.

 ?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 URL filtering servers that aren't empty and don't have bots:

http://api.soldat.pl/v0/servers?empty=no&bots=no

Example response:

{
   "Servers": [
       {
           "AC": false,
           "Advanced": false,
           "BonusFreq": 0,
           "ConnectionType": 3,
           "Country": "US",
           "CurrentMap": "ctf_Viet",
           "Dedicated": true,
           "GameStyle": "CTF",
           "IP": "108.61.204.90",
           "Info": "~ facebook.com/AUS7RAL12 | #austral12soldat @ Qnet",
           "MaxPlayers": 12,
           "Name": "=AUS7RAL|12 OneShots",
           "NumBots": 0,
           "NumPlayers": 1,
           "OS": "linux",
           "Port": 23075,
           "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"
   ]
}