Difference between revisions of "Lobby HTTP API"

From Soldat Community Wiki
Jump to: navigation, search
(add http api docs)
 
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
Recently, we added a standard json-based REST HTTP API to make getting the list of Soldat servers much easier for third party applications.
+
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.
 +
* [https://forums.soldat.pl/index.php?topic=44915.0 Forum thread] where this was originally announced. Feel free to comment on this thread with feature requests.
  
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 ==
 
== List all servers, with filters ==
Line 8: Line 10:
 
  http://api.soldat.pl/v0/servers
 
  http://api.soldat.pl/v0/servers
  
List all Soldat servers. You can provide a combination of these GET parameters as filters:
+
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
 
   ?os=linux|mac|windows
Line 21: Line 23:
 
   ?survival=yes|no
 
   ?survival=yes|no
 
   ?advanced=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:
 
Example response:
Line 31: Line 37:
 
             "BonusFreq": 0,
 
             "BonusFreq": 0,
 
             "ConnectionType": 3,
 
             "ConnectionType": 3,
             "Country": "FR",
+
             "Country": "US",
             "CurrentMap": "Blox",
+
             "CurrentMap": "ctf_Viet",
 
             "Dedicated": true,
 
             "Dedicated": true,
             "GameStyle": "DM",
+
             "GameStyle": "CTF",
             "IP": "5.135.160.192",
+
             "IP": "108.61.204.90",
             "Info": "GamingCrew.pl",
+
             "Info": "~ facebook.com/AUS7RAL12 | #austral12soldat @ Qnet",
             "MaxPlayers": 5,
+
             "MaxPlayers": 12,
             "Name": "GamingCrew.pl[1vs1]#2",
+
             "Name": "=AUS7RAL|12 OneShots",
 
             "NumBots": 0,
 
             "NumBots": 0,
             "NumPlayers": 0,
+
             "NumPlayers": 1,
 
             "OS": "linux",
 
             "OS": "linux",
             "Port": 23078,
+
             "Port": 23075,
 
             "Private": false,
 
             "Private": false,
 
             "Realistic": false,
 
             "Realistic": false,
Line 49: Line 55:
 
             "Version": "1.7.1",
 
             "Version": "1.7.1",
 
             "WM": false
 
             "WM": false
         }]
+
         }
 +
    ]
 
  }
 
  }
 +
  
 
== Get data on server ==
 
== Get data on server ==
Line 82: Line 90:
 
     "WM": false
 
     "WM": false
 
  }
 
  }
 +
  
 
== Get players for a server ==
 
== Get players for a server ==
Line 101: Line 110:
 
     ]
 
     ]
 
  }
 
  }
 +
 +
 +
[[Category:Server]]

Latest revision as of 21:38, 16 April 2018

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"
   ]
}