YouTube API

The YouTube Application Programming Interface, or the YouTube API, allows developers to access video statistics and YouTube channels' data via two types of calls, REST and XML-RPC. Google describe the YouTube API Resources as 'APIs and Tools that let you bring the YouTube experience to your webpage, application or device.' [1] This is one of the Google Developers

Players and Player APIs

The Players and Player APIs section identifies ways you can let your users watch YouTube videos in your application and control the playback experience. With an embedded YouTube player, you can integrate the YouTube video playback experience directly in your web page or application. You can use player parameters to customize the player's appearance, and you can also use Player APIs to control the player directly from your web page or app.[2]

Player parameters

All of the following parameters are optional. Note that these parameters are only officially supported by the embedded player, but a subset of them may also work with other players such as the playlist player.Here is the list of parameters.[3]

autohide (supported players: AS3, HTML5)

Values: 2 (default), 1, and 0. This parameter indicates whether the video controls will automatically hide after a video begins playing. The default behavior (autohide=2) is for the video progress bar to fade out while the player controls (play button, volume control, etc.) remain visible.

If this parameter is set to 1, then the video progress bar and the player controls will slide out of view a couple of seconds after the video starts playing. They will only reappear if the user moves her mouse over the video player or presses a key on his/her keyboard.

If this parameter is set to 0, the video progress bar and the video player controls will be visible throughout the video and in full screen.

autoplay (supported players: AS3, HTML5)

Values: 0 or 1. Default is 0. Sets whether or not the initial video will autoplay when the player loads.

cc_load_policy (supported players: AS3, HTML5)

Values: 1. Default is based on user preference. Setting to 1 will cause closed captions to be shown by default, even if the user has turned captions off.

color (supported players: AS3, HTML5)

This parameter specifies the color that will be used in the player's video progress bar to highlight the amount of the video that the viewer has already seen. Valid parameter values are red and white, and, by default, the player will use the color red in the video progress bar. See the YouTube API blog for more information about color options.

Note: Setting the color parameter to white will disable the modest branding option.

controls (supported players: AS3, HTML5) Values: 0, 1, or 2. Default is 1. This parameter indicates whether the video player controls will display. For IFrame embeds that load a Flash player, it also defines when the controls display in the player as well as when the player will load:

  1. controls=0 – Player controls do not display in the player. For IFrame embeds, the Flash player loads immediately.
  1. controls=1 – Player controls display in the player. For IFrame embeds, the controls display immediately and the Flash player also loads immediately.
  1. controls=2 – Player controls display in the player. For IFrame embeds, the controls display and the Flash player loads after the user initiates the video playback.

Note: The parameter values 1 and 2 are intended to provide an identical user experience, but controls=2 provides a performance improvement over controls=1 for IFrame embeds. Currently, the two values still produce some visual differences in the player, such as the video title's font size. However, when the difference between the two values becomes completely transparent to the user, the default parameter value may change from 1 to 2.

disablekb (supported players: AS3, HTML5) Values: 0 or 1. Default is 0. Setting to 1 will disable the player keyboard controls. Keyboard controls are as follows:

enablejsapi (supported players: AS3, HTML5)

Values: 0 or 1. Default is 0. Setting this to 1 will enable the Javascript API. For more information on the Javascript API and how to use it, see the JavaScript API documentation.

end (supported players: AS3, HTML5)

Values: A positive integer. This parameter specifies the time, measured in seconds from the start of the video, when the player should stop playing the video. Note that the time is measured from the beginning of the video and not from either the value of the start player parameter or the startSeconds parameter, which is used in YouTube Player API functions for loading or queueing a video.

fs (supported players: AS3, HTML5)

Values: 0 or 1. The default value is 1, which causes the fullscreen button to display. Setting this parameter to 0 prevents the fullscreen button from displaying.

hl (supported players: AS3, HTML5)

Sets the player's interface language. The parameter value is an ISO 639-1 two-letter language code, though other language input codes, such as IETF language tags (BCP 47) may also be handled properly.

The interface language is used for tooltips in the player and also affects the default caption track. Note that YouTube might select a different caption track language for a particular user based on the user's individual language preferences and the availability of caption tracks.

iv_load_policy (supported players: AS3, HTML5)

Values: 1 or 3. Default is 1. Setting to 1 will cause video annotations to be shown by default, whereas setting to 3 will cause video annotations to not be shown by default.

list (supported players: AS3, HTML5)

The list parameter, in conjunction with the listType parameter, identifies the content that will load in the player.

  1. If the listType parameter value is search, then the list parameter value specifies the search query.
  1. If the listType parameter value is user_uploads, then the list parameter value identifies the YouTube channel whose uploaded videos will be loaded.
  1. If the listType parameter value is playlist, then the list parameter value specifies a YouTube playlist ID. In the parameter value, you need to prepend the playlist ID with the letters PL

Note: If you specify values for the list and listType parameters, the IFrame embed URL does not need to specify a video ID.

listType (supported players: AS3, HTML5)

The listType parameter, in conjunction with the list parameter, identifies the content that will load in the player. Valid parameter values are playlist, search, and user_uploads.

If you specify values for the list and listType parameters, the IFrame embed URL does not need to specify a video ID.

loop (supported players: AS3, HTML5) Values: 0 or 1. Default is 0. In the case of a single video player, a setting of 1 will cause the player to play the initial video again and again. In the case of a playlist player (or custom player), the player will play the entire playlist and then start again at the first video.

Note: This parameter has limited support in the AS3 player and in IFrame embeds, which could load either the AS3 or HTML5 player. Currently, the loop parameter only works in the AS3 player when used in conjunction with the playlist parameter.

modestbranding (supported players: AS3, HTML5)

This parameter lets you use a YouTube player that does not show a YouTube logo. Set the parameter value to 1 to prevent the YouTube logo from displaying in the control bar. Note that a small YouTube text label will still display in the upper-right corner of a paused video when the user's mouse pointer hovers over the player.

origin (supported players: AS3, HTML5)

This parameter provides an extra security measure for the IFrame API and is only supported for IFrame embeds. If you are using the IFrame API, which means you are setting the enablejsapi parameter value to 1, you should always specify your domain as the origin parameter value.

playerapiid (supported players: AS3)

Value can be any alphanumeric string. This setting is used in conjunction with the JavaScript API. See the JavaScript API documentation for details.

playlist (supported players: AS3, HTML5)

Value is a comma-separated list of video IDs to play. If you specify a value, the first video that plays will be the VIDEO_ID specified in the URL path, and the videos specified in the playlist parameter will play thereafter.

playsinline (supported players: HTML5)

This parameter controls whether videos play inline or fullscreen in an HTML5 player on iOS. Valid values are:
0: This value causes fullscreen playback. This is currently the default value, though the default is subject to change.
1: This value causes inline playback for UIWebViews created with the allowsInlineMediaPlayback property set to TRUE.

rel (supported players: AS3, HTML5)

Values: 0 or 1. Default is 1. This parameter indicates whether the player should show related videos when playback of the initial video ends.

showinfo (supported players: AS3, HTML5)

Values: 0 or 1. The parameter's default value is 1. If you set the parameter value to 0, then the player will not display information like the video title and uploader before the video starts playing.

If the player is loading a playlist, and you explicitly set the parameter value to 1, then, upon loading, the player will also display thumbnail images for the videos in the playlist. Note that this functionality is only supported for the AS3 player since that is the only player that can load a playlist.

start (supported players: AS3, HTML5)

Values: A positive integer. This parameter causes the player to begin playing the video at the given number of seconds from the start of the video. Note that similar to the seekTo function, the player will look for the closest keyframe to the time you specify. This means that sometimes the play head may seek to just before the requested time, usually no more than around two seconds.

theme (supported players: AS3, HTML5)

This parameter indicates whether the embedded player will display player controls (like a play button or volume control) within a dark or light control bar. Valid parameter values are dark and light, and, by default, the player will display player controls using the dark theme. See the YouTube API blog for more information about the dark and light themes.

Player APIs and tools

Android

The minimum version supported of Android for the most recent versions of the API's is currently version 2.2. The Android device must also be running the YouTube app version 4.2.16. From then, using a web key, it is possible to use Googles API's through a developer enabled Android phone.[4]

IOS

Using the iOS versions of the API's is very similar to the Android explanation. However it involves using the Google Cloud Console. From there you are able to control the API's and set up the API's to work with your videos. You will also need a Client ID and a Client Secret; which can both be downloaded from Google's API Site. After this, it is a simple process of running the sample and the API's should then be properly integrated.[5]

Other API's include resources that can be implemented into a 3rd party website. These are the usual social network integrated API's that we regularly come across such as the Facebook like button or the Twitter follow button. YouTube widget API's include:

Data and Analytics APIs

The Data and Analytics APIs section briefly describes APIs that let your application access features and data normally available on the YouTube website.[6]

YouTube API V3

The YouTube Data API (v3) lets you incorporate YouTube functionality into your own application. You can use the API to fetch search results and to retrieve, insert, update, and delete resources like videos or playlists.

In conjunction with the YouTube Player APIs and the YouTube Analytics API, the API lets your application provide a full-fledged YouTube experience that includes search and discovery, content creation, video playback, account management, and viewer statistics.

youtube.activities.insertPosts a bulletin for a specific channel. (The user submitting the request must be authorized to act on the channel's behalf.)

Note: Even though an activity resource can contain information about actions like a user rating a video or marking a video as a favorite, you need to use other API methods to generate those activity resources. For example, you would use the API's videos.rate() method to rate a video and the playlistItems.insert() method to mark a video as a favorite.

youtube.activities.listReturns a list of channel activity events that match the request criteria. For example, you can retrieve events associated with a particular channel, events associated with the user's subscriptions and Google+ friends, or the YouTube home page feed, which is customized for each user.
youtube.channelBanners.insertUploads a channel banner image to YouTube. This method represents the first two steps in a three-step process to update the banner image for a channel:

- Call the channelBanners.insert method to upload the binary image data to YouTube. The image must have a 16:9 aspect ratio and be at least 2120x1192 pixels. - Extract the url property's value from the response that the API returns for step 1. - Call the channels.update method to update the channel's branding settings. Set the brandingSettings.image.bannerExternalUrl property's value to the URL obtained in step 2.

youtube.channelSections.deleteDeletes a channelSection.
youtube.channelSections.insertAdds a channelSection for the authenticated user's channel.
youtube.channelSections.listReturns channelSection resources that match the API request criteria.
youtube.channelSections.updateUpdate a channelSection.
youtube.channels.listReturns a collection of zero or more channel resources that match the request criteria.
youtube.channels.updateUpdates a channel's metadata.
youtube.guideCategories.listReturns a list of categories that can be associated with YouTube channels.
youtube.i18nLanguages.listReturns a list of supported languages.
youtube.i18nRegions.listReturns a list of supported regions.
youtube.liveBroadcasts.bindBinds a YouTube broadcast to a stream or removes an existing binding between a broadcast and a stream. A broadcast can only be bound to one video stream.
youtube.liveBroadcasts.controlControls the settings for a slate that can be displayed in the broadcast stream.
youtube.liveBroadcasts.deleteDeletes a broadcast.
youtube.liveBroadcasts.insertCreates a broadcast.
youtube.liveBroadcasts.listReturns a list of YouTube broadcasts that match the API request parameters.
youtube.liveBroadcasts.transitionChanges the status of a YouTube live broadcast and initiates any processes associated with the new status. For example, when you transition a broadcast's status to testing, YouTube starts to transmit video to that broadcast's monitor stream. Before calling this method, you should confirm that the value of the status.streamStatus property for the stream bound to your broadcast is active.
youtube.liveBroadcasts.updateUpdates a broadcast. For example, you could modify the broadcast settings defined in the liveBroadcast resource's contentDetails object.
youtube.liveStreams.deleteDeletes a video stream.
youtube.liveStreams.insertCreates a video stream. The stream enables you to send your video to YouTube, which can then broadcast the video to your audience.
youtube.liveStreams.listReturns a list of video streams that match the API request parameters.
youtube.liveStreams.updateUpdates a video stream. If the properties that you want to change cannot be updated, then you need to create a new stream with the proper settings.
youtube.playlistItems.deleteDeletes a playlist item.
youtube.playlistItems.insertAdds a resource to a playlist.
youtube.playlistItems.listReturns a collection of playlist items that match the API request parameters. You can retrieve all of the playlist items in a specified playlist or retrieve one or more playlist items by their unique IDs.
youtube.playlistItems.updateModifies a playlist item. For example, you could update the item's position in the playlist.
youtube.playlists.deleteDeletes a playlist.
youtube.playlists.insertCreates a playlist.
youtube.playlists.listReturns a collection of playlists that match the API request parameters. For example, you can retrieve all playlists that the authenticated user owns, or you can retrieve one or more playlists by their unique IDs.
youtube.playlists.updateModifies a playlist. For example, you could change a playlist's title, description, or privacy status.
youtube.search.listReturns a collection of search results that match the query parameters specified in the API request. By default, a search result set identifies matching video, channel, and playlist resources, but you can also configure queries to only retrieve a specific type of resource.
youtube.subscriptions.deleteDeletes a subscription.
youtube.subscriptions.insertAdds a subscription for the authenticated user's channel.
youtube.subscriptions.listReturns subscription resources that match the API request criteria.
youtube.thumbnails.setUploads a custom video thumbnail to YouTube and sets it for a video.
youtube.videoCategories.listReturns a list of categories that can be associated with YouTube videos.
youtube.videos.deleteDeletes a YouTube video.
youtube.videos.getRatingRetrieves the ratings that the authorized user gave to a list of specified videos.
youtube.videos.insertUploads a video to YouTube and optionally sets the video's metadata.
youtube.videos.listReturns a list of videos that match the API request parameters.
youtube.videos.rateAdd a like or dislike rating to a video or remove a rating from a video.
youtube.videos.updateUpdates a video's metadata.
youtube.watermarks.setUploads a watermark image to YouTube and sets it for a channel.
youtube.watermarks.unsetDeletes a watermark.

Buttons, Widgets, and Tools

The Buttons, Widgets, and Tools section describes other tools you can use to add YouTube functionality to your app or to test YouTube APIs.[7]

How To Use a YouTube API

To use YouTube's API, a developer must acquire a Developer ID - this is an additional property that is attached to the developer's YouTube account. The information that is available to developers is similar to the information that can be acquired by accessing YouTube's many RSS feeds. Since the integration of Google and YouTube it is possible to log in to YouTube using an existing Google account. An easy to use tutorial can be found as a YouTube video.[8]
The API's have since been extended and are now compatible with many mobile operating platforms such as Android and iOS. Quite obviously the Android API's are more complete with the iOS resources somewhat lacking. A list of this API's available for both platforms are below:

Other YouTube API's (the traditional API's) include:
Analytics API's

Data API

Advantages

A great advantage of using YouTube's API's is that 3rd party companies are able to arrange pay per click coupled with advertising for your videos. This allows the video uploader to receive money for the work they have put into their videos.[9] YouTube API's also allow a tighter integration of the video service into a 3rd party website. This essentially means that the user does not need to click a link to go to the YouTube video. Instead, they are able to view the video in the same page that they are visiting.[10] Another advantage of using the YouTube APIs is that as there are hundreds of hours of footage, however with using an API, it is easy to select the data and videos to store on a 3rd party site.[11]

Disadvantages

As of March 2006, API calls from Flash have been disabled due to security concerns. These however have since been re-enabled.[12]
There are also problems currently (October 2014) with the orientation on Android devices. Even by adding the fullscreen to the AndroidManifest, it still does not load properly in the correct full screen orientation.[13]
YouTube also does not allow videos to run whilst the Android device is sleeping. This can be seen as an annoyance for some users. Particularly if the user is trying to use YouTube as a replacement music player.[14]

Overall, the YouTube API's help the user with certain pieces of code. If the code snippet is already present, there is no need for each user to recreate this code as it has been supplied by YouTube themselves.[15]

See also

References

  1. "API Resources". YouTube API. Retrieved 7 October 2014.
  2. "Players and Player APIs". Retrieved 28 November 2014.
  3. https://developers.google.com/youtube/player_parameters#Parameters
  4. Francis, William. "Using Google's API In Your Android Apps". TechRepublic UK. Retrieved 24 October 2014.
  5. "YouTube Direct Lite for iOS". GitHub. GitHub Inc. Retrieved 24 October 2014.
  6. "Data and Analytics APIs". Retrieved 28 November 2014.
  7. "Buttons, Widgets, and Tools". Retrieved 28 November 2014.
  8. "Obtaining a simple API key for use with the YouTube API". YouTube. Google Developers. Retrieved 25 October 2014.
  9. Litt, Michael. "How To: Benefit From Using YouTube". VidYard. VidYard. Retrieved 24 October 2014.
  10. Wagner, Janet. "The Increasing Importance of APIs In Web Development". Tuts+. Tuts+. Retrieved 24 October 2014.
  11. Arno, Christian. "The Advantages of Social Media APIs". Search Engine Journal. Search Engine Journal. Retrieved 27 October 2014.
  12. "First time using YouTube's APi". Retrieved 2007-03-17.
  13. "what the advantage or disadvantages if i used youtube-API or present the video in a webview". StackOverflow. StackOverflow. Retrieved 24 October 2014.
  14. bh6712121. "Why Steam Music Won't Replace My Music Player". YouTube. bh6712121. Retrieved 25 October 2014.
  15. Purifier, HTML. "Embedding YouTube Videos". HTML Purifier. HTML Purifier. Retrieved 27 October 2014.

External links

This article is issued from Wikipedia - version of the 12/2/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.