-
Notifications
You must be signed in to change notification settings - Fork 1
Web API
Usage of server API controller:
http://example.com/server/api.php?apikey={APIKEY}&do={METHOD}&{PARAMS}
Request type is always GET
. The each method returns JSON with response result
or error
:
{'result':'data'}
or
{'error':'message'}
Get list of installed servers
Return
servers array where each item includes: id, status and name
Example
api.php?do=serverlist
{"result":{"1":{"id":1,"status":true,"hostname":"Server #1"},"2":{"id":2,"status":false,"hostname":"Server #2"}}}
Get status of windows server (service can be started but nfk server is not responding)
Parameters
- id - server id
Return
true (running) or false (stopped)
Example
api.php?do=status&id=1
{"result":false}
Start server
Parameters
- id - server id
Return
true
Example
api.php?do=start&id=1
{"result":true}
Stop server
Parameters
- id - server id
Return
true
Example
api.php?do=stop&id=1
{"result":true}
Edit server name in config
Parameters
- id - server id
- name - command text (urlencoded)
Return
edited server name
Example
api.php?do=editname&id=1&name=%5E%21server%20name%20%231
{"result":"^!server name #1"}
Get log data from a specified position
Parameters
- id - server id
- pos - log file position to start read from (if not passed or equal 0 then read maximum allowed size from the end of log)
Return
array with current
pos
anddata
(pos
can be used for next method call to get only updated chunk of log)
Example
api.php?do=getlog&id=1&pos=1000
{"result":{"pos":424408,"data":"[1\/24\/2013 3:44:22 AM] console: \"r_wateralpha\" is set t..."}}
Send console command to server
Parameters
- id - server id
- cmd - command text (urlencoded)
Return
true
Example
api.php?do=scc&id=1&cmd=say%20hello
{"result":true}