API
API принимает GET запросы и возвращает данные в массиве
Нажмите кнопку ниже, чтобы добавить сервер в мониторинг.
Содержание
Methods
To recieve result you need to send GET request with valid parameters. Example request: https://gamemetrics.ru/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 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://gamemetrics.ru/images/flags/16/ca.png", "country_img_24":"https://gamemetrics.ru/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://gamemetrics.ru/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://gamemetrics.ru/api/info/60/",
"serverIp": "",
"serverPort": "28015",
"enableRcon" : "0",
"rconhost" : "",
"rconport" : "",
"rconpass" : "",
"prefix" : "!",
"roles" : ["Administrator", "admins"],
"queueMessage" : "currently waiting in queue.",
"statusType" : "",
"updateInterval" : "1"
}