You need to have the following in your config:
{
"api": {
"enabled": true,
"blacklist": [],
"ip": "0.0.0.0",
"port": 3680,
"whitelist": []
}
}
You can configure the users in the users.json
.
Make sure that the passwords in the config are sha512
hashed.
There are currently three types of messages:
{
"type": "event",
"subtype": "<...>",
"data": <json_object>
}
{
"type": "request",
"subtype": "<...>",
"id": <snowflake_number>,
"data": <json_object>
}
You can send any id
which you will get back in the corresponding answer
{
"type": "answer",
"subtype": "<...>",
"id": <same_as_request_id>,
"error": 0,
"errormessage": "",
"data": <json_object>
}
The "data"
object depends on the "subtype"
(See Message Catalogue).
After a connection loss, the token is valid for another 15 minutes to relogin without using the users credentials.
You will get a new token after a successful relogin.
Error | Message |
---|---|
1 | request format error (id hardcoded to -1 . Connection will get closed) |
2 | too much data for one frame |
3 | not logged in |
4 | unknown request subtype |
5 | wrong message data format |
6 | failed apilogin request |
7 | no permission to process request |
8 | (getconfig /getlanguage ) error reading file |
9 | (writeconfig /writelanguage ) error writing file |
10 | (deleteconfig /deletelanguage ) error deleting file |
Only the data
object will be shown
apilogin
Either token
or username
and password
are null.
{
"username": <string|null>,
"password": <string|null>,
"token": <string|null>
}
{
"token": <string>
}
getplayers
null
Array of all players (Player::getPlayerInfos()
)
[
{"ip": "1.2.3.4", "pid": 8 },
{"ip": "2.3.4.5", "pid": 9 }
]
getconfig
{
"file": "filename"
}
"content of file"
deleteconfig
{
"file": "filename"
}
null
writeconfig
{
"file": "filename",
"content": "content of file"
}
null
getlanguage
{
"file": "filename"
}
"content of file"
deletelanguage
{
"file": "filename"
}
null
writelanguage
{
"file": "filename",
"content": "content of file"
}
null
addtoken
{
"group": "name of group"
}
"token"
gettokens
null
{
"tokenstr": "groupname",
"token2str": "groupname"
}
deletetoken
{
"token": "tokenstr"
}
true
executeingamecommand
{
"command": "readconfig"
}
The data
string contains the output the user would normally get via a PM ingame.
So most of the time this will be an empty string.
"Command PM output"
getplugins
null
{
"plugin.name.space1": {
"information": "<...>",
"compatibility": [],
"state": {}
},
"plugin.name.space2": {
"information": "<...>",
"compatibility": [],
"state": {}
}
}
quitgsmanager
null
true
getbanlist
null
Output of BanHelper::getAllBans()
["List of all bans"]
permissiontest
["permission1", "permission2"]
{
"permission1": true,
"permission2": false
}
getcommandpermissions
null
[
"permission1",
"permission2",
"some.other.per.mission"
]
getplayerinfo
{
"databaseid": 5
}
{
"user": "<database_row>",
"stats": "<database_row>",
"rest": "of player info from db"
}
subscribeevent
For List of events check https://www.gsmanager.de/lexicon/entry/34-list-of-events/
(07.03.2018: Status incomplete)
{
"name": "playerJoined"
}
null
unsubscribeevent
{
"name": "playerJoined"
}
null
listpresetfiles
null
["file1", "file2"]