How to know if a video has been seen/hidden? - youtube-api

Using the YouTube Data API v3, is there a way to know if a video has been seen or hidden?
Reading through the docs, I didn't see anything on the Video resource that could match what I'm looking for.

Logically, “Watched” videos are just videos which have entries on your “Watch History” on Youtube.
You can get your “Watched” videos list through the API by getting your Watch History list from your channel. You can do that by using obtaining your Watch History ID which at the same time is also treated as playlistId.
Referring through the Channel API, make a GET HTTP request to
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={YOUR_API_KEY}
This should return a JSON which should contain an object with “watchHistory” key. The value paired with it is your playlistId which you can now use to make a request using the PlaylistItems API
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId={YOUR_WATCHED_PLAYLIST_ID}&key={YOUR_API_KEY}
This should return a list of videos that your account has already watched.
As for getting the list of “Hidden” videos on your subscription feed. I think it's not achievable through the API. Checked on different responses of subscription and video resources but to no avail. No responses containing "watched" or "hidden" related.

Related

How to get YouTube channel's trailer and featured video via the Data API?

I'm trying to use the YouTube Data API to get a channel's Trailer and Featured Video but can't find anything in the [API docs][1] or responses that might provide it. Ideally, there'd be something that would return the ID of whichever videos had been selected here: https://studio.youtube.com/channel/[CHANNEL_ID]/editing/sections
Maybe it's buried in an obscure endpoint. Maybe the API simply doesn't include this anywhere. Can anyone please point me in the right direction?
Update: I've found the channel trailer as unsubscribedTrailer under the channels:list endpoint with the brandingSettings part. However, for some reason Google has decided not to include the featured video with it.
One more time YouTube Data API v3 doesn't provide a basic feature.
As Video spotlight you can have:
Featured video for returning subscribers
Highlight a video for your subscribers to watch. This video won’t be shown again at the top of your page for subscribers who have watched it. Learn more
Source: https://studio.youtube.com/channel/CHANNEL_ID/editing/sections
For the featured video:
you first need to subscribe to the give YouTube channel. To do so in an automatic way, use YouTube Data API v3 Subscriptions: insert endpoint.
then open your web-browser Network developer tool tab (Ctrl + Shift + E on FireFox) and filter HTML requests, then visit https://www.youtube.com/channel/CHANNEL_ID and copy the initial request to CHANNEL_ID as cURL, that way you can re-execute this cURL request for any channel you are subscribed to by changing the URL in the cURL request to https://www.youtube.com/channel/ANOTHER_CHANNEL_ID. Furthermore you'll find the featured video id in the JavaScript variable ytInitialData in the JSON entry
contents/twoColumnBrowseResultsRenderer/tabs/0/tabRenderer/content/sectionListRenderer/contents/0/itemSectionRenderer/contents/0/channelFeaturedContentRenderer/items/0/videoRenderer/videoId.
The channel with id UCv_LqFI-0vMVYgNR3TeB3zQ have both a channel trailer (1RHxvM8mQS4) and a featured video (rFuip5CSWcA).

How to get metrics from YouTube Analytics API for every video which belongs to current user?

I want to get metrics (such as likes, views and subscribers gained) for every video in my youtube channel (or about 10 latest video) , how can I do it correctly?
I'm using such API call from Youtube Analytics API, but it turns out that it returns total views and total likes from all videos, not individually about every video.
`https://youtubeanalytics.googleapis.com/v2/reports?metrics=views,likes,subscribersGained&ids=channel==MINE&startDate=2014-07-03&endDate=2020-06-01&&key=${apiKey}&access_token=${token}`
I read documentation of YouTube Analytics API and I can't find this information there.
If you want the response to be grouped by video your have to specify the dimension parameter to video.
Here is a sample request from the documentation (Basic stats/Top 10 – Most watched videos for a channel):
https://developers.google.com/youtube/analytics/sample-requests#Channel_Reports
Although the note does not specify it, the sort parameter must be the first metric that you declared.
If want to get information on more that 10 videos or to pull information for the latest videos, you can specify the dimension as video and you must specify the video ids in the filter parameter as video==VIDEO1_id,VIDEO2_id....
The videos in a channel can be retrieved through the YouTube Data API from the search endpoint.
You will get a list of videos with their details as a response, among others the videoId and publishedAt values.

Was User Watch History removed in YouTube Data API v3?

If you look at YouTube V3 Docs it will say
YouTube uses playlists to identify special collections of videos for a channel, such as: (...) watch history (...).
Now, if you go to Channels List API and make a call for part=contentDetails&mine=true it will list your information but watchHistory will appear as HL and watchLater as WL.
It makes me wonder, and so far I couldn't find any explicit mention, from Google/YouTube, were those playlists removed from API? IS there any way to actually get that information from an authenticated user?
For quite some time I observed the same values you mentioned on various channels. According to the docs, watch history and watch later playlists are deprecated.

Search youtube channel for specific video id's

I have a large array of video id's. (Over 100) I need to determine which videos belong to the oauth'd user. Looking through the Youtube API docs it doesn't look like they have a way to get videos by ID for a channel. I see how to get all videos for a channel but that looks like it limits the results. Is there an efficient way to do this that I'm missing?
Ideally I'd like to say grab all videos with this id that belong to this channel. I'd accept a way to just get all videos for the users channel so I can compare the array of videos with my array of id's.
Using Laravel socialite and the PHP google api client.
You can either
Get videos by IDs using the videos:list API endpoint. The id parameter takes up to 50 comma-separated videoIDs.
or
Get all videos in a channel using the channels:list API endpoint. The id parameter takes up to 50 comma-separated channelIDs. Each page of results has up to 50 videos.
If you already have the videoIDs, option 1 would be best.
I have figured it out if you want to get the video with particular video id
https://www.youtube.com/watch?v=hcMzwMrr1tE
if you want the thumbnails for the particular video
https://storage.googleapis.com/yt-trends-top-ten-lists-2022/thumbs/**hcMzwMrr1tE**.jpg
put the video id you will get the details you can use google api like this

Sort YouTube Videos by time of upload

I have searched the web tirelessly and looked through the YouTube API, but I still can't seem to find a way in which to request videos from a specific channel which have been uploaded since a certain date-time.
Something along the lines of this:
GET https://www.googleapis.com/youtube/v3/channels?part=videoContent&channel=UC_x5XG1OV2P6uZZ5FSM9Ttw&uploadedAfter=1421056357914
What you'd want to do is to get the channel's uploads playlist, the do a playlistItems.list with it.
Though currently playlistItems.list doesn't support orderBy or uploadedAfter, it's in the works.

Resources