YouTube Developers Live: The YouTube Analytics API

Uploaded by GoogleDevelopers on 14.11.2012


JEFFREY POSNICK: Hey, everybody.
Welcome to this week's YouTube Developers Live.
I'm Jeff Posnick, broadcasting from New York.
We don't have any of our Mountain View colleagues
joining us today.
We have lots of folks traveling to
really exciting events.
So I'm going to be emceeing the show.
But we do have some awesome guests joining us remotely
from Zurich.
And those are Ted Hamilton, who is the product manager for
YouTube Analytics, and Christoph Schwab-Ganser, who
is the lead engineer for the YouTube Analytics API.
And as you might imagine based on the guests that we have
today, we're going to be really doing a nice deep dive
on the YouTube Analytics API.
This is a fairly new API that we announced for the first
time back at Google I/O in July.
And ever since then, we've been slowly
adding on some features.
It's been publicly accessible for a few weeks now.
And hopefully, folks have had a chance to play around with
it already.
If you haven't, you'll learn a lot more today and hopefully
get started soon.
So I just want to say hi to Ted and Christoph.
Hi there.
JEFFREY POSNICK: And thanks so much for joining us.
So I kind of want to just dive right in with some questions
for you guys.
And first of all, for folks who maybe have not played
around with the type of Analytics data that we
previously offered before rolling out this YouTube
Analytics API, there was something called the Insight
Report that you could retrieve using the older version 2 of
the YouTube GData API.
And this would basically give you back a really big .zip
file, and the .zip file would contain a whole bunch of
comma-separated value files and within those files had
some useful YouTube Analytics data.
But kind of the whole process of doing that .zip file
extraction and CSV parsing maybe wasn't every developer's
favorite way of interacting with the API.
So I'm curious if you guys could talk a little bit about
how this new YouTube Analytics API is different from what we
used to offer with Insight and what's the developer
experience like if you're using the Analytics API.
CHRISTOPH SCHWAB-GANSER: So the new Analytics API allows
you to basically ask precise questions and then get really
a precise answer, unlike the old system, which just had a
zip file full of answers, and you had to find the one which
you were really interested in.
So for example, now we can ask, what are the views, for
example, for my videos from Italy.
And you just get this number.
Or you can ask, where was my video [INAUDIBLE] to, for
example, in what page.
So this is another example of a query.
So it's really a lot more--
it allows you to make a precise query, and you get
just the data that you asked for.
It also allows you to develop applications like from the web
pages, whereas with a .zip file, it's not really possible
to pull this from JavaScript.
So that's another advantage.
TED HAMILTON: Yeah, I mean previously, it would have been
impossible, basically, to make a dashboard or an app where
you're just looking up point data.
You'd have to basically download a CSV, cache it
locally somewhere so that you could
actually have quick lookups.
But now you can get exactly the data that
you're looking for.
An Android app, an Android widget, or iOS, all of that
becomes a whole lot simpler.
And I know that what you describe with the YouTube
Analytics API's approach, that's very much in keeping
with something we've talked about previously in this show,
the new version of the Data API, where it's a very
targeted set of information that gets returned, especially
compared to the older Atom XML response format
that it used to get.
The older version of the Data API, so kind of using the same
analogy, you're getting exactly what you want for.
That's obviously better for us in terms of not having to run
reports and generate metrics that you don't care about, and
it makes for more responsive applications.
Also worth pointing out that it's built on the same sort of
back end that the Data API is using.
So for folks out there who have already started their
Data API integration, using the Analytics API should
hopefully be straightforward for you guys.
Same set of client libraries, OAuth 2.0 type of flow.
And hopefully you can build some really cool applications
that use both of those APIs together.
So I've noticed that there's still some statistics that
developers can get via the YouTube
Analytics web interface.
And those aren't yet exposed via the API, or weren't until
recently exposed.
I mean, we do have a few announcements to make
regarding some new statistics today.
So what's the long-term plan for the API in terms of
catching up with what you can get through the web interface?
TED HAMILTON: So basically, the API should be every bit as
powerful as the web UI.
As a general rule, we want to enable you to do anything that
you can do on YTA, you can do analytics through the API,
with the slight exception that we might be able to put more
experimental data or something like that on the UI.
But when we put something in the API, we want it to be
around for a while.
So there might be a slight lag there.
But for instance, we hear all the time that earnings data is
missing or audience retention data is missing.
And we want to find a way to provide that data so we can
give you everything that you need to have a complete data
set, basically.
So definitely patience is recommended for developers out
there who are waiting for their
specific favorite metric.
TED HAMILTON: Yeah, exactly.
It's not easy to wait, but we want you to have it as much as
you want to have it.
Another thing that I know that developers out there have
probably noticed and might have questions about is the
fact that the Analytics API is currently marked as being
experimental, which has a very specific set of
connotations around it.
So what does being an experimental API mean for
developers, and can you talk a little bit about what the
process might be for leaving experimental?

CHRISTOPH SCHWAB-GANSER: Experimental means that we
still can make changes to the API.
So basically, you're not bound to the terms of services that
the other APIs are.
And so we should mention that we didn't make any breaking
change since we entered like trusted testing.
And basically, I think the criteria for leaving
experimental is that we have confidence in the structure of
the API and basically that we have enough positive feedback
from partners and developers that the API's
really what they want.
JEFFREY POSNICK: Yeah, so I guess there might be some
developers out there who see experimental and say, I don't
even want to bother developing anything or trying out this
API until that experimental label goes away.
And it sounds, based on what you're saying, that would kind
of be a negative reinforcement cycle where we're looking for
the feedback that we only get when developers are using
these APIs.
So if they just wait, we're never
going to get that feedback.
And that might actually delay the process of removing the
experimental label.
If I can kind of interpret what you're saying and have
the main takeaway that please, if you are doing anything with
Analytics, and you're doing stuff that might use the older
Insight Report in particular, please start using the YouTube
Analytics API.
It's definitely what the future of Analytics will be
for YouTube.

It has all the benefits that we talked about before, and
we're always interested in getting the feedback while
we're in the experimental phase.
And even when we leave the experimental phase, we
obviously still want to hear what developers have to say
about the API.
TED HAMILTON: I want to emphasize what Christoph
already said is that it has been stable.
We have not changed it.
We have to mark it as experimental because we need
to reserve the right, if we get feedback from you guys, to
make a slight change.
But this is basically the model that we
use for our own app.
So we expect it to kind of stay the way that it is.
And yeah, people, please do use it.
And if something does change, it's not going to change
So the more feedback that you can proactively provide, the
better sense that we get for whether things are working
well or not working.
And of course, we're monitoring the usage just to
know how that's ramping up.
Definitely makes sense.
Can you guys, either of you, speak to some of the specific
limitations that are currently in the API around generating
very large reports, maybe running specific report types
against channels that have thousands and
thousands of videos?
What's that experience like today, and what kind of
limitations are in place?
TED HAMILTON: Well, so it's basically limited by how fast
you can iterate through the data and of
course your rate limit.
It's not designed to basically be a data import
functionality, where we basically just export all of
the data that we have in our back end, and
you can ingest it.
It's meant to be much more like precise point lookup
dashboarding type of thing.
And then if you have a manageable amount of videos,
it works quite well.
But on the far end of the spectrum, some of our partners
have literally thousands of channels, and each one of
those has many, many videos.
And so we'll work on a solution for that type of user
where they can basically download the data, ingest it
into their data warehouse, so they can
perform analysis on it.
We're working on that type of thing.
And that we'd expect to be probably in the first
half of next year.
So if you have immense data needs and literally just want
to ingest the data to merge with your other internal data
or data from other networks or whatever, that might be a
solution for you.
But it's still a ways off.
That definitely makes sense.
And I know that I've heard questions from developers
specifically who weren't necessarily aware of that
We try to spell it out in the docs.
But for instance, if you are running certain types of
reports, you could only retrieve the actual metrics
for the top 10 videos in a given channel sorted by
decreasing views, for instance.
So that's the type of limitation that is in place.
You can't say I want every single video.
But you can still run a report.
It's just that it's kind of limited to the top 10 videos
in your channel.
TED HAMILTON: You can individually request the data
for every single video.
TED HAMILTON: But you can't get a sort of list of beyond
the top 10 for most things right now.
And that's just something we want developers to know that's
intentional right now, and it's for all the reasons that
Ted mentioned.
So just be aware of that limitation for right now.
And we talked a little bit about this having to do with
how expensive certain reports could be.
What should developers know about the way quota works with
the Analytics API?
I know that quota is always a big topic when we talk about
the Data API.
And people will want to know what types of calls are more
expensive than others.
How can they kind of optimize their usage?
Because we obviously do need to place some limit on the
type of API traffic that we receive.
So if you could go into a little more detail publicly, I
know our developers would be really happy to hear that.
CHRISTOPH SCHWAB-GANSER: Yeah, basically, our API server does
a variable amount of work depending on your query.
Basically, it's going to fetch more or less data on
processes for you.
And basically, this is also reflected in the amount of
quota that we deduct from your develop quota.
And we have something documented on our public
And basically, you can say the more columns or metrics that
you add to your report, the more expensive the
request will be.
And also, when you get, for example, for top videos, when
you get a top video report, and you add many metrics, it's
going to be more like exponentially
expensive as we look up.
Every value in this table represents a separate lookup,
and this is reflected in the quota deduction.
So as a general guideline, it's good if you just request
only the data that you really need, of course.
And that you also, if you're ingesting data in a database,
that you then prepare it for quota errors, limitations, and
that you have an exponential backoff based as you rate
limit your request to our API.
And I'm sure folks might run into that, people who despite
our disclaimer about this not really being a data dump, who
do try to do a data dump and get individual reports one by
one for each video ID in their channel, let's say.
That's a really easy way to trigger quota errors if you
keep doing that quickly enough and you have enough videos.
So do be prepared to kind of back off in that case using,
ideally, an exponential backoff.
CHRISTOPH SCHWAB-GANSER: You can also give us feedback
based on the quota limitations.
Just tell us if they are too narrow.
[INAUDIBLE] we are still open, of course, to your feedback.
JEFFREY POSNICK: Yeah, I know that while we're in
experimental mode, we have a default amount of quota units
that we're giving people.
And I don't want to speak for you guys, but I'm assuming we
could kind of be a little bit reactive in terms of upping
that in general as a default if things look like
it was set too low.
So that's one of the things I want to hear about, and I'll
pass it along to the relevant you guys on the team.
So those are the main questions that I had.
And we're going to answer some questions a little bit later
from the Google Moderator link.
For those who are watching this live on YouTube, you
should see in the comments a link to the Google Moderator
queue for any questions.
So this is your chance to ask
questions of Ted and Christoph.
But we'll get to that in a little bit.
Before we do, I wanted to show off some of the cool new
things using the Google APIs Explorer.
So both show off how you can use the API Explorer to run
Analytics reports, because not everybody knows that.
And that, in and of itself, is very cool.
But I also wanted to show off some of the new metrics that
are now available via YouTube Analytics.
And I think this is available as of earlier
today or as of yesterday.
Is that right, Christoph, some of these things?
So, they're so fresh that our tech writer is working very,
very diligently to try to get everything documented.
But you won't necessarily see these things in
the docs quite yet.
That should come shortly.
But nice little perk for tuning, and you get a sneak
preview of what we're about to add to the API, or what we
just added to the API.
TED HAMILTON: Hopefully it works.
JEFFREY POSNICK: Yeah, hopefully it does work.
I think I'm going--
So if you take a look at what I have on my screen right now,
I am using the Google APIs Explorer.
And this is something that, it's a public tool that
anybody can go and use.
It takes advantage of being able to do a nice OAuth 2.0 in
the browser flow.
So I've already authorized access to this test account
using OAuth 2.0.
But if you go to this for the first time, you have a chance
to authorize access.
You don't have to put in your username
and password anywhere.
It integrates nicely in that regard.
Actually, folks might not be able to see what the URL is.
But if you go to, I think
there's a link to the APIs Explorer at the bottom.
But the main URL is developers.googl
And you can get there from here.
So I'm going to show off a couple of new reports.
These reports are kind of run against a test content owner
account that we have set up.
This is actually something I wanted to point out because
this came up recently in Stack Overflow.
Somebody was asking a question, and they weren't
quite sure what the syntax was to use for the IDs parameters
that you see over here-- let me make it
a little bit bigger--
the IDs parameter that's over here when you're doing a
content owner.
So basically, the way it looks like is content owner equals
equals and then the name of the content owner.
It's not a alphanumeric ID.
It's the actual name of the content owner.
So that's what we're doing in this case.
We are doing a normal month-long report with a start
date and end date.
We're making use, in this case, of some of the new watch
time data that is now available in the API.
So we're asking for the estimated minutes watched, the
average view duration, and the average
view percentage metric.
This is something that people have been really asking about
since we announced the Analytics API.
You can now do it, which is great.
And the dimension in this case is video.
And we have a filter here to the videos that we uploaded.
And over here is 10 results.
And we are sorting by decreasing estimated minutes
watch, in this case.
This is another thing to point out for folks.
Not everybody--
this also came up on Stack Overflow once, where somebody
missed that minus sign that was at the
start of a sort order.
That lets you sort by decreasing.
So for instance, if you're doing certain types of
reports, you need to sort by decreasing views.
So be sure--
that minus sign actually is really important.
And I actually already executed this report, that we
could click Execute if you want to run it yourself.
And what you get back is your standard
YouTube Analytics response.
For folks who haven't actually tried the Analytics API
before, you get back JSON data.
It's pretty easy to parse.
I think you can also request CSV data, if I'm not mistaken.
I like working with JSON, so that's the default, and that's
what I'm showing off here.
You get back something that describes the headers for each
of the columns.
And then you just get back rows.
So it's kind of like a serialized version of a report
table, more or less.
Each row, in this case, has the video ID, the estimated
minutes watched, view duration, and the average view
percentage, which shows, I believe, what the average
viewer has viewed of the video, whether they've viewed
100% or 75% or so on.
So in this particular case, 48.669%, which
isn't bad at all.
So this is really useful data for folks who are curious
about how many minutes watched their videos have had, what
the most popular videos are on their accounts, according to
minutes watched over a certain period of time.
And something you couldn't do before, and something I would
imagine would have been very, very difficult using the
Insight API.
You certainly couldn't just have run a report and asked
for those specific types of metrics.
You would've had to parse a really big CSV file and kind
of interpret the results yourself.
So that's pretty cool that you can do that now.
A couple other things that I wanted to show off.
This one is making use of the playback location dimension,
which is now available on the API for a specific video ID.
And what this will let us do is get the top 10 videos
sorted by decreasing views--
sorry, get the top 10 locations for playback sorted
by decreasing values, based on where they were played back.
So in this case, this is a video that has presumably been
embedded a few places, embed over here on Facebook, on, a few other sites.
It gives you a real interesting way of
looking at your data.
You might have embedding enabled for your videos, and
you want to see where they're being played back.
It's pretty awesome that you can do that now.

One other report to show off, this is a
source of your playbacks.
And I believe if I just scroll down over here--
OK, the source for traffic to your videos.
So over here, you can see which playbacks came from
YouTube channels, people went to your videos via the channel
versus via search on YouTube versus via just like organic
Google search versus related videos versus just
clicking on the URL .
So also really super useful, if you care about how people
are finding your videos, you want to see what the top
sources are for people who are discovering your content so
you could maybe focus a little bit more on that.
And that's also something there that you can now do
using the API.
So I'm personally pretty excited to see
that new stuff added.
Is there anything else that is notable that I didn't cover in
these demos that you guys wanted to bring up in terms of
new types of metrics that are available?

CHRISTOPH SCHWAB-GANSER: These are the main two features
[INAUDIBLE], so yes.
And people have been asking us for that for a while, so it's
really exciting to see those there.
So play around with those demos.
That's a great way to get familiar with the API without
having to write any code yourself.
I mean, you obviously can make all these requests in an
automated fashion using pretty much any
language of your choosing.
We have other client libraries that support most of the
popular programming languages out there.
And if you're running into questions, either using the
client library or maybe just something about the Analytics
API is not really clear, and you're just running into any
sort of issues, I want to make sure that folks know the right
place to go for any sort of questions that you have.
And the best place to ask questions is on Stack
Overflow, which is generic.
It's a good programming website that folks are
hopefully familiar with.
And if you tag your thing with YouTube API, YouTube-API, you
should be able to post a question that
we'll see pretty easily.
So even though this is for the Analytics API, if you just use
the standard YouTube-API tag, that would help a lot in terms
of us finding your question.
And we'll answer pretty much anything that you guys ask.
But there are some things that are not really questions, and
they might be bug reports or feature requests, and that
sort of thing is best posted on our standard
YouTube issue tracker.
So please make use of that for the
appropriate types of things.
And we do have some resources for folks who want to get
started with the API.
Lots of people like having sample code.
So if you go to our documentation,
you'll come to this main page.
And over here, on the left hand side, there's a sample
I must admit that some of the items in the sample
application are not completely up to date.
So you'll take a look, and you'll see step one
through step five.
There are few changes actually specific not to the Analytics
API but to some of the other APIs that this uses, namely
the Data API, that were recently made, which we didn't
have a chance to reflect yet in the step
by steps over here.
But what we do have at the very bottom of the page is a
full sample application that's kind of the full version if
you were to go through all the steps yourself.
And this has been updated to be something
that's fully working.
Feel free to take this code, this JavaScript code.
It gives a pretty cool sample application that lets you do
real time requesting of data for specific videos over the
past month and then uses the Charts API for charting the
view count information for those videos.
So it's something that we want to make available just as a
very basic starting place.
There's going to be more sample code that you should
see over the next few days slash weeks.
It's definitely our goal to get as many languages covered
and make sure that people have a good starting place,
regardless of what language you're coding in.
So please check that out.
And at this point, I think I kind of wanted to switch
things over to the Google Moderator to see if anybody
has any questions from there.
So let's do a refresh.

And OK, so there's one question over here which I do
not think is specific to the Analytics API, per se.
But it's kind of a meta-question about the best
way of going about interacting with us during these live
broadcasts, let's say.
So it's, "I want to know if people are broadcasting live
via Hangouts can see the comments that are posted in
the live message feed.
It would be nice to interact with the viewers that aren't
included in the Hangout itself."
So we're actually a little bit different than a lot of the
other Google Developer live shows, in that we tend not to
have public Hangouts.
Christoph and Ted are joining us via Hangout right now, but
it's not just random audience members.
So we do ask people to interact with us via this
Google Moderator that's embedded at the bottom of
every show listing.
So you found it.
That was from Ollie.
You obviously found it.
That's the way to get our attention during a show.
I know that there is a live comments feed that you can
post on if you're watching the video there.
That tends to be watched by our fearless producer who's
running the whole show.
And if the audio isn't working or something along those
lines, that's a good thing to post in the comments feed of
the YouTube video.
But in general, the people who are on the air don't get to
see anything that's raised there.
So use the Google Moderator.
TED HAMILTON: That's where you can call us idiots and stuff,
and then we don't get distracted by
that during the show.
So fortunately, none of the two questions that are there
actually call us idiots in this particular case.
But we have a pretty--
I'm trying to interpret this question here.
It's kind of about publishing YouTube videos to a website.
And it's asking whether you can use Analytics data to
analyze things.
I'm not entirely sure what the question refers to other than
just the basic fact that, yes, you can use the YouTube
Analytics API to, for any video, regardless of where
it's played back, get information about who's
watching your video.
So take a look at the documentation, use the API
Explorer, and I think that will give you, hopefully, what
you need to get started.
TED HAMILTON: I think he might be asking if you can upload
through the API.
Yeah, if you're asking about uploading, that definitely is
part of the Data API.
So that's not necessarily part of the Analytics API, which
we're talking about today, but it's part of either the older
Google Data version of the API or the newer version of the
API which we are calling Version 3, and we recently
also launched.
You can definitely automate the uploading of videos into
your own channel.
So yep.
TED HAMILTON: And once you do, you can definitely get the
data for it.
So we want everything to be as automated
as possible, ideally.
So a couple of other questions came in recently.
Can you package OAuth for two different YouTube APIs in a
single prompt, and the answer is yes.
So I assume, specifically, the question has to do with
whether you could ask for both Analytics permission and
YouTube Data API permission within a single OAuth 2.0
approval flow.
And that's a really nice thing about OAuth 2.0.
You can specify as many, it's called
scopes, OAuth 2.0 scopes.
So you can specify as many scopes as you
want in a single request.
And you don't have to have the user see a pop up multiple
times where they say, OK, yes, I do want to
give Data API access.
Yes, I want to give Analytics API access,
that sort of thing.
And that actually applies to any of the Google APIs.
So let's say, I don't know, in addition to doing YouTube
Analytics, you're also doing Google Analytics and using the
separate Google Analytics API.
You could put the Google Analytics API scope in the
same OAuth 2.0 request flow and do all of that at once.
And there was a question about where you could download the
example code.
So right now, the sample that we had on the site is just
linked to from the main YouTube--
sorry, developers.googl, and
going there, and then going to the left hand side to Sample
What we've been doing for the Data API and we've been
actually kind of successful, I think, in getting that
started, and I can pull that up and show what we're doing
there, is trying to do inline code samples when you look at
the different API methods.
So I believe this is one that has it.
So this is for the Data API.
And you can see that we have inline PHP and Python samples
right within the page that documents
the search.list method.
So we're going to first of all work on expanding our Data API
code samples.
But I think we're going to also start doing the same
thing for the Analytics API.
And when you go to the page, that's referenced.
This is a little bit different because there's really only
one reference page for the Analytics API.
But ideally, we'll have some code samples right here on
this page in all the different languages that you need.
And that's something that we're hard at work on and
hopefully will make available pretty soon.

So we are actually out of time.
This was a really fun, full show.
And I just want to thank both Ted and Christophe.
It's fairly late in Zurich.
And thanks so much for sticking around and dialing in
and talking about the API.
And hopefully, we'll get some folks going out there and
writing some code now that makes use of this cool stuff.
TED HAMILTON: Absolutely.
Thanks for having us on, and I can't wait to see what
everyone does with the data.
I think this will unlock some great new possibilities.
So have at it.
OK, until next week, bye, everybody.