/

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:
PropertyTypeDescriptionRequiredDefault
accessTokenQuery ParamSecurity tokenRequired 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:
PropertyTypeDescriptionRequiredDefault
appQuery ParamApplication nameRequired
scopeQuery ParamApplication sub scope pathOptional (For use with single app request)
unitQuery ParamUnit of data transferOptionalb (bytes)
accessTokenQuery ParamSecurity tokenRequired if token security is enabled

RESPONSE

  • Failure: HTTP CODE 400 or 404 or 500 or 401 See failure status code table for more information on error cause.
  • Data:
{
  "status": "error",
  "code": <http-status-code>,
  "message": <error-message>",
  "timestamp": <server-timestamp>
}

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:
PropertyTypeDescriptionRequiredDefault
appnameQuery ParamApplication nameRequired
scopeQuery ParamApplication sub scope pathOptional (For use with single app request)
unitQuery ParamUnit of data transferOptionalb (bytes)
accessTokenQuery ParamSecurity tokenRequired if token security is enabled

RESPONSE

  • Failure: HTTP CODE 400 or 404 or 500 or 401 See failure status code table for more information on error cause.
  • Data:
{
  "status": "error",
  "code": <http-status-code>,
  "message": <error-message>",
  "timestamp": <server-timestamp>
}

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:
PropertyTypeDescriptionRequiredDefault
appnamePath ParamApplication nameRequired
Custom Method Invoke ObjectPost ParamJson Complex ObjectRequired
accessTokenQuery ParamSecurity tokenRequired if token security is enabled

Custom Method Invoke Object

{
  "method": "",
  "parameters": [ ]
}

RESPONSE

  • Failure: HTTP CODE 400 or 404 or 500 or 401 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
}