Reputation: 968
On YouTube now there is a show video statistics button which shows the statistics of video like view count over time and demography .
I have looked through the YouTube api but I didn't seem to find a way to retrieve this data. The closest I could come to was http://code.google.com/apis/youtube/2.0/developers_guide_protocol_insight.html but this is for particular user . I wished to get data available in public .
Upvotes: 2
Views: 3635
Reputation: 11
Now this service is available, but now he need a token for download the file insight ajax.xml with all data. because if a call the service http://www.youtube.com/insight_ajax?action_get_statistics_and_data=1&v=MYVIDEOID the response is
<?xml version="1.0" encoding="UTF-8"?>
<root><return_code>
<![CDATA[1]]>
</return_code>
<error_message>
<![CDATA[The request is not valid.]]>
</error_message></root>
the POST call has this fotmat :
Parameters
application/x-www-form-urlencoded
session_token 1UEcRYZx-I3xifChIhm5QFOKxfJ8MTM3MjI1MjY3OUAxMzcyMTY2Mjc5
Source
session_token=1UEcRYZx-I3xifChIhm5QFOKxfJ8MTM3MjI1MjY3OUAxMzcyMTY2Mjc5
Upvotes: 1
Reputation: 144
Yes like mad_scientist said, the public insights for a video are not provided via the API
https://developers.google.com/youtube/2.0/developers_guide_protocol_insight
"YouTube Insight, an analytics and reporting engine, provides viewing statistics, popularity metrics and demographic information for videos and channels.
A video entry contains a link to Insight data if the authenticated user retrieving the entry owns the video.
A profile entry contains a link to Insight data for the channel if the authenticated user is retrieving his or her own profile."
If you want to get likes and dislikes, and works with c#, you can use this code:
https://groups.google.com/forum/?fromgroups=#!topic/youtube-api-gdata/UBbiyE3Cw5M
:)
Upvotes: 2
Reputation: 9709
Unfortunately, the public insights for a video are not provided via the API (and I´m pretty sure they won´t add id, but maybe there is a small chance they´ll implement this in the new analytics API). If you want to query the statics for your own video, you could use the insights APIInsights API. For all other videos, you could screen-scrape/parse the insights out of the xml/CDATA-Response with this link
http://www.youtube.com/insight_ajax?action_get_statistics_and_data=1&v=YOURVIDEOID
You should use a parser which is capable of parsing broken html, like lxml or BeautifulSoup for python.
Upvotes: 2