Search videos using the Office 365 Video REST API

Office 365 is an awesome solution to share videos in a dedicated portal, organized in different channels. Channels are used (for example) to split videos by themes or categories.

But if you create a lot of channels in your organization or if you have a lot of videos in each channel, it may be pretty difficult to find relevant videos.

If you want to create an application on top of Office 365 Video, it’s interesting to know that the REST API exposes capabilities to search videos, globally at the service level, or at the channel level.

Build and submit search queries

When you want to use the Office 365 Video REST API, you have to submit requests to the endpoint which is only accessible through the portal URL as you can see below.

https://tenant.sharepoint.com/portals/hub/_api/VideoService

As we previously said, this endpoint exposes search capabilities at two different levels :

  • Video Service (across all channels)
  • Channel

Depending on which level you want to search videos, you have to build requests by appending path components as you can see below :

Across all channels

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Search/Query

On a specific channel

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Search/Query

Add parameters to the querystring to specify search criterias

To retrieve only information that you want, you have to add some parameters to the querystring. Three possibilites are offered to you :

  • querytext
  • startItemIndex
  • itemLimit

As you can imagine, the most important parameter is querytext which allows you to make fulltext searches. startItemIndex and itemLimit are used to perform paging operations.

For example if you want to search the first 10 videos which contains the ‘Awesome’ word, across all channels, your request should look something like that :

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Search/Query?querytext='Awesome'&itemLimit=10

In the same manner, if you want to retrieve the same videos on a specific channel, your query should look something like that :

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Search/Query?querytext='Awesome'&itemLimit=10

By querying those URLs, you will retrieve a list of videos. Each video is described by the following structure :

<entry>
<id>https://tenant.sharepoint.com/portals/hub/_api/VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')</id>
<category term="SP.Publishing.VideoItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" type="application/atom+xml;type=entry" title="Author" href="VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')/Author" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Owner" type="application/atom+xml;type=entry" title="Owner" href="VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')/Owner" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PeopleInMedia" type="application/atom+xml;type=feed" title="PeopleInMedia" href="VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Videos(guid'01234567-abcd-cded-1234-1234567890ab')/PeopleInMedia" />
<title />
<updated>2015-01-01T01:00:00Z</updated>
<author>
  <name />
</author>
<content type="application/xml">
  <m:properties>
    <d:ChannelID m:type="Edm.Guid">01234567-abcd-cded-1234-1234567890ab</d:ChannelID>
    <d:CreatedDate m:type="Edm.DateTime">2015-01-01T01:00:00Z</d:CreatedDate>
    <d:Description />
    <d:DisplayFormUrl>https://tenant.sharepoint.com/portals/community/pVid/Forms/DispForm.aspx?ID=1</d:DisplayFormUrl>
    <d:FileName>AwesomeVideo.mp4</d:FileName>
    <d:OwnerName>Stephane Cordonnier</d:OwnerName>
    <d:ServerRelativeUrl>/portals/community/pVid/AwesomeVideo.mp4</d:ServerRelativeUrl>
    <d:ThumbnailUrl>https://tenant.sharepoint.com/portals/community/pVid/AwesomeVideo.mp4.PNG?VideoPreview=1</d:ThumbnailUrl>
    <d:Title>My Awesome Video</d:Title>
    <d:ID m:type="Edm.Guid">01234567-abcd-cded-1234-1234567890ab</d:ID>
    <d:Url>https://tenant.sharepoint.com/portals/community/pVid/AwesomeVideo.mp4</d:Url>
    <d:VideoDurationInSeconds m:type="Edm.Int32">120</d:VideoDurationInSeconds>
    <d:VideoProcessingStatus m:type="Edm.Int32">2</d:VideoProcessingStatus>
    <d:ViewCount m:type="Edm.Int32">10</d:ViewCount>
    <d:YammerObjectUrl>https://tenant.sharepoint.com/portals/hub/_layouts/15/videoplayer.aspx?v=https%3A%2F%2Ftenant%2Esharepoint%2Ecom%2Fportals%2Fcommunity%2FpVid%2FAwesomeVideo%2Emp4</d:YammerObjectUrl>
  </m:properties>
</content>
</entry>

Retrieve popular videos across all channels, or for a specific channel

It’s great to be able to search for videos but if you use the web version of Office 365 Video, you probably saw that the homepage displays popular videos. I guess you wonder how to retrieve those videos ?

The search endpoint mentioned above has special syntax to get those data. If you want to retrieve popular videos globally or for a specific channel, you have to submit requests using the following URLs:

https://tenant.sharepoint.com/portals/hub/_api/VideoService/Search/Popular
https://tenant.sharepoint.com/portals/hub/_api/VideoService/Channels(guid'01234567-abcd-cded-1234-1234567890ab')/Search/Popular

As for simple searches, you can use startItemIndex and itemLimit to perform paging through popular videos.

If you want more information on the Office 365 Video REST API, you can read the official documentation on the MSDN website : https://msdn.microsoft.com/office/office365/APi/video-rest-operations.

Advertisements

4 thoughts on “Search videos using the Office 365 Video REST API

  1. Pingback: Office 365 Developer Podcast: Episode 050 on the Office 365 Groups API | nokipedia.com

  2. Pingback: Office 365 Developer Podcast: Episode 050 on the Office 365 Groups API • PC Portal

  3. Pingback: SharePoint 2013 & Office 365: Recopilatorio de enlaces interesantes (LXVIII)! - Blog de Juan Carlos González en Geeks.MS

  4. Pingback: Office 365 Developer Podcast: Episode 050 on the Office 365 Groups API | Eli Shlomo Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s