API

This sections demonstrates the use of the API interface to communicate directly with supported devices.

Authentication

The use of the API requires API Authentication Credentials. ('KEY' and 'HASHKEY').
API Authentication Credentials can be generated for developers by contacting support (developer@zerhex.com).
Authentication is required for each API request.

Authenticating With API Credentials

API requests will be authenticated based on the request parameters key and hashkey as provisioned.
A sample API request thats returns a devices status information is listed below.

<?php 


$key = 'D4j1dKYE3g40VROOPCGyJ9zRwP0ADJIv'; 
$hashkey = 'F1CKGXRIpylMfsrig3mww'; 
$api_request = 'GET_DEVICE_STATE'; $device_serial = '0B0B0B0B0B0B'; $postfields = array( 'key' => $key, 'hash' => $hashkey, 'Request' => $api_request, 'device_serial_id' => $device_serial );
?>


Sample Reponse

Listed below is a sample response array returned using JSON.

<?php 

Array
(
    [success] => 1
    [ret_code] => SUCCESS
    [msg] => DEVICE ONLINE. 
    [response] => Array
        (
            [online] => 1        <!--# Devices online status --> 
            [ip] => 192.168.1.108   <!--# LAN ip address of device -->    
            [sn] => 0B0B0B0B0B0B   <!--# Device's serial number -->
            [ver] => 1.4.5  <!--# OS Version -->
            [last_command] => STATUS_STOP  <!--# Last Broadcast Command -->
            [server_profile] => demot  <!--# Current Active Broadcast Profile -->
            [uptime] => 67365  <!--# Time in seconds synce device rebooted. -->
            [recording] => 1  <!--# Indicate if device is currently recording or not -->
            [file_system] => 1  <!--# FileSystem on SD card check -->
            [sdcard_in] => 1  <!--# Sdcard detected -->
            [screen] => Array
                (
                    [line1] => TX: IDLE.   <!--# Text on screen 1 of device -->
                    [line2] => RX: IDLE.   <!--# Text on screen 2 of device -->
                )

            [playtitle] => Motivational  <!--# Playback Title -->
            [playlink] => http://s30.streamerportal.com:8533/stream  <!--# Playback link -->
            [play_servertype] => ICECAST  <!--# Playback link type -->
            [playchan] => 2628  <!--# Playback Channel number -->
        )

)


?>


In this example the return value indicates that the device is online and playing back an icecast stream Titled "Motivational".