I have two channels examples:
https://www.youtube.com/channel/UC56eaiucsjSfKgevcaGcn2w => real sub 150k
https://www.youtube.com/channel/UC-2Zibu3OGJdIisYaODXhbQ => real sub 208k
This is what was returned from the Channels list endpoint:
{
"kind": "youtube#channelListResponse",
"etag": "wVkhi3RvF1ayB9ou0W6KZcanGZE",
"pageInfo": {
"totalResults": 2,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "QI30osPYB_sy-uwNipgDhEPKRso",
"id": "UC56eaiucsjSfKgevcaGcn2w",
"statistics": {
"viewCount": "17359612",
"subscriberCount": "320",
"hiddenSubscriberCount": false,
"videoCount": "26"
}
},
{
"kind": "youtube#channel",
"etag": "IjATUKKNgPUxmtHQWicg_r22hqc",
"id": "UC-2Zibu3OGJdIisYaODXhbQ",
"statistics": {
"viewCount": "1723670",
"subscriberCount": "18",
"hiddenSubscriberCount": false,
"videoCount": "1"
}
}
]
}
When you go to the links above, and navigate through the channel, I noticed that the channel Id changes and the API returns the correct sub count for the new Id.
I am unsure how a unique video Id can be linked to more than one channel, What kind of channels are these? merged, linked, or something else? and how does the user do this?
"click on the same link you gave me, then click on the first video" there isn't any video on my side. Using PlaylistItems: list with the channel uploads playlist I get 26 videos and the first one is hVyJsXCXyuo. Even if all retrieved videos are unavailable, for the first video I indeed see that the channel real subscribers count is 150k and if I click on the channel name I get redirected to another channel that is UC4LyPYXnF07KF97Nb8vE_Pg which indeed has 150k subscribers.
Then you can use Channels: list to get the correct subscriber count using id=UC4LyPYXnF07KF97Nb8vE_Pg cf https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UC4LyPYXnF07KF97Nb8vE_Pg&key=YOUR_API_KEY
Note that under a video the channel id you are redirected to seems to differ if you click on the channel avatar or the channel name on a desktop. The following redirection are done if you are on a phone or a computer and if you click on the channel avatar or channel name:
Phone:
Name: UC56eaiucsjSfKgevcaGcn2w
Avatar: UC56eaiucsjSfKgevcaGcn2w
Computer:
Name: UC4LyPYXnF07KF97Nb8vE_Pg
Avatar: UC56eaiucsjSfKgevcaGcn2w
Related
There is an answer that describes how to fetch all videos from a YouTube channel here. However, in many cases, the parent account is not a channel per se, but something similar (like this is a channel, as evidenced by the "channel" word in the URL, while this one is not, since it has a keyword "c" in the URL, and not "channel"). I can still get playlists from it, and get all videos from individual playlist in that WWE account, but there are many videos in that account that are not part of any playlist listed in the account, like this).
Question - Is there a way to get all videos from an account, not just a channel or a playlist? Or is there any way to get default playlist/channel from an account where all unlisted videos such as above can be found?
Edit (15/03/2022):
I've found that the video_id = eJjbnFZ6yA8 is on the "uploads" playlist and it's in the position # 7765.
You can try to get the position in the given playlist by making this query:
https://content-youtube.googleapis.com/youtube/v3/playlistItems?maxResults=50&playlistId=<UPLOADS_PLAYLIST_ID>&videoId=<VIDEO_ID_YOU_WANT_TO_GET>&part=id,snippet,contentDetails,status&key=[YOUR_API_KEY]
These are the results of the video_id = eJjbnFZ6yA8:
URL:
https://content-youtube.googleapis.com/youtube/v3/playlistItems?maxResults=50&playlistId=UUJ5v_MCY6GNUBTO8-D3XoAg&videoId=eJjbnFZ6yA8&key=[YOUR_API_KEY]&part=id,snippet,contentDetails,status
Response:
{
"kind": "youtube#playlistItemListResponse",
"etag": "SyO-_mevTIc8xX7G8QA0JKcgwTE",
"items": [
{
"kind": "youtube#playlistItem",
"etag": "70IgC85z_68I9jCkp4Jwuwo_pO8",
"id": "VVVKNXZfTUNZNkdOVUJUTzgtRDNYb0FnLmVKamJuRlo2eUE4",
"snippet": {
"publishedAt": "2020-12-27T21:05:54Z",
"channelId": "UCJ5v_MCY6GNUBTO8-D3XoAg",
"title": "FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999",
"description": "Mankind looks to make his dream come true when he challenges The Rock for the WWE Championship on the first Raw of 1999: Courtesy of WWE Network.\nWWE Network | Subscribe now: http://wwe.yt/wwenetwork\r\n---------------------------------------------------------------------\r\nFollow WWE on YouTube for more exciting action!\r\n---------------------------------------------------------------------\r\nSubscribe to WWE on YouTube: http://wwe.yt/\r\nCheck out WWE.com for news and updates: http://goo[.]gl/akf0J4\r\nWatch WWE on Sony in India: http://www.wwe.com/SonySportsNetwork\r\nFind the latest Superstar gear at WWEShop: http://shop.wwe.com\r\n---------------------------------------------\r\nCheck out our other channels!\r\n---------------------------------------------\r\nThe Bella Twins: https://www.youtube.com/thebellatwins\r\nUpUpDownDown: https://www.youtube.com/upupdowndown\r\nWWEMusic: https://www.youtube.com/wwemusic\r\nTotal Divas: https://www.youtube.com/wwetotaldivas\r\n------------------------------------\r\nWWE on Social Media\r\n------------------------------------\r\nTwitter: https://twitter.com/wwe\r\nFacebook: https://www.facebook.com/wwe\r\nInstagram: https://www.instagram.com/wwe/\r\nReddit: https://www.reddit.com/user/RealWWE\r\nGiphy: https://giphy.com/wwe\r\n------------------------------------\r\nWWE Podcasts\r\n------------------------------------\r\nAfter the Bell with Corey Graves: https://wwe.com/afterthebell\r\nThe New Day: Feel the Power: https://wwe.com/feelthepower\r\nUncool with Alexa Bliss: https://wwe.com/uncoolwithalexa",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "WWE",
"playlistId": "UUJ5v_MCY6GNUBTO8-D3XoAg",
"position": 7765,
"resourceId": {
"kind": "youtube#video",
"videoId": "eJjbnFZ6yA8"
},
"videoOwnerChannelTitle": "WWE",
"videoOwnerChannelId": "UCJ5v_MCY6GNUBTO8-D3XoAg"
},
"contentDetails": {
"videoId": "eJjbnFZ6yA8",
"videoPublishedAt": "2021-01-04T16:00:08Z"
},
"status": {
"privacyStatus": "public"
}
}
],
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 50
}
}
Initial response (17/02/2022):
That's a odd result, IMHO. You can follow any of these steps:
Get all playlists from a given channel and loop every video in every playlist obtained and compare to the video_id you want to check if it belongs to any playlist found.
If the video is not found in any playlist, probably is due the video itself does not belong to any created playlist, but, rather, to the "Uploads" playlist of the owner channel.
For check the last point I mentioned in my comment and in this answer, you can follow these steps:
Replace the second character of the channel_id from "C" to "U". Example: channel_id: UCJ5v_MCY6GNUBTO8-D3XoAg - once modified, the result is: UUJ5v_MCY6GNUBTO8-D3XoAg = this is the "Upload" playlist_id of the channel UCJ5v_MCY6GNUBTO8-D3XoAg.
With the upload playlist_id, paste it in this URL: https://www.youtube.com/playlist?list=<UPLOAD_PLAYLIST_ID_OF_THE_CHANNEL>
Result:
https://www.youtube.com/playlist?list=UUJ5v_MCY6GNUBTO8-D3XoAg
Then, you can yield the default "uploads" playlist of the given channel and their videos in it.
N.B that some videos (including probably the video_id you supplied) might not appear in any playlist, for example, when entering to the "upload playlist" sample (i.e. https://www.youtube.com/playlist?list=UUJ5v_MCY6GNUBTO8-D3XoAg), you might get this message above the playlist itself:
Unavailable videos are hidden.
In this case, might be worth it use the YouTube Data API to query the videos in UUJ5v_MCY6GNUBTO8-D3XoAg playlist or double-check if the video in subject in you region is available - in my case, Colombia, I got the message mentioned above, but, probably this wont happen in the US or UK.
I'm trying to get a list of the most popular videos for certain video categories, however some categories return an empty list of videos despite the response being successful.
For example, the News & Politics category (ID 25):
I get the same response when making this request from my app. The category ID is valid and correct (as obtained from /youtube/v3/videoCategories). Changing the regionCode doesn't make a difference.
It's really important for the functionality of my app that a list of popular/recent/noteworthy videos for particular categories are shown. If there's no way to get the above request to return some videos, is there some kind of workaround that would return appropriate videos for the troublesome categories?
This looks like a bug to me
I tested it in the apis-explorer
Testing request 1:
Without category. test here scroll down there are some with nr 25
Request
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=50®ionCode=us&fields=items%2Fsnippet%2FcategoryId&key={YOUR_API_KEY}
Response
{
"kind": "youtube#videoListResponse",
"etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 50
},
"items": [
"snippet": {
"categoryId": "25"
}
......
]
}
but as soon as you add the catagori id it returns 0
Test 2 fun results
A fun thing i found in my testing is if i add a category id of 10 link
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&maxResults=50®ionCode=us&videoCategoryId=10&fields=items%2Fsnippet%2FcategoryId&key={YOUR_API_KEY}
it returns others as well.
{
"items": [
{
"snippet": {
"categoryId": "24"
}
},
{
"snippet": {
"categoryId": "10"
}
},
{
"snippet": {
"categoryId": "10"
}
I would submit a bug report. issue forum
is there Youtube API support to retrieve my statistics like if I watched it or not, how many times I played it or retrieve my view history? I spend some time going thru the Youtube Data API but no luck.
You can use YouTube API - ViewCount to retrieve the number of times the video has been viewed. You can retrieve the information in the client side or in the server side using some of the libraries.
You need to retrieve the video, from there you can retrieve the statistics part contains the viewCount
Sample request:
GET https://www.googleapis.com/youtube/v3/videos?part=statistics&id=Q5mHPo2yDG8&key={YOUR_API_KEY}
Response:
200 OK
- Show headers -
{
"kind": "youtube#videoListResponse",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/dZ8K81pnD1mOCFyHQkjZNynHpYo\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"id": "Q5mHPo2yDG8",
"kind": "youtube#video",
"etag": "\"g-RLCMLrfPIk8n3AxYYPPliWWoo/4NA7C24hM5mprqQ3sBwI5Lo9vZE\"",
"statistics": {
"viewCount": "36575966",
"likeCount": "127569",
"dislikeCount": "5715",
"favoriteCount": "0",
"commentCount": "20317"
}
}
]
}
Until now I've been using this URL to retrieve subscriber count for a channel:
http://gdata.youtube.com/feeds/api/users/<channel_id>?v=2&alt=json
And this URL to get channel videos count:
https://gdata.youtube.com/feeds/api/users/<channel_id>/uploads?v=2&alt=jsonc&max-results=0
But from this day Google discontinued using it's v2 API and I can't find replacement options for this data.
You're going to want to use the Channels/list endpoint as pass in statistics for the part parameter.
Request:
HTTP GET: GET https://www.googleapis.com/youtube/v3/channels?part=statistics&id={CHANNEL_ID}&key={YOUR_API_KEY}
Response (with id=UCt7iVnJwjBsof8IPLJHCTgQ):
{
"kind": "youtube#channelListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WNxXCvycTyqTjTn9sLJ5toVjBRY\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/jijTuA_iWn2Kv9aRnqeAWNAcQ6I\"",
"id": "UCt7iVnJwjBsof8IPLJHCTgQ",
"statistics": {
"viewCount": "796662",
"commentCount": "20",
"subscriberCount": "257",
"hiddenSubscriberCount": false,
"videoCount": "126"
}
}
]
}
You can pass in a comma-separated list of Channel IDs for the id parameter. Because I only passed in one id, the first object of the items array will have the values you need. Get the object for the subscriberCount and videoCount values in the statistics dictionary for the data you want.
I'm trying to use the Youtube Analytics API to gather daily view counts for all the videos in my channel. It seems like the video dimension throttles the result at top 10 only. Is there anyway I could get daily view count for all my videos?
At the moment you cannot get metrics for all videos via Analytics API directly. First you need to fetch the ids of all your videos and then request Analytic's data for each. I managed it this way:
Get the playlist ID for your uploaded videos via Data API https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&maxResults=25&access_token=[TOKEN]. Gives you this result:
{
"kind": "youtube#channelListResponse",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/SAGx1pv6myGXge51dmywGW81h8o\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/g5zJtodBJms3CAfwF_ar2nVgJjU\"",
"id": "[id]",
"contentDetails": {
"relatedPlaylists": {
"likes": "[id]",
"favorites": "[id]",
"uploads": "[id]",
"watchHistory": "[id]",
"watchLater": "[id]"
},
"googlePlusUserId": "[id]"
}
}
]
}
Get all ids of your uploaded videos with the upload playlist id via Data API: https://www.googleapis.com/youtube/v3/playlistItems?part=id&pageToken=&playlistId=[UPLOADID]&maxResults=50&access_token=[TOKEN]. Note: You have to page through the results with nextPageToken.
With the collected video ids you can make a batch request to the Analytics API https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel==mine&start-date=2014-12-29&end-date=2015-01-05&metrics=views,likes&dimensions=video,day&filters=video==[videoId],[videoId],[videoId],[...]&sort=video&access_token=[TOKEN] Note: You can batch up to 200 Video Ids.