[Advanced users] Process federated search JSON data


About

If you're a developer building a video widget for your organization's intranet or another portal, this article explains how to request results from a federated search producer and use the JSON data it returns.

Your site administrator sets up the producer in the Federatedsearchinteractive module and gives you what you need to access it.

Before you start

Get the following from your site administrator:

  • The producer's slug
  • The app token ID and value
  • Your partner ID
  • The sample HTML code from the playground
  • Optional. A sample JSON response
  • Which settings you can change in the URL, if any
  • If the producer includes custom metadata, the list of custom fields

Request results from a producer

  1. Create a Kaltura Session (KS) with the app token. For instructions and sample code, see App Token Authentication. If the producer searches channels, or returns results for each user, include the user's ID when you create the KS. Usually, your back end, such as a CMS template, creates a new KS each time the page loads.
  2. Request the producer's URL, using this format: https://{your_site_url}/federatedsearchinteractive/{slug}/ks/{ks}/term/{search_term}. The search term is optional.
  3. Loop over the results in the JSON response, and show each entry in your widget.

The sample HTML code from the playground shows all three steps: building the URL (1), requesting it with jQuery's getJSON (2), and showing each entry (3).

Change settings in the URL

If your site administrator allows it, you can change some of the producer's settings by adding them to the URL:

  • /sortBy/{value} - The order of the results: 0 = Most recent, 1 = Most viewed, 2 = Most liked, 3 = Alphabetical. For example, /sortBy/2.
  • /limitToCategoryOrChannel/{category_id} - Results from one category or channel only. For example, /limitToCategoryOrChannel/1542261.
  • /limitToItemsNum/{value} - The number of results. The maximum is 50.

Link to more results

A producer returns up to 50 results. To let users see more, add a link such as Watch more videos to your widget, which opens the video site.

If your widget has a search box, add search/searchkeyword/ and the search term to the end of the link, so users can continue their search on the site.

JSON fields

Each entry in the response includes the following fields:

Field Description
entryType 1 = media hosted in Kaltura, externalMedia.externalMedia = YouTube video.
mediaType 1 = video, 2 = image, 5 = audio.
id The entry's unique ID. Use it to play the entry in a Kaltura player.
referenceId The ID of the matching item in another system, if the entry has one.
name The entry's name. Use it as the title.
description The entry's description.
tags Tags that the entry's owner added. You can use them to build tag search links to the site.
msDuration The length of the media, in milliseconds.
isSticky true if the entry is promoted, so it always appears at the top of the results.
rootEntryId If the entry is a clip of a longer video, the ID of the original video. Otherwise, the same as id.
thumbnailUrl The URL of the entry's thumbnail. Use it as is, so you always get the latest thumbnail. To set the size, add /width/{value}/height/{value}/type/3 to the URL, for example, /width/478/height/269/type/3. /type/3 crops the image from the center. For all thumbnail options, see The Kaltura Thumbnail API..
capabilities Contains quiz.quiz if the entry is a video quiz.

Optional fields

Depending on how your site administrator set up the producer, each entry can also include:

  • customData - Custom metadata fields. Ask your site administrator which fields are included.

  • views and likes - The number of views and likes.

Was this article helpful?
Thank you for your feedback!
User Icon

Thank you! Your comment has been submitted.

In this article
Related articles