How can I get YouTube playlist views count? - youtube-api

Does anyone know how this website is able to get historical views data for YouTube playlists?
From my research, YouTube API doesn't even let you get the current playlist views (I might be wrong).
I am talking about the playlist views, not the views from videos that were added to the playlist (you can see the view count here for example, on the left side - on desktop).
How can we get access to this type of data?

One more time YouTube Data API v3 doesn't provide a basic feature.
I would recommend you to use my open-source YouTube operational API. Indeed by requesting the JSON document https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID containing item["statistics"]["viewCount"] integer, your problem is solved.
You can request up to maxResults (currently 50) playlists separating playlist ids by a comma in id, example: https://yt.lemnoslife.com/playlists?part=statistics&id=PLAYLIST_ID_0,PLAYLIST_ID_1,...,PLAYLIST_ID_49
You can also request the title of the playlist by adding snippet to part, example: https://yt.lemnoslife.com/playlists?part=snippet,statistics&id=PLAYLIST_ID

Related

How do I get channel IDs for all YouTube channels in Japan?

I want to get channel IDs for all YouTube channels in Japan.
I tried to set the following parameters and call /search of YouTube Data API v3.
part: id
maxResults: 50
regionCode: jp
type: channel
pageInfo.totalResults in the API response is about 200,000 but actually I can only get 583 channel IDs.
583 is too little even if pageInfo.totalResults is an approximate value.
I would like to know how to get all the channel IDs in Japan, either by using the API or not.
I hope you will be able to provide the related information.
I tried to do almost the same for France. As said #stvar there isn't any appropriate endpoint to do so. However with patience and work we can make a kind of work around. My method only retrieves Japanese YouTube channels having indirectly publicly interacted with your starting set (see below).
Get a good starting set (in order to maximize the discover of the Japanese YouTube channels graph). I recommend you for instance to retrieve the top 100 Japanese YouTube channels sorted by view count by using SocialBlade.
For each channel discovered by the comments retrieved at step 3 (automatically) choose whether or not it is a Japanese YouTube channel. You can retrieve this piece of information if it is available for the channel in the "About" tab. To do it in an automatic way check whether or not snippet["country"] == "JP" in https://youtube.googleapis.com/youtube/v3/channels?part=snippet&id=CHANNEL_ID&key=YOUR_API_KEY If country isn't defined you can try to guess (automatically) whether or not it is a Japanese YouTube channel by making more complex checks see isFrench function. These checks are based on "About" tab and uploaded videos.
If the channel is interesting you (is Japanese) retrieve all comments (and so the YouTube channel about channel's videos and in the community tab using CommentThreads: list with part containing snippet and allThreadsRelatedToChannelId filter. If this method doesn't return any data because a video has disabled comments then retrieve the videos list and comments associated using (a) then CommentThreads: list with filter videoId. The approach (a) consists in getting the uploads auto-created playlist id of the YouTube channel by using Channels: list with contentDetails in part and then use PlaylistItems: list to retrieve all public videos uploaded on this YouTube channel. And if the YouTube channel contains more than 20 000 videos which is the upper limit for playlist size, use this script instead of (a). The script consists in faking requests done when browsing videos on a YouTube channel.
Then continue to dive into the Japanese YouTube channel graph by discovering Japanese YouTube channels through the comments found in your starting set and so on.
You can have a look for more details and some helping tools on my GitHub repository dedicated to the same approach for France (I was trying to list all comments let on French YouTube videos).
Of course you might need multithreading and group your YouTube Data API v3 request to reach maxResults upper limit in order to maximize your quota efficiency. Good luck.

Youtube api v3 - list of deleted vids

we are using the youtube api to keep track of youtube videos. currently we "watch" around 30k videos. now we have the issue that we want to figure out which videos have been deleted. is there some way to get e.g. a list of all deleted vids of a channel or some other way?
sending a single request (and handling 404) for each video doesn't seem to be a good idea.
I guess you can not do it with only youtube api.
You can create your own database of all your videos and channels and periodically sync it with youtube to check what video status changed or not exists in list anymore.
Youtube API has method Videos.list, it returns list of all your videos.
Another tricky way: load every video url and check the size of content instead of parsing html.
If video exists then content size about 50kb, if not - 15kb. It seems youtube do not pass Content-Length header. That's why you need to load content to check size.
But I prefer the first way.

Output last and popular youtube videos on site ? any api?

I want to output last videos and popular videos of my youtube channel.
Is there any standart widget, api method for this?
Based on this answer, you can use the YouTube Data V3 API to get the uploads playlist ID, which you can then use to get the latest videos in that playlist. You can change the value of maxResults to return however many videos you want (from 0 to 50).
Use the search:list method to get your most viewed videos by specifying the channel ID and setting order=viewcount (not quite sure what you want when you say popular videos, you could also set order=rating to get the highest rated videos). This video might also help you out.

YouTube Content ID API - Views and earnings per asset

Assuming that I'm quite new to the YouTube Content ID API (and in general to YouTube Content ID), i'm looking for a method for get quickly the views and the earnings of a single asset.
Analyzing the YouTube Analytics API, I have not found anything making reference to the assets,
then I tried to base myself on the claims to obtain the data which I need. It's work, but, having to walk multiple pages, this takes many requests to the YouTube API server and it responds really slowly.
I would like, in practice, achieve a similar result:
I'm using PHP for this, but I do mostly GET requests directly basing on the documentation of YouTube Content ID API
I've found the solution:
Using the Youtube Analytics API:
ids=contentOwner==MY_CONTENT_OWNER_ID
start-date=my_start_date
end-date=my_end_date
metrics=estimatedMinutesWatched,averageViewDuration,averageViewPercentage, views,subscribersGained
dimensions=video
filters=claimedStatus==claimed
max-results=10
sort=-views
I can obtain the top 10 videos claimed sorted by views.
With the video ids, I can get the views, the earnings and the asset id using the ClaimSearch reference in YouTube Content ID API I can find the rest of the informations that I need.
EDIT:
There is a dimension missed on the official documentation: asset.
I've updated the query of Analytics API:
ids=contentOwner==MY_CONTENT_OWNER_ID
start-date=my_start_date
end-date=my_end_date
metrics=estimatedMinutesWatched,averageViewDuration,averageViewPercentage, views,subscribersGained
dimensions=asset
filters=claimedStatus==claimed
max-results=10
sort=-views
and it show directly the assets.

YouTube API Search by Tags

I'm trying to add videos to an existing ASP.NET MVC site, and I'd like to show videos from our YouTube channel.
I have added a tag to each video to indicate what page it should appear on. I had thought that I could search our channel by tag on each page to render the relevant video on that page.
I'm trying to exclusively use the API v3, but it seems I can't do this.
I can't use developer tags, because videos are uploaded by multiple users using the standard YouTube front end. This seems like basic functionality, so I'm assuming it's my inexperience with this API.
As an example, our YouTube channel is ChillinWithCharlie. During development, one video is tagged 20141213Cheneys.
I can get all videos in our channel, but is there a way to query the v3 API to retrieve just this video?
I've seen one suggestion here that I retrieve all videos, and filter in code. This feels inefficient, so I'd rather not do this, but I can't even see where the tag is returned with all channel videos, that I could interrogate in code.
It's not just you. There seems to be no specific query parameter to search by tag with API v3.
I would recommend doing a search with your tag in the 'q' (search) parameter, then checking the results to see if the tag exists in the returned snippet->tags property to verify the exact video.
Note YouTube tags are only visible to the video's uploader.
https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]

Resources