MistServer
2.5.3-Pro-19-gf5e75b1 ( Generic_64)
|
Listing of all controller API calls.
The controller listens for commands through a JSON-based API. This page describes the API in full.
A default interface implementing this API as a single HTML page is included in the controller itself. This default interface will be send for invalid API requests, and is thus triggered by default when a browser attempts to access the API port directly. The default API port is 4242 - but this can be changed through both the API and commandline parameters.
To send an API request, simply send a HTTP request to this port for any file, and include either a GET or POST parameter called "command"
, containing a JSON object as payload. Nearly all members of the request object are optional, and described below. A simple example request logging in to the system would look like this:
GET /api?command={"authorize":{"username":"test","password":"941d7b88b2312d4373aff526cf7b6114"}} HTTP/1.0
Or, when properly URL encoded:
GET /api?command=%7B%22authorize%22%3A%7B%22username%22%3A%22test%22%2C%22password%22%3A%22941d7b88b2312d4373aff526cf7b6114%22%7D%7D HTTP/1.0
The server is quite lenient about not URL encoding your strings, but it's a good idea to always do it, anyway. See the "authorize"
section below for more information about security and logging in.
As mentioned above, sending an invalid request will trigger a response containing the default interface. As you may not want to receive a big HTML page as response to an invalid request, requesting the file "/api"
(as done in the example above) will force a JSON response, even when the request is invalid.
You may also include a "callback"
or "jsonp"
HTTP variable, to trigger JSONP compatibility mode. JSONP is useful for getting around the cross-domain scripting protection in most modern browsers. Developers creating non-JavaScript applications will most likely not want to use JSONP mode, though nothing is stopping you if you really want to.
"authorize"
request must be sent. Since HTTP does not use persistent connections, you are required to re-sent authentication with every API request made. To prevent plaintext sending of the password, a random challenge string is sent first, and then the password is hashed together with this challenge string to create a one-time-use string to login with. If the user is not authorized, this request is the only request the server will respond to until properly authorized. "authorize"
requests take the form of: "NOACC"
, where it is left out. A status of "OK"
means you are currently logged in and have access to all other API requests. A status of "CHALL"
means you are not logged in, and a challenge has been provided to login with. A status of "NOACC"
means there are no valid accounts to login with. In this case - and ONLY in this case - it is possible to create a initial login through the API itself. To do so, send a request as follows: "ACC_MADE"
indicates the account was created successfully and can now be used to login as normal. "capabilities"
requests are always empty: "config"
requests take the form of: "streams"
requests take the form of: "update"
and "checkupdate"
requests (LTS-only) are responded to as: ~~~~~~~~~~~~~~~{.js} { "error": "Something went wrong", // 'Optional' "release": "LTS64_99", "version": "1.2 / 6.0.0", "date": "January 5th, 2014", "uptodate": 0, "needs_update": ["MistBuffer", "MistController"], //Controller is guaranteed to be last "MistController": "abcdef1234567890", //md5 sum of latest version //... "active_streams"
and "stats_streams"
requests may either be empty, in which case the response looks like this: "stats_streams"
will list all streams that any statistics data is available for, and only those. "active_streams"
only lists streams that are currently active, and only those. If the request is an array, which may contain any of the following elements: "clients"
requests take the form of: "totals"
requests take the form of: "addstream"
requests (LTS-only) take the form of:
These requests will add new streams or update existing streams with the same names, without touching other streams. In other words, this call can be used for incremental updates to the stream list instead of complete updates, like the "streams" call. Sending "addstream"
or "deletestream"
as part of your request will alter the "streams"
response. As opposed to a full list of streams, this will now include a property "incomplete list"
set to 1 and only include successfully added streams. As deletions cannot fail, these are never mentioned.
"deletestream"
requests (LTS-only) take the form of:
OR
OR
These requests will remove the named stream(s), without touching other streams. In other words, this call can be used for incremental updates to the stream list instead of complete updates, like the "streams" call. Sending "addstream"
or "deletestream"
as part of your request will alter the "streams"
response. As opposed to a full list of streams, this will now include a property "incomplete list"
set to 1 and only include successfully added streams. As deletions cannot fail, these are never mentioned.
"addprotocol"
requests (LTS-only) take the form of:
OR
These requests will add the given protocol configurations, without touching existing configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
"deleteprotocol"
requests (LTS-only) take the form of:
OR
These requests will remove the given protocol configurations (exact matches only), without touching other configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
"browse"
requests take the form of:
and are responded to as:
"save"
requests are always empty:
Sending this request will cause the controller to write out its currently active configuration to the configuration file it was loaded from (the default being ./config.json
).
"ui_settings"
requests can take two forms. The first is the "set" form:
The second is the "request" form, and takes any non-object as argument. When using the set form, this will write the given object verbatim into the controller storage. No matter which form is used, the current contents of the ui_settings object are always returned in the response. This API call is intended to store User Interface settings across sessions, and its contents are completely ignored by the controller itself. Besides the requirement of being an object, the contents are entirely free-form and may technically be used for any purpose.
LTS builds will always include an "LTS"
response, set to 1.
"autoupdate"
requests (LTS-only) will cause MistServer to apply a rolling update to itself, and are not responded to.
"log"
responses are always sent, and cannot be requested:
It's possible to clear the stored logs by sending an empty "clearstatlogs"
request.
"deletestream"
requests (LTS-only) take the form of:
OR
OR
These requests will remove the named stream(s), without touching other streams. In other words, this call can be used for incremental updates to the stream list instead of complete updates, like the "streams" call. Sending "addstream"
or "deletestream"
as part of your request will alter the "streams"
response. As opposed to a full list of streams, this will now include a property "incomplete list"
set to 1 and only include successfully added streams. As deletions cannot fail, these are never mentioned.
"addprotocol"
requests (LTS-only) take the form of:
OR
These requests will add the given protocol configurations, without touching existing configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
"deleteprotocol"
requests (LTS-only) take the form of:
OR
These requests will remove the given protocol configurations (exact matches only), without touching other configurations. In other words, this call can be used for incremental updates to the protocols list instead of complete updates, like the "config" call. There is no response to this call.
"browse"
requests take the form of:
and are responded to as:
"save"
requests are always empty:
Sending this request will cause the controller to write out its currently active configuration to the configuration file it was loaded from (the default being ./config.json
).
"ui_settings"
requests can take two forms. The first is the "set" form:
The second is the "request" form, and takes any non-object as argument. When using the set form, this will write the given object verbatim into the controller storage. No matter which form is used, the current contents of the ui_settings object are always returned in the response. This API call is intended to store User Interface settings across sessions, and its contents are completely ignored by the controller itself. Besides the requirement of being an object, the contents are entirely free-form and may technically be used for any purpose.
LTS builds will always include an "LTS"
response, set to 1.
"autoupdate"
requests (LTS-only) will cause MistServer to apply a rolling update to itself, and are not responded to.
"log"
responses are always sent, and cannot be requested:
It's possible to clear the stored logs by sending an empty "clearstatlogs"
request.