The fact Kaltura is open sourced provides users of the Kaltura platform with many advantages. Amongst which, the ability to shape and influence the platform and its roadmap by contributing code to the project.
Very often, when building a new integration or a publishing workflow, it’s a bit too much to dive into the core platform code. With Kaltura you don’t have to!
Kaltura is a RESTful API and Microservices driven platform.
This means that all features, user facing or internal, are based on the same unified API broken down by services that are atomic and independent.
From upload and transcoding to playback and analytics, all platform components are controlled via the same unified API. Even the platform internals such as managing backend nodes, account configurations, etc.
A RESTful API follows these basic concepts:
A lot of projects offer a RESTful API. But what I believe makes the Kaltura API special is –
It’s API from the inside out!
The platform’s own components also use the same APIs to get their job done. This means core developers build and test using the same APIs that App developers use. Which in turn tests and improves the APIs daily.
Always up-to-date SDKs
Kaltura’s API features a unique automatic generation of SDK. With every release Kaltura generates new client libraries. Which are available for most popular programming languages, including: PHP, Ruby, Python and JavaScript.
See the Kaltura.com client libraries page for complete list and downloads.
It’s Robust, Allowing Complete Control
The API is capable of controlling pretty much any operation in the platform’s core components. From ingesting content through management and transcoding, to playback, delivery, distribution and analytics.
To further explain point A, let’s dive into the Kaltura architecture:
The API and Client Libraries are used across the platform’s components, both in external applications such as Kaltura MediaSpace and various modules for 3rd party systems such as Drupal or WordPress, as well as internally, within the core Kaltura components such as transcoding, batch servers or the platform’s Admin Console.
For example, the batch daemon, responsible for performing roles such as: media import, media info extraction, transcoding and server notifications, triggers these APIs the same way any other party, like, your own application, would: using the Kaltura API Client libraries.
Here is a short example of how the APIs (in this particular case, using the PHP client lib) can be used to upload a new video entry to the system:
// require the Kaltura PHP5 client libs: require_once('/usr/local/lib/php5/KalturaClient.php'); // generate a KS and return a client to work with: function generate_ks($service_url,$partnerId,$secret,$type=KalturaSessionType::ADMIN,$userId=null,$expiry = null,$privileges = null) { $config = new KalturaConfiguration($partnerId); $config->serviceUrl = $service_url; $client = new KalturaClient($config); $ks = $client->session->start($secret, $userId, $type, $partnerId, $expiry, $privileges); $client->setKs($ks); return ($client); } function upload($client,$fileData,$title,$conv_profile=null,$type=null) { try{ $uploadToken = new KalturaUploadToken(); $result = $client->uploadToken->add($uploadToken); $tok=$result->id; $resume = null; $finalChunk = null; $resumeAt = null; $result = $client->uploadToken->upload($tok, $fileData, $resume, $finalChunk, $resumeAt); $entry = new KalturaBaseEntry(); $entry->name = $title; if (isset($conv_profile)){ $entry->conversionProfileId = $conv_profile; } if (!isset($type)){ $type = KalturaEntryType::AUTOMATIC; } $result = $client->baseEntry->addfromuploadedfile($entry, $tok, $type); $id=$result->id; return($id); }catch(exception $e){ throw $e; } } // call generate_ks() to instantiate a Kaltura client and start a session $client=generate_ks($service_url,$partnerId,$secret,$type=KalturaSessionType::USER,$userId=null); // pass $client object and $video_file to upload() function to upload and create the new entry $id=upload($client,$video_file,"Entry's name",null,null);
Having an API driven architecture enables complete control and freedom with how you want your application workflows and UI to behave. From creating different publishing workflows to exposing sets of functionalities.
In addition, the API inside-out approach opens up many opportunities for adapting, controlling and extending beyond the simple UI workflows and apps, important examples for that are platform automation and monitoring tools.
Playing with the API:
As mentioned, Kaltura provides client libs generated for various programming languages. In addition, API calls can be made using a testing tool dubbed the Kaltura TestMe console.
The first thing you would want to do is create a Kaltura Session – KS:
If you look at the screenshot above, you will see that, in the right frame, we have the returned XML which includes:
At the bottom of the page, you can see the code our selections in the input form generated.
Notice that while the default displayed code is in PHP, you can click on one of the other languages to see the code generated for them.
As a second example for using the Test Me Console, we will list the entries our partner owns, by using the baseEntry service and calling its listAction() action.
As you can see, the generated code reads:
require_once('lib/KalturaClient.php'); $config = new KalturaConfiguration($partnerId); $config->serviceUrl = 'https://ce-lb.dev.kaltura.com:8001/'; $client = new KalturaClient($config); $filter = new KalturaBaseEntryFilter(); $filter->statusEqual = KalturaEntryStatus::READY; $result = $client->baseEntry->listAction($filter, $pager);
If you run this code and add:
var_dump($result);
You will get a result very similar to the XML outputted in the right frame of the page in the screenshot above.
The Test Me Console is a useful method for exploring the Kaltura API. Simply browse through available services and see what actions can be made.
Then, you can copy the code snippet and shape it into something useful within your scripts.
Hopefully this article will help you get started with the Kaltura APIs.
Browse the Kaltura API Documentation Set to learn more and explore more Kaltura APIs.
For questions, leave a comment below, or start a thread in the forums.
Download, install and take part in the Community.
Happy coding 🙂
The Video Experience Hackathon endded. You can explore the winning projects at: https://videoxhackathon.devpost.com/submissions.