Get videos from youtube api from channel - youtube

How can i get videos from the youtube channel with duration and views count?
I tried this request:
https://www.googleapis.com/youtube/v3/search?part=snippet%2Cid&channelId=UC4H3KiOO86uiw2fAoZy6NRA&key=YOUR_API_KEY
but response doesn't contains duration/views count. Any ideas? Thx.

That data is not available in the snippet field. Instead, make a second API call to the channels.list() with the video IDs and request the contentDetails and statistics fields in your response. You can find documentation on the video resource here.

Related

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.

I want to get playlist view count with YouTube Data API

I want to get playlist view count with YouTube Data API. But I can't find a way from the YouTube DATA API reference. Please let me know if there is a way to get.
The Playlist endpoint does not return a view count. You need to take those video IDs and make another call to the Videos endpoint to get them using part statistics.

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

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.

Get recommendation videos from youtube api

I need to get some recommended videos for loggined user from youtube api. I am using this request
GET GET https://www.googleapis.com/youtube/v3/activities?part=snippet&home=true&maxResults=50&key={YOUR_API_KEY}
But in response i receive only 4 videos and all the same in every request. So how do i get all recommended videos i want?
You should be able to get the videos from your subscribed channels with that request. You can also try chart=mostpopular for most popular videos.
More info:
http://apiblog.youtube.com/2013/09/what-to-watch-our-apis-can-help.html

Youtube API -likes/views along with the time when it is liked/viewed for a video

Can we get the likes/views along with the time when it is liked/viewed of a particular youtube video using Youtube API
Data API won't give that information. You can only access number and person, not the time piece.

Resources