Hello, this is an API!
This is an API for L4d-servers.com - Servers monitoring tool.
API accepts requests in GET string and returns data in JSON arrays. If you want to use this API firstly you need add your server to monitoring and get unique ServerID!
Click button below to add server to monitoring.
Contents
Methods
To recieve result you need to send GET request with valid parameters. Example request: https://l4d-servers.com/api/‹METHOD›/‹ServerID›/ will return JSON array with data.
- ‹METHOD› — One of the available methods
- ‹ServerID› — Existing ID of server in monitoring. You can find him on server page.
Status
Use this method to quickly obtain your Rust server's basic data, such as:
- Hostname
- Status (Online/Offline)
- Current players
- Total slots
Output:
{ "status": true, "name": "UNDERWORLD Co-Op", "status": "Online", "players": "2", "players_max": "25" }
Info
Use this method to quickly obtain your Left 4 Dead server's full data, same as Status +:
- Hostname
- Server IP
- Server Port
- Map name
- Status (Online/Offline)
- Average players
- Players Max forever + date
- Rating
- Server version
- Server's OS
- Country code, and full name + flags images
Output:
{ "success":true, "name":"UNDERWORLD Co-Op", "ip":"66.70.180.229", "port":"2400", "map":"l4d_garage01_alleys", "online_state":"1", "status":"Online", "players_cur":"20", "players_max":"80", "players_avg":"13", "rating":"77", "version":"1.05.152380", "os":"Windows", "country_iso":"CA", "country_name":"Canada", "country_img_16":"https://l4d-servers.com/images/flags/16/ca.png", "country_img_24":"https://l4d-servers.com/images/flags/24/ca.png" }
Example: Parse & Decode JSON and converting to php variables check it.
JavaScript
Besides JSON you can use JavaScript API. To start using this, you need to include
<script src="https://l4d-servers.com/api/js/‹ServerID›/"></script>
the <head>
section of an HTML page.
After that, in place where you want to display the current number of players, paste the code:
<script>document.write(players_cur);</script>
Full list of variables:
- server_ip
- server_port
- hostname
- map
- is_online - 1/0
- players_max
- players_cur
- players_avg
- rating
- version
- os
- country - ISO 3166
- country_full
Example: JavaScript API GitHub
Discord bot that displayes online players
Updates activity status on discord bot and displays how many players are connected to your game server that support sourcequery / rest api sites and webrcon.
All information about how can create bot you can find in GitHub (Thanks Kennethrisa)
Warning! In configuration file (config/serverX.json) apiSite should be = 1.
For example:
{
"debug" : false,
"token" : "your token here",
"apiSite" : 1,
"apiUrl" : "https://l4d-servers.com/api/info/60/",
"serverIp": "",
"serverPort": "28015",
"enableRcon" : "0",
"rconhost" : "",
"rconport" : "",
"rconpass" : "",
"prefix" : "!",
"roles" : ["Administrator", "admins"],
"queueMessage" : "currently waiting in queue.",
"statusType" : "",
"updateInterval" : "1"
}