NICE re/streamer pro

Guides

NICE API for your own players

A small JSON API for your own player or set-top box app: a subscriber logs in and gets the channels, the stream addresses and the programme guide.

1Log in

GET /api/json/login?login=user&pass=password
{
  "sid": "50f91f0739c84b58ecb6a5c7d2",
  "sid_name": "MW_SSID",
  "account": { "login": "alex", "packet_name": "Nice", "packet_id": "1", "packet_expire": "1521676800" },
  "services": 0, "settings": 0, "geo": 0, "messages": 0,
  "servertime": 1517586814
}

Keep sid. The answer also sets it as the cookie MW_SSID; if your client does not keep cookies, add MW_SSID=<sid> to every request below.

Errors

{"error":{"message":"Access denied","code":3}} – wrong user or password; {"error":{"message":"Login incorrect","code":4}} – the session is missing or expired: log in again.

2Functions

RequestReturns
/api/json/channel_listgroups: the categories with their channels (id, name, is_video)
/api/json/categories_listcategories: id, name
/api/json/icons_listicons: ch_id and the logo address (source, empty = none)
/api/json/get_url?cid=1url – the MPEG-TS address of channel 1 (encoded, see below)
/api/json/get_urlh?cid=1url – the HLS address of channel 1 (encoded)
/api/json/epg_next?cid=1epg: the current and the next programme
/api/json/epg?cid=1epg: the whole day

An example – channel_list:

{
  "groups": [
    { "id": "1", "name": "SPORT", "color": "Silver",
      "channels": [ { "id": 1, "name": "1 tv", "is_video": 1 }, { "id": 2, "name": "2 tv", "is_video": 1 } ] }
  ],
  "servertime": 1517589200
}

…and epg_next:

{
  "epg": [
    { "ut_start": "1517584200", "progname": "News", "t_start": "15:10" },
    { "ut_start": "1517589300", "progname": "Football", "t_start": "16:35" }
  ],
  "messages": 0, "servertime": 1517586897
}

3Decoding the stream address

get_url and get_urlh return the address encoded as hex: each byte is shifted by 1…5 in turn. In JavaScript:

function niceUrl(hex) {
  var out = '', k = 0;
  for (var i = 0; i < hex.length; i += 2) {
    if (k > 4) k = 0;
    k++;
    out += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - k);
  }
  return out;   // e.g. http://host:3000/…
}

The address leads to the server that should serve the subscriber – with balancers it can be a slave.