• Stream management query examples for the Wowza Streaming Engine REST API

    Wowza Streaming Engine™ media server software has a REST Application Programming Interface (API) that can be used to configure, manage, and monitor the media server through HTTP requests. This article demonstrates ways to identify, add, and manage stream files in a Wowza Streaming Engine instance using some basic cURL examples to query the Wowza Streaming Engine REST service. For a complete breakdown and documentation of the API, see How to access documentation for the Wowza Streaming Engine REST API.

    Note: Wowza Streaming Engine 4.3.0 or later is required. You must also have working knowledge of cURL and REST-related services.

    Contents


    Get a list of stream files
    Add a stream file
    Update a stream file
    Connect a stream file
    Remove a stream file

    Get a list of stream files


    The following example shows how to get a list of existing stream files (files with a .stream extension):
    curl -X GET --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles
    The expected response:
    {"restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles","streamFiles":[{"id":"metallica","href":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/metallica"},{"id":"saosin","href":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/saosin"}]}
    Similarly, to get a specific stream file configuration, you can use the following result:
    curl -X GET --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/metallica
    An example result:
    {"restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/metallica","version":"1430317484000","uri":"rtmp://[wowza-server]:1935/[path-to-resource]"}

    Add a stream file


    To add a stream file, ]you can use the following request:
    curl -X POST --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/axis -d'
    {
       "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles",
       "streamFiles": [
          {
             "id": "connectAppName= testlive&appInstance=_definst_&mediaCasterType=rtp",
             "href": "http://localhohst:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/connectAppName=testlive&appInstance=_definst_&mediaCasterType=rtp"
          }
       ]
    }'

    Update a stream file


    After you've initiated the stream file using the add stream file request above, you can use the following request to define its parameters:
    curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/axis/adv -d'
    {
    "restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/axis/adv",
    "version": "1430601267443",
    "advancedSettings": [
    {
    "enabled": true,
    "canRemove": true,
    "name": "uri",
    "value": "rtsp://user:pass@[ip-camera]:554/axis-media/media.amp?videocodec=h264&streamprofile=400",
    "defaultValue": null,
    "type": "String",
    "sectionName": "Common",
    "section": null,
    "documented": true
    },
    {
    "enabled": true,
    "canRemove": true,
    "name": "streamTimeout",
    "value": "0",
    "defaultValue": "12000",
    "type": "Integer",
    "sectionName": "Common",
    "section": null,
    "documented": true
    },
    {
    "enabled": true,
    "canRemove": true,
    "name": "reconnectWaitTime",
    "value": "0",
    "defaultValue": "3000",
    "type": "Integer",
    "sectionName": "Common",
    "section": null,
    "documented": true
    }
    ]
    }'

    Connect a stream file


    Lastly, you'll likely want to initiate the stream file connection. You can do so by making a request for action to the stream file VHost path, as follows:
    curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/metallica/actions/connect?connectAppName=testlive&appInstance=_definst_&mediaCasterType=rtp"

    Remove a stream file


    When you're done with the stream file, you can delete it with the following request:
    curl -X DELETE --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/axis

    Originally Published: 06-16-2015.
    Updated: For Wowza Streaming Engine 4.3.0 on 10-06-2015.

    If you're having problems or want to discuss this article, post in our forum.