Introduction The Kwik-Platform is brand new core of KwikFlix streaming system. API Methods list can be found in API documentation API documentation. This Tutorial describes Kwik-Platform API integration to your workflow. Examples prepared using php. Authorization For authorization using OAuth2 standard (for example: oauth2-client). You need to follow next steps to have access to API methods: Get refresh and access token using password grant authentication. See /oauth/access_token method in API documentation. The parameters should be in the array. For example: $url = 'https://api.infoview.tv/oauth/access_token'; $user_data = array( "client_id" => '<application client id>', "client_secret" => '<application client secret>', "username" => '<username>', "password" => '<user password>', "grant_type" => 'password', ); $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POSTFIELDS => $user_data )); $response = curl_exec($ch); Sample output: { "access_token": "<access_token>", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "<refresh_token>" } Make requests to API methods with header 'Authorization: Bearer <access_token>'. When access token will expires request new one using ‘refresh_token’ or ‘password’ grant: $user_data = array( "client_id" => '<application client id>', "client_secret" => '<application client secret>', "refresh_token" => '<refresh_token>', "grant_type" => 'refresh_token', ); Products Create Product Before create product need to upload files using Upload API /v1.0/upload/flow method in API documentation and Flow.js library. To see the list of uploaded files you can use GET /v1.0/upload method. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/upload'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); Sample output: { "total": 100, "per_page": 10, "current_page": 1, "last_page": 10, "next_page_url": "http://api.infoview.tv/v1.0/enduser/?page=2", "prev_page_url": null, "from": 1, "to": 10, "data": [ { "id": "1", "filename": "queen_smiled.mp4", "path": "/platform/uploads/2/queen_smiled.mp4", "created_at": "2015-09-11T15:43:10+0000", "updated_at": "2015-09-11T15:43:10+0000", }, { "...": "..." } ] } To create Product you can use POST /v1.0/product method in API documentation. The parameters should be in the json format. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/product'; $file_data = array( "title" => 'Queen smiled', "upload_id" => '1', "status" => 'public' ); $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header), CURLOPT_POSTFIELDS => json_encode($file_data) )); $response = curl_exec($ch); Sample output: { "message": "resource created successfully" } Products list You can get the list of existing products by GET /v1.0/product method in API documentation. Don't forget about access_token in the header. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/product'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); Also you can use request parameters full list which you can see in the API documentation. For example you can get second page list of 20 public products per page which contains ‘queen’ and sort it by name: $url = 'https://api.infoview.tv/v1.0/product? page=2&limit=20&search=queen&sort=name&status=public'; Sample output: { "total": 35, "per_page": 20, "current_page": 2, "last_page": 2, "next_page_url": null, "prev_page_url": "http://api.infoview.tv/v1.0/product/?page=1", "from": 21, "to": 35, "data": [ { "id": "12", "name": "pack00000000000000079", "title": "Queen smiled", "status": "public", "type": "vod", "created_at": "2015-09-15T16:51:45+0000", "updated_at": "2015-09-15T16:51:45+0000" }, { "id": "6", "name": "pack0000000000000202", "title": "Playing the Queen", "status": "public", "type": "live", "live_upstream_url": "http://example.com/mylive.m3u8", "created_at": "2015-09-15T16:51:45+0000", "updated_at": "2015-09-15T16:51:45+0000" }, { "...": "..." } ] } In the output you get the data array with products information and parameters for building pagination: total - the total number of products which corresponding request; per_page - number of products which you get in the output (default - 10); current_page - the current page (default - 1); last_page - total number of pages; from - first item on page (default - 1); to - last item on page. To get the one product info you should add the product id to the URL: $url = 'https://api.infoview.tv/v1.0/product/12'; End Users Create End User To adding new End User you can use POST /v1.0/enduser method in API documentation. The parameters should be in the json format. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/enduser'; $end_user_data = array( "email" => 'Lessie44@OReilly.com', "name" => 'Bruce Howell', ); $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header), CURLOPT_POSTFIELDS => json_encode($end_user_data) )); $response = curl_exec($ch); Sample output: { "message": "resource created successfully" } End Users list You can get the list of existing End Users by GET /v1.0/enduser method. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/enduser'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); Sample output: { "total": 10000, "per_page": 10, "current_page": 1, "last_page": 1000, "next_page_url": "http://api.infoview.tv/v1.0/enduser/?page=2", "prev_page_url": null, "from": 1, "to": 10, "data": [ { "id": "2", "name": "Bruce Howell", "email": "Lessie44@OReilly.com", "created_at": "2015-09-11T15:43:10+0000", "updated_at": "2015-09-11T15:43:10+0000", "purchases_qty": 0 }, { "id": "3", "name": "Kiana Ryan III", "email": "Rick23@Lind.biz", "created_at": "2015-09-11T15:43:10+0000", "updated_at": "2015-09-11T15:43:10+0000", "purchases_qty": 117 }, { "...": "..." } ] } To get the one End User info you should add the End User id to the URL: $url = 'https://api.infoview.tv/v1.0/enduser/2'; Purchases Create Purchase To adding new Purchase use POST /v1.0/purchase method in API documentation. The parameters should be in the json format. The expires_at should be in UTC time. To create unlimited purchase don’t set product_id parameter. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/purchase'; $purchase_data = array( "enduser_id" => '2', "product_id" => '12', "expires_at" => '2015-12-31T21:10:32+0000' ); $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_POST => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header), CURLOPT_POSTFIELDS => json_encode($purchase_data) )); $response = curl_exec($ch); Sample output: { "message": "resource created successfully" } Purchases list You can get the list of existing Purchases by GET /v1.0/purchase method. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/purchase'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); Sample output: { "total": 10000, "per_page": 10, "current_page": 1, "last_page": 1000, "next_page_url": "http://api.infoview.tv/v1.0/purchase/?page=2", "prev_page_url": null, "from": 1, "to": 10, "data": [ { "id": "332", "enduser_id": "2", "product_id": "12", "is_expired": "false", "expires_at": "2015-12-31T21:10:32+0000", "created_at": "2015-11-24T21:10:32+0000", "updated_at": "2015-11-24T21:10:32+0000", "enduser": { "id": "2", "name": "Bruce Howell" }, "product": { "id": "12", "name": "pack00000000000000079", "title": "Queen smiled", "type": "vod" }, }, { "...": "..." } ] } To get the one Purchase info you should add the Purchase id to the URL: $url = 'https://api.infoview.tv/v1.0/purchase/332'; Get purchases for certain End User You can get purchases list for certain End User by adding parameters to the URL. Also you can sort the output data by types of products. If product is null then purchase is unlimited (for all products). It’s means that such purchase allow to watch any product. To prevent pagination set limit to 999. For example: $auth_header = 'Authorization: Bearer <access_token>'; $url = 'https://api.infoview.tv/v1.0/purchase?enduser_id=2&limit=999'; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); /* $result will contain all purchases for certain user */ $result = json_decode($response, TRUE); /* Sort output array by types */ $live = []; $vod = []; $unlim = []; foreach ($result['data'] as $item) { if ($item['product'] === null) { array_push($unlim, $item); } else if ($item['product']['type'] === 'vod') { array_push($vod, $item); } else if ($item['product']['type'] === 'live') { array_push($live, $item); } } Product play URL To get the product play URL use method GET /v1.0/product/{id}/play. For example: $auth_header = 'Authorization: Bearer <access_token>'; $product_id = '12'; $enduser_id = '2'; $url = 'https://api.infoview.tv/v1.0/product/' . $product_id . '/play?enduser_id=' . $enduser_id; $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPHEADER => array($auth_header) )); $response = curl_exec($ch); Sample output: { "url": "http://players.infoview.tv/pack00000000000000079" } If you get message "Record not found" check the following: the Product with requested id exist; the Product have public status; the End User with requested id exist; the Purchase for this End User with this Product or Unlim exist and not expired. This works with VOD and Live Product types.
Category: Kwiktec API
KwikTec Digital Rights Management
Licence types
SVOD = Subscription VOD
AVOD = Advertising VOD
TVOD = Transactional VOD
Live = Live stream
Catchup = recording of scheduled live
Introduction
This document describes KwikTecs approach and DRM protection workflow.
Workflow
Step 1: Navigate
The user navigates the Web portal and decides to buy/rent some content (this is just a sample scenario TVOD). User hits «Buy» button.
Step 2: Transaction processing
The Web portal processes the transaction and does whatever it needs to do.
Step 3: DRM Purchase
The Web portal makes /purchase API to the Kwiktec server to create a license rule for the current purchase which will allow the current user to view the acquired content.
Step 4: Watch url
The Web portal sends its Web response to the user’s browser.
Usually the user is redirected now to a Web page that contains a video player and the stream URL for the video.
Step 5: Detect encryption
Kwiktec Player on the client browser connects the delivery server and starts downloading the protected content. It discovers that the content is encrypted and extracts the license acquisition URL from the content header.
Step 6: Retrieve license
KwikFlix Player connects to KwikSecureDRM server and receives the just created license (/key/{productId}). This license contains the decryption key as well as the usage rights.
Step 7: Start watching
Kwiktec Player continues downloading and starts decryption and playback of the video.
Authorization API (Version 1.0)
POST /api/v1.0/purchase
request parameters:
product_id- product identifier.
uid (optional) – client identifier. Create new one if not specified.
type – one licence types: tvod (expires in 48 hours), svod (never expires)
response parameters:
token
uid
created
expires
GET /api/v1.0/check?token={token}&product_id={pid}
request parameters:
product_id | name – product identifier. “name” is parameter alias for Kwiktec
token – token that was generated on purchase.
GET /api/v1.0/key/create
request parameters:
product_id | name – product identifier. “name” is parameter alias for Kwiktec
response body: hex key data
response headers:
X-Key-Url – url to get binary version of this key. See previous method
X-Created – is key just created
GET /api/v1.0/key/{name}?token={token}
request parameters:
name – key unique name.
token (optional) – If specified do additional token validation (is token exists and product_id of token match product_id of key).
response body: binary key data
API methods protection
There are next methods should be protected from everyone’s access:
Purchase. Purchase method should public accessible (for example for middleware), but only for authorized users (OAuth / password / host based)
key/create. Create key method should be accessible only for Kwiktec machines (host based protection). Because only Kwiktec should request new keys creation.
Kwiktec online radio station API
Introduction
Kwiktec online radion station features a public HTTP API that allows you to retrieve JSON-encoded information about a station and what’s currently playing.
To invoke an API, make an HTTP request to:
http://my-Kwiktec-station/api/live-info
Live Info API
live-info
Note: The live-info-v2 API below is slightly easier to use. We recommend using that API instead.
The current (as of 2.5.1) live-info API provides the user with a JSON encoded object containing track, show, and station data in the following format:
{
“env”: “”,
“schedulerTime”: “”,
“previous”: {
“name”: “”,
“starts”: “”,
“ends”: “”
},
“current”: null,
“next”: {
},
“currentShow”: [
{
“start_timestamp”: “”,
“end_timestamp”: “”,
“name”: “”,
“description”: “”,
“id”: 0,
“instance_id”: 0,
“instance_description”: “”,
“record”: 0,
“url”: “”,
“image_path”: “”,
“starts”: “”,
“ends”: “”
}
],
“nextShow”: [
{
}
],
“timezone”: “”,
“timezoneOffset”: “”,
“Kwiktec_API_VERSION”: “”
}
This format supports the following parameters:
type
api/live-info?type=endofday – provides information on shows until the end of the current day, in the station timezone
api/live-info?type=interval – default; provides information for a 48 hour interval from the current time
limit
api/live-info?limit=n – limits the number of shows returned by the request. The defaults is 5
callback
api/live-info?callback=myFunction – passes a user-defined function as JSONP padding to call on the JSON response
live-info-v2
Changes to live-info (currently in-progress as live-info-v2) will change this format to the following:
{
“station”: {
“env”: “”,
“schedulerTime”: “”,
“timezone”: “”,
“Kwiktec_API_VERSION”: “”
},
“tracks”: {
“previous”: null,
“current”: {
“name”: “”,
“starts”: “”,
“ends”: “”
}
“next”: null
},
“shows”: {
“previous”: [],
“current”: {
“name”: “”,
“description”: “”,
“id”: 0,
“instance_id”: 0,
“instance_description”: “”,
“record”: ,
“url”: “”,
“image_path”: “”,
“starts”: “”,
“ends”: “”
},
“next”: [
]
}
}
This new format will support the following parameters:
timezone
api/live-info-v2?timezone=est – specifies the timezone that the returned information should be converted to. The default is the station timezone
Timezones can be provided in abbreviated or full form (Africa/Johannesburg), and support all PHP-supported timezones.
The timezone parameter is case-insensitive.
days
api/live-info-v2?days=n – specifies the number of days of shows to return. The default is 2 days.
Note that days are defined until the end of day in the specified timezone, so days=1 will return show information for shows starting before the end of the current day, days=2 will return show information for shows starting before the end of the following day, and so on.
If this parameter is omitted, the API returns the next 2 days of shows by default.
shows
api/live-info-v2?shows=n – specifies the number of shows in the future to return. The default is 5.
Shows returned are prioritized in the following way: current show first, followed by upcoming (“next”) shows within the interval defined by the days parameter, followed by shows (“previous”) within the past 48 hours.
If this parameter is omitted, the API returns the next 5 shows by default.
callback
api/live-info-v2?callback – the callback parameter will remain unchanged from version 2.5.1
Week Info (Schedule) API
week-info
The week-info API call provides the user with a JSON encoded object containing track, show, and station data in the following format:
{
“monday”: [
{
“start_timestamp”: “”,
“end_timestamp”: “”,
“name”: “”,
“description”: “”,
“id”: 0,
“instance_id”: 0,
“instance_description”: “”,
“record”: 0,
“url”: “”,
“image_path”: “”,
“starts”: “”,
“ends”: “”
}
],
“tuesday”: [
],
“wednesday”: [
],
“thursday”: [
],
“friday”: [
],
“saturday”: [
],
“sunday”: [
],
“nextmonday”: [
],
“nexttuesday”: [
],
“nextwednesday”: [
],
“nextthursday”: [
],
“nextfriday”: [
],
“nextsaturday”: [
],
“nextsunday”: [
],
“Kwiktec_API_VERSION”: “”
}
Although currently unimplemented (as of 2.5.1), this format will support the following parameters:
timezone
api/week-info?timezone=est – specifies the timezone that the returned information should be converted to. The default is the station timezone
Timezones can be provided in abbreviated or full form (South Africa/Johannesburg), and support all PHP-supported timezones.
The timezone parameter is case-insensitive.
callback
api/week-info?callback=myFunction – passes a user-defined function as JSONP padding to call on the JSON response
Kwiktec Pro APIs
As of January 5th, 2016, the following APIs are currently only available on Kwiktec Pro. We hope to bring these to a future open source Kwiktec release.
Station Metadata API
station-metadata
The station-metadata API call provides static information about the station in the following format:
{
“name”: “”,
“logo”: “”,
“description”: “”,
“timezone”: “”,
“locale”: “”,
“Kwiktec_API_VERSION”: “”
}
Station Logo API
station-logo
The station-metadata API is a read-only URL that returns the radio station’s logo.
eg. http://your_domain/api/station-logo
Shows API
shows
The shows API is a read-only URL that returns the list of shows on the station.
eg. http://your_domain/api/shows
[
{
“name”: “The DJ DJ Show”,
“id”: 1,
“url”: “http:\/\/www.64studio.com\/”,
“genre”: “Funk”,
“description”: “Give up the funk, baby!”,
“color”: “000000”,
“background_color”: “75bc0c”,
“linked”: false
},
{
“name”: “DJ SmiLing”,
“id”: 2,
“url”: “”,
“genre”: “”,
“description”: “Beata rocks the house!”,
“color”: “000000”,
“background_color”: “00f82b”,
“linked”: false
},
….
]
Show Logo API
show-logo
Retrieves the logo for the show with the given ID. Redirects to the station logo if the show has no logo.
Parameters:
id (int) – Show ID
Item History Feed API
item-history-feed
Documentation coming soon…
Item History Feed API
item-history-feed
Documentation coming soon…
Show Tracks API
show-tracks
Documentation coming soon…
Show Schedules API
show-schedules
Documentation coming soon…