Youtube GData API : Retrieving public statistics - youtube

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 .

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
:)

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.

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

Related

I am only getting upload activities from YouTube API, rather than getting other activities e.g. like, recommendation, subscription, favourite

I am using the YouTube API to get the activities of the authenticated user e.g. like, subscription, etc. The API should only return my the items with snippet.type=upload
This is my request call in python:
request = youtube.activities().list(
part="snippet,contentDetails",
# channelId=channelId,
mine=True,
maxResults=25
)
Here is the link to the API: https://developers.google.com/youtube/v3/docs/activities/list
Like you mentioned, (once again) YouTube Data API v3 doesn't work as expected by the documentation.
I think the best way to go is parsing webpages (when logged) like these ones:
Likes: https://myactivity.google.com/page?page=youtube_likes
Subscriptions: https://myactivity.google.com/page?page=youtube_subscriptions
This webpage describes a few webpages like above: https://myactivity.google.com/more-activity
If you go this way, don't hesitate to share your parsing code with others for instance on this repository.

Google Youtube API V3 Just Get Data

There are changes made on the Youtube API, i see bunch of stuff.
But all i want is to get the Youtube title and img thumbnail. DO i really need to go all the stuff regestering for api, etc just to get the title and img of a single video.
So i figured it out.
Yes, you really need to register an to the API Developers Console.
if you are like me and just want to get the title or thumbnail use the
Public API access
but if you are looking more for the extreme controls on your video out of youtube. You can do that but you have to use the
OAuth Credentials
to get simple data i used >>THIS<< basically the snippet holds the information for the Video like title,uploaded by,uploaded on etc. .

Getting curated content using streaming API

I cam across one third party API which provides organized twitter data as per user request.
example
http://api.frrole.com/v1/curated-content?location=India&contenttype=link&category=sports&orderby=popularity&minrt=10&resultcount=100&apikey=4534sdg34343
It give top 100 tweets from india, which contains link in tweets and falling into sports category and having minimum rt count =10.
Can someone tell me how does this work? It gives json data as result. Does this result comes directly via twitter streaming APIs or third party's own data base?
Is there any way for streaming API to do this?
This is likely coming from their database. They are consuming the data from the Streaming API or another API and then applying their categorization to it, then giving you the ability to access it from an API.
Some of the criteria above you could get from the Streaming API such as the filter_level (to find top Tweets) but you wouldn't be able to get that whole set of requirements (especially the sports categorization).

Can contentOwners use youtube analytics API to find ContentType(uploaderType) of a video

Using CMS account we can download raw data files from youtube(https://cms.youtube.com/cyc_download_reports).
This csv does have information whether a video was Partner-provided or UGC.
The corresponding closest match from Youtube Analytics API I believe is using the uploaderType
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3DXXXXXXXXXXXXXXX&start-date=2013-06-17&end-date=2013-06-21&metrics=views&filters=uploaderType%3D%3Dself&key={YOUR_API_KEY}
But this is at a contentOwner Level rather than at video level.Kindly let me know if I am missing something.
You're not missing anything. You can run a content-owner YouTube Analytics API report and use the uploaderType as a filter, to find stats about all the videos underneath that content owner that have a specific uploader type value. You can't request uploaderType as a dimension in a request with a video== or channel== filter, though.
The matrix of supported parameters is at https://developers.google.com/youtube/analytics/v1/content_owner_reports#Reports

Youtube API 2.0 Checking if a video is age restricted

I would like to check and see if a youtube video is age restricted. There are not many videos that are, but some are. I have been digging around in the youtube api documents and on the internet, but can't seem to find a way to detect this.
I am using the Youtube API V2 and only looking for one video at a time.
To check whether a video is (age) restricted in a given region, you can take a look at the media:rating attribute of the video entry, which is documented at
https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
If you want to do a search and filter out videos that are age restricted, you can use the safeSearch=strict parameter:
https://developers.google.com/youtube/2.0/reference#safeSearchsp
I agree to Greg Schechter. The actual question was like if we have a video id (eg: In the link http://www.youtube.com/watch?v=RyDY0hiMZy8 the video id is RyDY0hiMZy8), how can we get the age restriction details based on that?
There is an API provided by Youtube to get the details based on the video id. For the above example the API link is:
http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
But there is no information about the age restriction in the response.
Update on the above post:
In the API response from http://gdata.youtube.com/feeds/api/videos/tA4wytG3uh0?v=2&alt=json
we have a media$rating content coming and the data coming there can be compared with the rules mentioned in the link https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating
For non restricted videos, the media$rating value is not coming in the response. eg: in the link http://gdata.youtube.com/feeds/api/videos/RyDY0hiMZy8?v=2&alt=json
Any updates are welcome.
Age gating is not supported for embedded playbacks; so it's not something that is returned in the YouTube data api.
You can un-restrict those videos by following this link:
https://www.quora.com/How-do-you-change-the-settings-of-the-the-age-restrictrincts-on-my-YouTube-videos/answer/Doyle-Lorraine
Then your iframes should be back to normal.

Resources