kWidget Direct JS Server API

kWidget Direct Server API enables simple object request API calls. This should not be confused with the JavaScript client library, which offers object mappings and works with the code generated in the test me console.

The kWidget Direct Server API is included by default every time you include the player library.

<script src="http//cdnapi.kaltura.com/p/{partnerId}/sp/{partnerId}00/embedIframeJs/uiconf_id/{uiconf_id}/partner_id/{partnerId}"></script>
<script>
	new kWidget.api( {
		'wid' : {partnerId},
	}).doRequest( requestObject, function( result ){ ... });
</script>

Custom API query

Partner id:
Multi-Request:

Get entries from playlist id

Retrieves all the entries for a given playlist id via playlist execute along with custom entry metadata for all the returned playlist items in a customMetadata field on the processed result data
<script>
$('#plbutton').click(function(){ var multiRequest = [{ 'service':'playlist', 'action': 'execute', 'id': '1_ft5fcih2' }]; for(var i=0;i<25;i++){ multiRequest.push({ 'service' : 'metadata_metadata', 'action' : 'list', 'version' : '-1', // metaDataFilter 'filter:metadataProfileId': 3282, 'filter:metadataObjectTypeEqual' :1, /* KalturaMetadataObjectType::ENTRY */ 'filter:orderBy' : '+createdAt', 'filter:objectIdEqual' : '{1:result:' + i + ':id}', 'pager:pageSize' : 1 }); } $('#playlist_result').show().text('loading..'); new kWidget.api( { 'wid' : '_243342', }).doRequest( multiRequest, function( data ){ $('#plclose').show(); // normalize the XML custom data into a customMetadata field in each entry results: var playlist = data.splice(0,1); var result = {}; $.each(playlist[0], function(inx, entryItem){ result[entryItem.id] = entryItem; }); $.each( data, function( inx, resultItem ){ if( resultItem && resultItem.objects && resultItem.objects[0] ){ var xml = $.parseXML( resultItem.objects[0].xml ); var $xml = $( xml ).find('metadata').children(); var jsonObj = {}; $.each( $xml, function(inx, node){ jsonObj[ node.nodeName ] = node.textContent; }); result[ resultItem.objects[0]['objectId'] ]['customMetadata'] = jsonObj; } }); $('#playlist_result').html( syntaxHighlight( result ) ); }) }); </script>

Get entry contextData and custom metadata ( multiRequest )

Retrieves all the sources for a given entry id via baseEntry getContextData
and via multi-request list entry custom metaData

Also see kWidget.getSources.html for simple library that builds usable playMainfest source urls
<script>
$('#entriesbutton').click(function(){
new kWidget.api( {
'wid' : '_243342',
}).doRequest([
{
'contextDataParams' : {
'referrer' : document.URL,
'objectType' : 'KalturaEntryContextDataParams',
'flavorTags': 'all'
},
'service' : 'baseentry',
'entryId' : '0_uka1msg4',
'action' : 'getContextData'
},
{
'service' : 'metadata_metadata',
'action' : 'list',
'version' : '-1',
// metaDataFilter
'filter:metadataObjectTypeEqual' :1, /* KalturaMetadataObjectType::ENTRY */
'filter:orderBy' : '+createdAt',
'filter:objectIdEqual' : '0_uka1msg4',
'pager:pageSize' : 1
}
], function(data ){
$('#entries_result').html(
syntaxHighlight( data )
);
})
});
</script>