You can use the Wowza Streaming Engine™ REST API to create and manage applications in Wowza Streaming Engine media server software. This article shows how to use cURL to query the REST API to create and manage a live streaming application.
Notes:
- Wowza Streaming Engine 4.3.0 or later is required.
- PHP examples for the tasks in this article are available in the tests folder of the PHP REST Library for Wowza Streaming Engine on GitHub.
- Reference documentation for the Wowza Streaming Engine REST API is available by using OpenAPI (Swagger), which you can download and install locally. See Access reference documentation for the Wowza Streaming Engine REST API.
Create an application
Create an application for live streaming with Wowza Streaming Engine default settings.
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/{appName} \ -d' { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}_/applications/{appName}", "name": "testlive", "appType": "Live", "clientStreamReadAccess": "*", "clientStreamWriteAccess": "*", "description": "A basic live application", "streamConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/streamconfiguration", "streamType": "live" } }'
This example creates an application named testlive.
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 \ -d' { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive", "name": "testlive", "appType": "Live", "clientStreamReadAccess": "*", "clientStreamWriteAccess": "*", "description": "A basic live application", "streamConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamconfiguration", "streamType": "live" } }'
The command should return a response that looks something like this:
{ "success": true, "message": "Application (testlive) created successfully." }
You could also create the application testlive with password authentication by adding securityConfig and ModuleCoreSecurity to the request:
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 \ -d' { "restURI": "http://localhost:8087/v2/servers/(serverName}/vhosts/{vhostName}/applications/testlive", "name": "testlive", "appType": "Live", "description": "A live application with password authentication", "streamConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamconfiguration", "streamType": "live" }, "securityConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/security", "secureTokenVersion": 0, "clientStreamWriteAccess": "*", "publishRequirePassword": true, "publishPasswordFile": "", "publishRTMPSecureURL": "", "publishIPBlackList": "", "publishIPWhiteList": "", "publishBlockDuplicateStreamNames": false, "publishValidEncoders": "", "publishAuthenticationMethod": "digest", "playMaximumConnections": 0, "playRequireSecureConnection": false, "secureTokenSharedSecret": "", "secureTokenUseTEAForRTMP": false, "secureTokenIncludeClientIPInHash": false, "secureTokenHashAlgorithm": "", "secureTokenQueryParametersPrefix": "", "secureTokenOriginSharedSecret": "", "playIPBlackList": "", "playIPWhiteList": "", "playAuthenticationMethod": "none" }, "modules": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/modules", "moduleList": [{ "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" }] } }'
Here's how you would create the application testlive with password authentication and a live stream packetizer enabled:
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/_defaultVHost_/applications/testlive \ -d' { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive", "name": "testlive", "appType": "Live", "description": "A live application with password authentication and packetizers", "streamConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamconfiguration", "streamType": "live", "liveStreamPacketizer": [ "cupertinostreamingpacketizer" ] }, "securityConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/security", "secureTokenVersion": 0, "clientStreamWriteAccess": "*", "publishRequirePassword": true, "publishPasswordFile": "", "publishRTMPSecureURL": "", "publishIPBlackList": "", "publishIPWhiteList": "", "publishBlockDuplicateStreamNames": false, "publishValidEncoders": "", "publishAuthenticationMethod": "digest", "playMaximumConnections": 0, "playRequireSecureConnection": false, "secureTokenSharedSecret": "", "secureTokenUseTEAForRTMP": false, "secureTokenIncludeClientIPInHash": false, "secureTokenHashAlgorithm": "", "secureTokenQueryParametersPrefix": "", "secureTokenOriginSharedSecret": "", "playIPBlackList": "", "playIPWhiteList": "", "playAuthenticationMethod": "none" }, "modules": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/modules", "moduleList": [{ "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" }] } }'
Update an application's settings
Update the application:
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} \ -d'
Update the application testlive to include the MPEG-DASH packetizer:
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/testlive \ -d' { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive", "name":" testlive", "appType": "Live", "streamConfig": { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamconfiguration", "streamType": "live", "liveStreamPacketizer": [ "cupertinostreamingpacketizer", "mpegdashstreamingpacketizer" ] } }'
The command should return a response that looks something like this:
{ "success": true, "message": "Saved" }
Add custom properties to an application
Update the testlive application to include a custom module called MyCustomModule:
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/testlive/adv \ -d' { "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/adv", "version": "1430682096000", "modules": [{ "order": 0, "name": "base", "description": "Base", "class": "com.wowza.wms.module.ModuleCore" }, { "order": 0, "name": "logging", "description": "Client Logging", "class": "com.wowza.wms.module.ModuleClientLogging" }, { "order": 0, "name": "flvplayback", "description": "FLVPlayback", "class": "com.wowza.wms.module.ModuleFLVPlayback" }, { "order": 0, "name": "ModuleDRMVerimatrix", "description": "ModuleDRMVerimatrix", "class": "com.wowza.wms.drm.module.verimatrix.ModuleDRMVerimatrix" }, { "order": 0, "name": "ModuleDRMBuyDRM", "description": "ModuleDRMBuyDRM", "class": "com.wowza.wms.drm.module.buydrm.ModuleDRMBuyDRM" }, { "order": 0, "name": "ModulePushPublish", "description": "Module Push Publish", "class": "com.wowza.wms.pushpublish.module.ModulePushPublish" }, { "order": 0, "name": "MyCustomModule", "description": "Module Custom Module", "class": "com.my.custom.path.MyCustomModule" }], "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 }, { "enabled": false, "canRemove": true, "name": "cupertinoChunkDurationTarget", "value": "0", "defaultValue": "10000", "type": "Integer", "sectionName": "cupertinostreamingpacketizer", "section": "/Root/Application/LiveStreamPacketizer", "documented": true }, { "enabled": true, "canRemove": false, "name": "myCustomPropertyName", "value": "myValue", "defaultValue": null, "type": "String", "sectionName": "Application", "section": "/Root/Application", "documented": false }] }'
The result is that your application's configuration includes the following custom modules and properties:
<Modules> <Module> <Name>base</Name> <Description>Base</Description> <Class>com.wowza.wms.module.ModuleCore</Class> </Module> <Module> <Name>logging</Name> <Description>Client Logging</Description> <Class>com.wowza.wms.module.ModuleClientLogging</Class> </Module> <Module> <Name>flvplayback</Name> <Description>FLVPlayback</Description> <Class>com.wowza.wms.module.ModuleFLVPlayback</Class> </Module> <Module> <Name>ModuleDRMVerimatrix</Name> <Description>ModuleDRMVerimatrix</Description> <Class>com.wowza.wms.drm.module.verimatrix.ModuleDRMVerimatrix</Class> </Module> <Module> <Name>ModuleDRMBuyDRM</Name> <Description>ModuleDRMBuyDRM</Description> <Class>com.wowza.wms.drm.module.buydrm.ModuleDRMBuyDRM</Class> </Module> <Module> <Name>ModulePushPublish</Name> <Description>Module Push Publish</Description> <Class>com.wowza.wms.pushpublish.module.ModulePushPublish</Class> </Module> <Module> <Name>MyCustomModule</Name> <Description>Module Custom Module</Description> <Class>com.my.custom.path.MyCustomModule</Class> </Module> </Modules> <!-- Properties defined here will be added to the IApplication.getProperties() and IApplicationInstance.getProperties() collections --> <Properties> <Property> <Name>myCustomPropertyName</Name> <Value>myValue</Value> <Type>String</Type> </Property> </Properties>
Restart an application
Restart an application:
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 applications
Get a list of all applications on an instance of Wowza Streaming Engine:
curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications
The command should return a response that looks something like this:
{ "restURI": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications", "applications": [{ "id": "live", "href":"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/live", "appType": "Live", "dvrEnabled": false, "drmEnabled": false, "transcoderEnabled": false }, { "id": "vod", "href": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/vod", "appType": "VOD", "dvrEnabled": false, "drmEnabled": false, "transcoderEnabled": false }] }