How to geo-block stream targets by using the Wowza Streaming Cloud REST API

The Wowza Streaming Cloud™ service allows you to selectively allow or block access to Wowza CDN stream targets so that you can control where a stream can be viewed. Learn how to use the REST API to control the locations where your stream can be viewed.

Contents


Add a Wowza CDN stream target for Apple HLS playback Create a geo-block for the target Assign the stream target to a transcoder

Add a Wowza CDN stream target for Apple HLS playback


First, add a Wowza CDN stream target configured to play streams over Apple HLS or Apple HLS and Adobe HDS.

Stream target parameters

Parameter Data Type Description
name string A descriptive name for the stream target. Maximum 255 characters.
provider string Specify akamai_cupertino (for HLS-only playback) or akamai (for HLS and HDS playback).
type string Specify WowzaStreamTarget for a Wowza CDN destination.
use_cors Boolean (Optional) CORS, or cross-origin resource sharing, allows streams to be sent to providers such as Peer5, Viblast, and Streamroot, which implement a peer-to-peer grid delivery system. Specify true to enable CORS. The default is false. Available if the provider is akamai_cupertino.
use_secure_ingest Boolean (Optional) Specify true to deliver the HLS stream securely between the transcoder and the target. The default is false. Available if the provider is akamai_cupertino.

Example request and response

Note: In all code examples, for [key], substitute your API key or your access key as appropriate. For more information, see Locating and using API and access keys.
The following request generates a Wowza CDN stream target for Apple HLS playback:
 
curl -X POST --header "Content-Type: application/json" --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" -d '{
   "stream_target": {
     "name": "MyHLSTarget",
     "provider": "akamai_cupertino",
     "type": "WowzaStreamTarget"
   }
 }' "https://api.cloud.wowza.com/api/v1/stream_targets"
The details of the configured target are listed in the response, which should look something like this:
 
{
  "stream_target": {
    "chunk_size": "10",
    "created_at": "2016-02-23T16:04:23.170Z",
    "hls_playback_url": "https://[wowzasubdomain]-i.akamaihd.net/hls/live/[appname]/[streamname]/playlist.m3u8",
    "id": "1234abcd",
    "name": "MyHLSTarget",
    "primary_url": "http://[wowzasubdomain]-i.akamaihd.net/[appname]/[streamname]",
    "provider": "akamai_cupertino",
    "stream_name": "st1r2eam",
    "type": "WowzaStreamTarget",
    "updated_at": "2016-02-23T16:04:23.170Z",
    "use_cors": false,
    "use_secure_ingest": false
  }
}

Create a geo-block for the target


Create a geo-block for the HDS/HLS stream target.

Geo-block parameters

Parameter Data Type Description
countries array of strings The locations affected by the geo-block. Enter a comma-separated list of two-letter ISO 3166-1 country codes. For a list of codes, see ISO 3166-1 on Wikipedia.
type string Geo-blocks can permit or prohibit viewing of a stream target. The value allow permits viewing only in the locations specified by the countries parameter. The value deny prohibits viewing in the locations specified by the countries parameter. The value disabled permits viewing everywhere.
whitelist string Whitelisted addresses can be viewed even if they're within a geo-blocked location. Enter a comma-separated list of IP addresses that always allow streaming.
 
Note: You can block or whitelist a total of 30 locations and IP addresses, in any combination.

Example request and response

The following request allows only the United States and Germany as well as the IP addresses 1.2.3.4 and 9.8.7.6 to view a stream at the target 1234abcd:
 
curl -X POST --header "Content-Type: application/json" --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" -d '{
   "geoblock": {
     "countries": ["de","us"],
     "type": "allow",
     "whitelist": ["1.2.3.4","9.8.7.6"]
   }
 }' "https://api.cloud.wowza.com/api/v1/stream_targets/1234abcd/geoblock"
The details of the configured geo-block are listed in the response, which should look something like this:
 
{
  "geoblock": {
    "countries": [
      "de",
      "us"
    ],
    "created_at": "2016-02-23T16:04:22.828Z",
    "stream_target_id": "1234abcd",
    "type": "allow",
    "updated_at": "2016-02-23T16:04:22.828Z",
    "whitelist": [
      "1.2.3.4",
      "9.8.7.6"
    ]
  }
}

Related requests

View the details of a geo-block:
 
curl -X GET --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" "https://api.cloud.wowza.com/api/v1/stream_targets/[stream_target_id]/geoblock"
Update a geo-block's configuration:
 
curl -X PATCH --header "Content-Type: application/json" --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" -d '{
   "geoblock": {
     "type": "deny",
     "countries": ["de","us"]
  }
 }' "https://api.cloud.wowza.com/api/v1/stream_targets/[stream_target_id]/geoblock"
Delete a geo-block:
 
curl -X PUT --header "Content-Type: application/json" --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" -d '{
   "geoblock": {
     "type": "disabled"
  }
 }' "https://api.cloud.wowza.com/api/v1/stream_targets/[stream_target_id]/geoblock"

Assign the stream target to a transcoder


Assign the geo-blocked stream target to a transcoder's output rendition.

Add stream target parameters

Parameter Data Type Description
id string The unique alphanumeric string that identifies the output rendition that will deliver content to the stream target. You can find the ID in the details of the output's transcoder.
stream_target_id string The unique alphanumeric string that identifies the stream target. You can find the ID in the details of the target you just created.
transcoder_id string The unique alphanumeric string that identifies the transcoder.

Example request and response

The following request adds the geo-blocked stream target 1234abcd to the output rendition whose ID is 5678efgh for the transcoder 9012ijkl.
 
curl -X POST --header "Content-Type: application/json" --header "wsc-api-key: [key]" --header "wsc-access-key: [key]" -d '{
   "output_stream_target": {
     "stream_target_id": "1234abcd",
     "use_stream_target_backup_url": false
   }
 }' "https://api.cloud.wowza.com/api/v1/transcoders/9012ijkl/outputs/5678efgh/output_stream_targets/"
The details of the configured target are listed in the response, which should look something like this:
 
{
   "output_stream_target": {
    "stream_target_id": "1234abcd",
    "use_stream_target_backup_url": false
   }
}

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