Applications API
Overview
getApplications
Description
Returns a list of all the Red5 Pro web applications on the server.
REQUEST
- URI:
http://{host}:5080/api/v1/applications?accessToken={security-token}
- Method: GET
- Parameters:
Property | Type | Description | Required | Default |
---|---|---|---|---|
accessToken | Query Param | Security token | Required if token security is enabled |
RESPONSE
- Failure: NA
- Data: NA
- Success: HTTP CODE
200 - OK
- Data:
Example
REQUEST
- URI:
http://localhost:5080/api/v1/applications?accessToken=xyz123
- Method: GET
RESPONSE
- Success: HTTP CODE
200 - OK
- Data:
{
"status": "success",
"code": 200,
"data": [
"api",
"live"
],
"timestamp": 1467060546158
}
getApplicationStatistics
Description
Returns statistics for all applications or a selection of applications. Optionally you can provide the relative path to the scope (subdirectory of an application) if you wish to get statistics for that scope. A list of applications can be specified by providing multiple entries for query parameter 'app' in the query string.
REQUEST
- URI:
http://{host}:5080/api/v1/applications/statistics?accessToken={security-token}
- Method: GET
- Parameters:
Property | Type | Description | Required | Default |
---|---|---|---|---|
app | Query Param | Application name | Required | |
scope | Query Param | Application sub scope path | Optional (For use with single app request) | |
unit | Query Param | Unit of data transfer | Optional | b (bytes) |
accessToken | Query Param | Security token | Required if token security is enabled |
RESPONSE
- Failure: HTTP CODE
400
or404
or500
or401
See failure status code table for more information on error cause. - Data:
{
"status": "error",
"code": <http-status-code>,
"message": <error-message>",
"timestamp": <server-timestamp>
}
- Success: HTTP CODE
200 - OK
- Data: Returns a single ScopeStatistics json object or a list of ScopeStatistics json objects dependiing on number of application names specified. See Response objects for attribute definitions.
Example
REQUEST
-
URI:
http://localhost:5080/api/v1/applications/statistics?accessToken=xyz123
- Method: GET
RESPONSE
- Success: HTTP CODE
200 - OK
- Data:
{
"status": "success",
"code": 200,
"data": [
{
"name": "live",
"path": "/default",
"creation_time": 1467058529097,
"depth": 1,
"active_connections": 0,
"total_connections": 9,
"max_connections": 2,
"active_subscopes": 1,
"total_subscopes": 4,
"max_subscopes": 1,
"bytes_in": 10,
"bytes_out": 0,
"messages_out": 0,
"messages_in": 0,
"type": "application",
"data_unit": "b"
}
],
"timestamp": 1467060616203
}
getApplicationStatistics (single)
Description
Returns statistics for a single application. Optionally you can provide the relative path to the scope (subdirectory of an application) if you wish to get statistics for that scope.
REQUEST
-
URI :
http://{host}:5080/api/v1/applications/{appname}?accessToken={security-token}
- Method: GET
- Parameters:
Property | Type | Description | Required | Default |
---|---|---|---|---|
appname | Query Param | Application name | Required | |
scope | Query Param | Application sub scope path | Optional (For use with single app request) | |
unit | Query Param | Unit of data transfer | Optional | b (bytes) |
accessToken | Query Param | Security token | Required if token security is enabled |
RESPONSE
- Failure: HTTP CODE
400
or404
or500
or401
See failure status code table for more information on error cause. - Data:
{
"status": "error",
"code": <http-status-code>,
"message": <error-message>",
"timestamp": <server-timestamp>
}
- Success: HTTP CODE
200 - OK
- Data: Returns a single ScopeStatistics json object. See Response objects for attribute definitions.
Example
REQUEST
-
URI:
http://localhost:5080/api/v1/applications/live?accessToken=xyz123
- Method: GET
RESPONSE
- Success: HTTP CODE
200 - OK
- Data:
{
"status": "success",
"code": 200,
"data": {
"name": "live",
"path": "/default",
"creation_time": 1467058529097,
"depth": 1,
"active_connections": 0,
"total_connections": 9,
"max_connections": 2,
"active_subscopes": 1,
"total_subscopes": 4,
"max_subscopes": 1,
"bytes_in": 10,
"bytes_out": 0,
"messages_out": 0,
"messages_in": 0,
"type": "application",
"data_unit": "b"
},
"timestamp": 1467060616203
}
invoke
Description
Invokes a custom method on the application's ApplicationAdapter class. Note: HTTP to java RMI has limitations. Use String, Double (for numerics).
The invoke api is applicable only to custom developed Red5Pro applications and is used for invoking custom methods on the ApplicationAdapter. These custom methods may carry a business logic which is specific to the given application.
REQUEST
-
URI:
http://{host}:5080/api/v1/applications/{appname}/invoke?accessToken={security-token}
- Method: POST
- Parameters:
Property | Type | Description | Required | Default |
---|---|---|---|---|
appname | Path Param | Application name | Required | |
Custom Method Invoke Object | Post Param | Json Complex Object | Required | |
accessToken | Query Param | Security token | Required if token security is enabled |
Custom Method Invoke Object
{
"method": "",
"parameters": [ ]
}
RESPONSE
- Failure: HTTP CODE
400
or404
or500
or401
See failure status code table for more information on error cause. - Data:
{
"status": "error",
"code": <http-status-code>,
"message": <error-message>",
"timestamp": <server-timestamp>
}
- Success: HTTP CODE
200 - OK
- Data: Custom Json serialized object as per developer's return type in the invoked method.
{
"status": "success",
"code": 200,
"data": {CustomResponseObject},
"timestamp": 1467060941836
}
Example 1
Below is a sample of the ApplicationAdapter of a custom Red5 Pro application with a custom method called sayHello. The objective of the method is to recieve a clientname parameter and return a welcome message.
public class Application extends MultiThreadedApplicationAdapter
{
private static Logger log = Red5LoggerFactory.getLogger(Application.class, "Application");
public String sayHello(String name)
{
return "Welcome " + name;
}
}
REQUEST
-
URI:
http://localhost:5080/api/v1/applications/api/invoke?accessToken=xyz123
- Method: POST
- Data: JSON
{
"method": "sayHello",
"parameters": [
"Tony"
]
}
RESPONSE
- Success: HTTP CODE
200 - OK
- Data:
{
"status": "success",
"code": 200,
"data": "Welcome Tony",
"timestamp": 1467193076102
}
Example 2
In this example we have a custom made application with a method to accept two integers and print the sum. Below is a sample of the ApplicationAdapter of a custom Red5 Pro application with a custom method called getSum. The objective of the method is to receive two parameters and return the sum.
public class Application extends MultiThreadedApplicationAdapter
{
private static Logger log = Red5LoggerFactory.getLogger(Application.class, "Application");
public Integer add(Double a, Double b)
{
return a.intValue() + b.intValue();
}
}
Note that the parameters type is declared as Double. This is because any number in json is a float (contains decimal place). So if you pass 1 it is treated as 1.0. However when returning a result, you may return any data type which can be serialized into json.
REQUEST
-
URI:
http://localhost:5080/api/v1/applications/api/invoke?accessToken=xyz123
- Method: POST
- Data: JSON
{
"method": "getSum",
"parameters": [
1,
2
]
}
RESPONSE
- Success: HTTP CODE
200 - OK
- Data:
{
"status": "success",
"code": 200,
"data": 3,
"timestamp": 1467193610836
}