Skip to content

HTTP API

Tim Stableford edited this page Mar 11, 2017 · 2 revisions

/api/login

Asks for basic auth login. On success it returns {"token": ""}. It also attempts to set the cookie token. If no cookie token is already set a new one is created.

/api/validate?token=

Returns status code 200 if the token is valid. Does not create new tokens. Tokens can also be retrieved from cookies.

/api/logout/:user?

When called as just /api/logout it deleted only the current login, if it exists. If a user is supplies such as /api/logout/brain then all tokens for that user will be removed. A standard user can call this for themselves, admins can call it for anyone.

/api/ask?q=

Runs a query with a JSON response. Returns JSON on success. If no token cookie is detected, a login will be requested. New tokens are not created with this call.

/api/settings/global_setting/:key?

If the user is an admin it allows viewing and setting global settings. New tokens are not created with this API. Key is optional. Eg. Get Port Number /api/settings/global_setting/port. Get all global settings /api/settings/global_setting/port?value=1234. All results are returned in a format compatible with JSON.parse().

/api/settings/skill_settings/:skill?/:key?

The same as global settings but on a per skill basis. If name is not provided then it shows all settings for a skill, if neither name nor skill are provided it shows all settings for all skills.

/api/settings/user_settings/:user?/:skill?/:key?

The same as above except with an optional user parameter. Non-admins can view and set their own data. Admins can view/set all users.