Create and manage stream targets by using the Wowza Streaming Engine REST API

You can use the Wowza Streaming Engine™ media server software REST API to identify and manage stream targets in a Wowza Streaming Engine instance.

Notes:

Enable push publishing in the Wowza Streaming Engine REST API


Before you can create or use stream targets with the Wowza Streaming Engine REST API, you must enable the push publishing module. To do so, you need to add an advanced property to the application's configuration and add the push publish module to the application.

Start by retrieving the details of the application's advanced settings and a list of the modules the application is using. Retrieve the information by sending a GET call to the endpoint /v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv.

Note: Wowza Streaming Engine REST API requests must include three headers: Accept:application/json, Content-Type:application/json, and charset=utf-8. For more information, see Query the Wowza Streaming Engine REST API.

Example request:

curl -X GET \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv"

The request returns an object (advancedSettings) that shows the application's advanced settings and a modules list of the modules in use. The response looks something like this:

{
  "version": "1543353224014",
  "serverName": "serverName",
  "advancedSettings": [
    {
      "enabled": false,
      "canRemove": true,
      "name": "debugAACTimecodes",
      "value": "false",
      "defaultValue": "false",
      "type": "Boolean",
      "sectionName": "cupertinostreamingpacketizer",
      "section": "/Root/Application/LiveStreamPacketizer",
      "documented": true
    },
    {
      "enabled": false,
      "canRemove": true,
      "name": "debugMP3Timecodes",
      "value": "false",
      "defaultValue": "false",
      "type": "Boolean",
      "sectionName": "cupertinostreamingpacketizer",
      "section": "/Root/Application/LiveStreamPacketizer",
      "documented": true
    },
    ...
  ],
  "modules": [
    {
      "order": 0,
      "name": "base",
      "description": "Base",
      "class": "com.wowza.wms.module.ModuleCore"
    },
    {
      "order": 1,
      "name": "logging",
      "description": "Client Logging",
      "class": "com.wowza.wms.module.ModuleClientLogging"
    },
    {
      "order": 2,
      "name": "flvplayback",
      "description": "FLVPlayback",
      "class": "com.wowza.wms.module.ModuleFLVPlayback"
    },
    {
      "order": 3,
      "name": "ModuleCoreSecurity",
      "description": "Core Security Module for Applications",
      "class": "com.wowza.wms.security.ModuleCoreSecurity"
    },
  ]
}

Now, execute a PUT command to accomplish two tasks:

  1. Add the pushPublishMapPath property to the application's configuration and
  2. Append the ModulePushPublish to the complete list of modules in use.

Note: The PUT command must include all of the existing modules in use by the application as well as the push publish module; use the response from the GET call to enumerate the modules that precede ModulePushPublish in the PUT call.

The command calls the same endpoint, /v2/servers/{serverName}/vhosts/(vhostName}/applications/{appName}/adv, and looks like this:

curl -X PUT \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \ 
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv"
{
  "version": "1543353224014",
  "serverName": "serverName",
  "advancedSettings": [
    {
      "enabled": true,
      "canRemove": false,
      "name": "pushPublishMapPath",
      "value": "${com.wowza.wms.context.VHostConfigHome}/conf/${com.wowza.wms.context.Application}/PushPublishMap.txt",
      "defaultValue": null,
      "type": "String",
      "sectionName": "Application",
      "section": "/Root/Application",
      "documented": false
    }
  ],
  "modules": [
    {
      "order": 0,
      "name": "base",
      "description": "Base",
      "class": "com.wowza.wms.module.ModuleCore"
    },
    {
      "order": 1,
      "name": "logging",
      "description": "Client Logging",
      "class": "com.wowza.wms.module.ModuleClientLogging"
    },
    {
      "order": 2,
      "name": "flvplayback",
      "description": "FLVPlayback",
      "class": "com.wowza.wms.module.ModuleFLVPlayback"
    },
    {
      "order": 3,
      "name": "ModuleCoreSecurity",
      "description": "Core Security Module for Applications",
      "class": "com.wowza.wms.security.ModuleCoreSecurity"
    },
    {
      "order": 4,
      "name": "ModulePushPublish",
      "description": "ModulePushPublish",
      "class": "com.wowza.wms.pushpublish.module.ModulePushPublish"
    }
  ]
}

Finally, restart the application, and then you can create and edit stream targets using the Wowza Streaming Engine REST API.

curl -X PUT \
-H 'Accept:application/json; charset=utf-8' \ 
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/actions/restart"

Get a list of stream targets


View a list of stream targets for an application:

curl -X GET \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries

View a list of stream targets for an application named testlive:

curl -X GET \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/pushpublish/mapentries

Create a stream target


Create a stream target for the Wowza Streaming Engine testlive application (an RTMP destination) with an entryName of ppsource.

Note: The parameters required vary by stream target destination type. All stream targets must have an entryName and profile specified. See Sample map file entries for Stream Target destinations (push publishing) for the lists of additional required and optional parameters you can specify for each stream target destination types.

curl -X POST \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-type:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/pushpublish/mapentries/ppsource \
-d'
{
   "serverName": "serverName",
   "sourceStreamName": "streamName",
   "entryName": "ppsource",
   "profile": "rtmp",
   "host": "localhost",
   "application": "testlive",
   "userName": "testUser",
   "password": "pass",
   "streamName": "streamName"
}'

Create a CDN stream target in Wowza Streaming Engine for distribution with Wowza Video. The following example adds a stream target named wv-stream-target to the live application. The single stream setting is used to push the source to Wowza Video. For more, see wowza-cdn profile parameters.

curl -X POST \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-type:application/json; charset=utf-8' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/live/pushpublish/mapentries/{entryName}" \
-d '
{
  "sourceStreamName": "myStream",
  "entryName": "wv-stream-target",
  "profile": "wowza-cdn",
  "wowzaVideo.region":"us",
  "group.streamMatcher": "nameSingle",
  "extraOptions": {
    "destinationName": "wowzavideocdn"
  }
}'

Update a stream target


Update a stream target:

curl -X PUT \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-type:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries/{entryName} \
-d'
{
   "serverName": "serverName",
   "sourceStreamName": "streamName",
   "entryName": "entryName",
   "profile": "rtmp",
   "host": "localhost",
   "application": "appName",
   "userName": "testUser",
   "password": "pass",
   "streamName": "streamName"
}'

Remove a stream target


Delete a stream target.

curl -X DELETE \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries/{entryName}