REST API – get historic connection counts

You can obtain historical connection & bandwidth information via Wowza’s REST API. As a quick & dirty test, you can try the following curl example:

curl -X GET --header 'Accept:application/json; charset=utf-8' ""

Further you can add query string parameters to specify the date/time range:

curl -X GET --header 'Accept:application/json; charset=utf-8' ""

Further to use PHP to do the same thing, it might look like the following:

$url = "";
$ch = curl_init($url);                                                     
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HEADER      ,0);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
					'Accept:application/json; charset=utf-8',
					'Content-type:application/json; charset=utf-8',
					'Content-Length: '.strlen($json)));
$contents = curl_exec($ch); 

$obj =  json_decode($contents);
	if(isset($obj->entries->min) &&
			is_array($obj->entries->min) && 
		foreach($obj->entries->min as $entry){
			$dateTime = Date("m/d/Y h:i a", strtotime($entry->dateTime));
			$data = $entry->data; 
			if(is_array($data) && count($data)==10){
				$stats = new stdClass();
				// data
				$stats->bandwidth_inbound = $data[0];
				$stats->bandwidth_outbound = $data[1];
				// connections
				$stats->rtmp = $data[2];
				$stats->rtsp = $data[3];
				$stats->hds = $data[4];
				$stats->hls = $data[5];
				$stats->smooth = $data[6];
				$stats->webrtc = $data[7];
				$stats->webm = $data[8];
				$stats->dash = $data[9];
				echo "Date: ".$dateTime."\n";
				echo "\n=====\n\n";

Comments are closed.