Engineering and Developers Blog
What's happening with engineering and developers at YouTube
What to watch? Our APIs can help!
Thursday, September 12, 2013
It’s an age-old question: what to watch? Applications that integrate with YouTube have access to countless hours of videos, and, as a developer, you have an interest in helping your users find the videos and channel most relevant to them. This blog post will walk you through a few ways that you can use the
latest YouTube Data API
to discover great content.
If you have an
OAuth 2 token
for the current user, your application can make a call to
youtube.activities.list(part=”snippet”, home=true)
to get back a list of videos and channels similar to the recommendations that the user would see on the YouTube.com home page. These results are customized for each individual user, and the list is kept fresh automatically, so it’s a great way to present your users with content they’re likely to enjoy.
Even if your users are not logged in, there are still are a few charts and guides at your disposal to aid in discovery.
To find popular videos your users might want to watch,
youtube.videos.list(part=”snippet”, chart=”mostPopular”)
is the basic API call to use. By default, it will return a list of videos in any category that are considered popular globally. If this is too broad a list, though, you can narrow things down using the
regionCode
or
videoCategoryId
(or both) parameters.
regionCode
can be set to a
two-letter country code
to retrieve a list of videos popular in that specific country (though not every country is currently supported).
videoCategoryId
needs to be set to an ID corresponding to one of our existing video categories—you can retrieve a list of valid categories and their corresponding IDs via
youtube.videoCategories.list(part=”snippet”, regionCode=”
XX
”)
, where “
XX
” is also a two-letter country code.
There’s an analogous set of API calls that you could make to find channels your users might be interested in.
youtube.guideCategories.list(part=”snippet”, regionCode=”
XX
”)
will return a list of all the channel categories that are available in a given country. Once a user has chosen a category, you can get back a list of the most relevant channels in that category via a call to
youtube.channels.list(part=”snippet”, categoryId=”
CATEGORY_ID
”)
, where “
CATEGORY_ID
” is the ID of the guide category you’re interested in. At that point, you could display a list of the most recent videos associated with each channel, and give your users the option of subscribing (assuming they grant OAuth 2 authorization first).
All of these examples assume that you’re using the latest version of the
YouTube Data API, v3
. Developers still using the Data API v1 or v2 should be aware of some recent changes to our older content discovery mechanism, standard feeds.
As explained in the documentation
, all of the previous different types of standard feeds are now returning the equivalent of the
most_popular
feed, with the
time
parameter set to “today”. If you are still using v1 or v2, there’s no time like the present (
time=”today”
, if you will) to make the switch to v3.
Update
:
For a walkthrough and demos of all the API calls, please watch this episode of YouTube Developers Live:
Cheers,
—
Jeff Posnick
,
YouTube API Team
An Update to our Deprecation Policy
Friday, April 20, 2012
As you might have seen
announced
on our Google Developers blog, the deprecation policies associated with many of Google’s APIs are changing. We want to highlight the specific way this affects YouTube API developers.
As of today, our YouTube API deprecation policy states:
Google will announce if we intend to discontinue or make backwards incompatible changes to this API or Service. We will use commercially reasonable efforts to continue to operate the YouTube API without these changes until the later of: (i) one year after the announcement or (ii) April 20, 2015, unless (as Google determines in its reasonable good faith judgment):
required by law or third party relationship (including if there is a change in applicable law or relationship), or
doing so could create a security risk or substantial economic or material technical burden.
This Deprecation Policy doesn't apply to versions, features, and functionality labeled as "experimental."
Please note that while the deprecation policy listed above is current as of the date of this blog post, the definitive version of the policy can always be found in our
Terms of Service
.
Cheers,
—Jeff Posnick, YouTube API Team
The ActionScript 2 Chromeless Player and Monetized Videos
Monday, October 25, 2010
The
ActionScript 3 Player APIs
, both in the chromeless and embedded variety, have been available for use since
last October
. When we released the ActionScript 3 APIs, we announced the deprecation of the ActionScript 2 equivalents. As per our deprecation policy, we will keep the ActionScript 2 Player APIs running through October of 2012; however, we wanted to announce a change in the videos available for playback that will affect those still using the ActionScript 2
chromeless
player.
As of early January, 2011, some videos that YouTube and our content partners would like to monetize will not be playable using the ActionScript 2 chromeless player because it does not have the ability to show ads. If you attempt to play back such a video, an
onError
event will be fired, as
documented
in the ActionScript 2 Player APIs reference guide. As a developer, you can handle this event and play an alternate video, or display an explanatory message to your users.
Please note that this change only affects playback in the ActionScript 2 chromeless player. If you are using the ActionScript 2 embedded player (i.e. the official YouTube player with built-in controls) or if you’ve already upgraded to one of the ActionScript 3 players, you can continue to play the same video content you can play today. Also note that you might be using the the ActionScript 2 chromeless player indirectly if you’re using a third-party custom video player to play back YouTube content. Please reach out to the provider of your custom video player if you’re not sure whether this change will affect you.
Cheers,
-Jeff Posnick, YouTube API Team
Labels
.net
360
acceleration
access control
accessibility
actionscript
activities
activity
android
announcements
apis
app engine
appengine
apps script
as2
as3
atom
authentication
authorization
authsub
best practices
blackops
bootcamp
captions
categories
channels
charts
chrome
chromeless
client library
clientlibraries
clientlogin
code
color
comments
compositing
create
curation
custom player
decommission
default
deprecation
devs
direct
discovery
docs
Documentation RSS
dotnet
education
embed
embedding
events
extension
feeds
flash
format
friendactivity
friends
fun
gears
google developers live
google group
googlegamedev
googleio
html5
https
iframe
insight
io12
io2011
ios
iphone
irc
issue tracker
java
javascript
json
json-c
jsonc
knight
legacy
Live Streaming API
LiveBroadcasts API
logo
machine learning
mashups
media:keywords keywords tags metadata
metadata
mobile
mozilla
NAB 2016
news
oauth
oauth2
office hours
open source
partial
partial response
partial update
partners
patch
php
player
playlists
policy
previews
pubsubhubbub
push
python
quota
rails
releases
rendering
reports
responses
resumable
ruby
samples
sandbox
shortform
ssl https certificate staging stage
stack overflow
stage video
staging
standard feeds
storify
storyful
subscription
sup
Super Chat API
survey
tdd
theme
tos
tutorials
updates
uploads
v2
v3
video
video files
video transcoding
virtual reality
voting
VR
watch history
watchlater
webvtt
youtube
youtube api
YouTube Data API
youtube developers live
youtube direct
YouTube live
YouTube Reporting API
ytd
Archive
2017
Mar
Jan
2016
Nov
Oct
Aug
May
Apr
2015
Dec
Nov
Oct
May
Apr
Mar
Jan
2014
Oct
Sep
Aug
May
Mar
2013
Dec
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
2012
Dec
Nov
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2011
Dec
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2010
Dec
Nov
Oct
Sep
Jul
Jun
May
Apr
Mar
Feb
Jan
2009
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2008
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
2007
Dec
Nov
Aug
Jun
May
Feed
YouTube
on
Follow @youtubedev