/

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 (all apps)

Description

Returns statistics for all applications.

REQUEST

  • URI:http://{host}:5080/api/v1/applications/statistics?accessToken={security-token}
  • Method: GET
  • Parameters:
PropertyTypeDescriptionRequiredDefault
unitQuery ParamUnit of data transferOptionalb (bytes), kb, mb, gb
accessTokenQuery ParamSecurity tokenRequired if token security is enabled
appQuery Paramweb app to include in the reportOptional

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: Returns a list of ScopeStatistics JSON objects, depending on the number of apps that are running under red5pro. See Response objects for attribute definitions. A filtered list of applications can also be specified by providing one or multiple entries for the query parameter 'app' in the query string.

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": "api",
            "path": "/default",
            "creation_time": 1623880035035,
            "depth": 1,
            "active_connections": 0,
            "total_connections": 0,
            "max_connections": 0,
            "active_subscopes": 0,
            "total_subscopes": 0,
            "max_subscopes": 0,
            "bytes_in": 0.0,
            "bytes_out": 0.0,
            "messages_out": 0,
            "messages_in": 0,
            "type": "application",
            "data_unit": "b"
        },
        {
            "name": "live",
            "path": "/default",
            "creation_time": 1623880034862,
            "depth": 1,
            "active_connections": 0,
            "total_connections": 0,
            "max_connections": 0,
            "active_subscopes": 0,
            "total_subscopes": 0,
            "max_subscopes": 0,
            "bytes_in": 0.0,
            "bytes_out": 0.0,
            "messages_out": 0,
            "messages_in": 0,
            "type": "application",
            "data_unit": "b"
        },
        {
            "name": "streammanager",
            "path": "/default",
            "creation_time": 1623880034917,
            "depth": 1,
            "active_connections": 0,
            "total_connections": 0,
            "max_connections": 0,
            "active_subscopes": 0,
            "total_subscopes": 0,
            "max_subscopes": 0,
            "bytes_in": 0.0,
            "bytes_out": 0.0,
            "messages_out": 0,
            "messages_in": 0,
            "type": "application",
            "data_unit": "b"
        }
    ],
    "timestamp": 1623880073212
}

Example2

REQUEST

  • URI:

    http://localhost:5080/api/v1/applications/statistics?accessToken=xyz123&app=live&app=api
  • Method: GET

RESPONSE

  • Success: HTTP CODE 200 - OK
  • Data:
{
    "status": "success",
    "code": 200,
    "data": [
        {
            "name": "api",
            "path": "/default",
            "creation_time": 1623880035035,
            "depth": 1,
            "active_connections": 0,
            "total_connections": 0,
            "max_connections": 0,
            "active_subscopes": 0,
            "total_subscopes": 0,
            "max_subscopes": 0,
            "bytes_in": 0.0,
            "bytes_out": 0.0,
            "messages_out": 0,
            "messages_in": 0,
            "type": "application",
            "data_unit": "b"
        },
        {
            "name": "live",
            "path": "/default",
            "creation_time": 1623880034862,
            "depth": 1,
            "active_connections": 0,
            "total_connections": 0,
            "max_connections": 0,
            "active_subscopes": 0,
            "total_subscopes": 0,
            "max_subscopes": 0,
            "bytes_in": 0.0,
            "bytes_out": 0.0,
            "messages_out": 0,
            "messages_in": 0,
            "type": "application",
            "data_unit": "b"
        }
    ],
    "timestamp": 162384973212
}

getApplicationStatistics (single app)

Description

Returns statistics for a single application. Optionally you can provide the relative path to the scope (a 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
appnamePath ParamApplication nameRequired
scopeQuery ParamApplication sub-scope pathOptional (For use with single app request)
unitQuery ParamUnit of data transferOptionalb (bytes), kb, mb, gb
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 that 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 receive 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 parameter type is declared as Double. This is because any number in JSON is a float (contains a 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
}