-
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 service (service can be started but nfk server is not responding)
Parameters
- id - server id
Return
bool (true = running | false = stopped)
Example
api.php?do=status&id=1
{"result":false}
Start server
Parameters
- id - server id
Return
bool
Example
api.php?do=start&id=1
{"result":true}
Stop server
Parameters
- id - server id
Return
bool
Example
api.php?do=stop&id=1
{"result":true}
Stop and then start server
Parameters
- id - server id
Return
bool
Example
api.php?do=restart&id=1
{"result":true}
Return contents from a specified file.
Allowed files: maplist.txt, server.cfg, message.cfg, startup.cfg, autoexec.cfg, nfkconfig.cfg, nfksetup.ini
Parameters
- id - server id
- file - local server file name
Return
file contents
Example
api.php?do=getfile&id=1&file=maplist.txt
{"result":"pro-dm0 dm\ndm2 dm\ntourney4 dm\ncmp3 dm\ndm13 dm\ndm6 dm\ntourney0 dm\ntourney1 dm\ntourney7 dm\nmdm1 dm\n"}
Save file contents from url to a specified file.
Allowed files the same as in getfile
method.
Parameters
- id - server id
- file - local server file name
- url - (urlencoded) remote url from where the api must download data to save
Return
true
Example
api.php?do=savefile&id=1&file=maplist.txt&url=&url=http%3A//example.com/client/file.php%3Fhash%3Db5639998ca953c6f0870b2cede18488f
{"result":true}
Edit server name in config
Parameters
- id - server id
- name - (urlencoded) new server name
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 - (urlencoded) command text
Return
true
Example
api.php?do=scc&id=1&cmd=say%20hello
{"result":true}