how to map youtube handles to channel IDs - youtube

Youtube recently rolled out handles feature where they gave users youtube.com/#xxx type usernames, when visited these URLs show user's channel but I can't find any documentation or reference in API repositories.
How to extract youtube user channel ID from their handle?

One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?handle=#HANDLE you will get the YouTube channel id you are looking for in item["id"].
For instance with the YouTube channel handle #WHO, you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UC07-dOwgza1IguKA86jqxNA"
}
]
}

Related

How to get a User's Youtube handle after they sign in with Google?

Is there an API to retrieve a user's Youtube handle as of today?
cannot find anything in Youtube Data API doc.
One more time YouTube Data API v3 doesn't provide a basic feature. As handle isn't found for channel handles in YouTube Data API v3 revision history, while it's a recent feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?part=about&id=CHANNEL_ID, you will get the channel handle you are looking for in item["about"]["handle"].
For instance for UCQxJsAlqmBPAbR_0syDi9mg you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UCQxJsAlqmBPAbR_0syDi9mg",
"about": {
...
"handle": "#Fairphone"
}
}
]
}

Retrieve the subscribers id who watched video

Overall Goal: To report possible subscribers who are not active on my YouTube channel.
I'm reading through the YouTube Data API (v3) trying to understand how to retrieve the actual ids who watched a specific video. I know you can get the number of views, but I don't see any call/response that shows you the subscriber ids. Has anyone done this?
So far what I gathered from the docs and Google searching is that this was possible using the Watch History of a subscriber, but that's been deprecated.
Thanks in advance!
So I do not believe it's possible to get IDs of users who have watched certain videos but I have a workaround for my use case; reporting inactive subscribers. This is not the best but it'll get me somewhere.
YouTube's API is very limiting now, but by calling the Subscriptions API
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mySubscribers=true&key=[YOUR_API_KEY]
I am able to get all subscribers with their channel IDs. Then after saving their IDs, I can check each one's statistics by making this call:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[SUB_ID]&key=[YOUR_API_KEY]
which I receive a response like this:
{
"kind": "youtube#channelListResponse",
"etag": "\"j6xRRd8dTPVVptg711_CSPADRfg/AZpZT_vQrY3UTi57ia_QqrKdc8c\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"something\"",
"id": "[SUB_ID]",
"statistics": {
"viewCount": "0",
"commentCount": "0",
"subscriberCount": "1",
"hiddenSubscriberCount": false,
"videoCount": "0"
}
}
]
}
Using this response (see "statistics"), I am making a generalization that if the subscriber has no comments AND no videos, then it's a safe bet that they are not active.

How to detect official artist channel using youtube api?

How to detect is it official artist channel or not, using youtube api? Official channel has special label next to title, like this one https://www.youtube.com/channel/UCBQZwaNPFfJ1gZ1fLZpAEGw, but it doesn't appear in title from api.
One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?part=approval&id=CHANNEL_ID, you will get whether or not the given channel is an official artist in item["approval"] by checking if this value is Official Artist Channel.
For instance the YouTube channel UC0aMaqIs997ggjDs_Q9UYiw is an official artist channel, with this channel id you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UC0aMaqIs997ggjDs_Q9UYiw",
"approval": "Official Artist Channel"
}
]
}

YouTube Data API channels list returning no results for valid Channel ID

I'm attempting to access https://www.youtube.com/channel/UC7LoiySz7-FcGgZCKBq_2vQ via the YouTube Data API v3 however am not able to load channel by id:
https://content.googleapis.com/youtube/v3/channels?part=snippet&id=UC7LoiySz7-FcGgZCKBq_2vQ&key=<omitted>
{
"kind": "youtube#channelListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/Rk41fm-2TD0VG1yv0-bkUvcBi9s\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": []
}
other channels that this same error occurs for:
https://www.youtube.com/channel/UCzwNZaQ2qyZw0n3xOSNoXaQ
https://www.youtube.com/channel/UC0iFwqagVPP6pXiDwYU170g
Your channels are of type hidden. This is the expected outcome. Unhide it and work your way from there.
Delete or hide your YouTube channel:
You can hide content from your YouTube channel and choose to re-enable
it later. When you hide content, your channel name, videos, likes,
subscriptions, and subscribers will be made private.
All your comments and replies will be permanently deleted. Your
account data on other Google properties will not be removed.
One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?part=status&id=CHANNEL_ID, you will get the YouTube channel status message you are looking for in item["status"].
For instance with this channel id UC7LoiySz7-FcGgZCKBq_2vQ you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UC7LoiySz7-FcGgZCKBq_2vQ",
"status": "This channel is not available."
}
]
}
For a suspended YouTube channel such as UCF_UozwQBJY4WHZ7yilYkjA, you would get for status: "This account has been terminated due to multiple or severe violations of YouTube's policy on nudity or sexual content.".
For a normal channel, such as UC4QobU6STFB0P71PMvOGN5A, you would get for status: null.

What is difference of "Posted video" and "Uploads" in YouTube Channel? And how to get them through YouTube Data v3 API?

I am in the middle of developing a YouTube client using YouTube Data v3 API, and is playing with two different channels observed:
Go Pro Channel: https://www.youtube.com/user/GoProCamera/videos
YouTube curated Sports Channel: https://www.youtube.com/channel/UCEgdi0XIXXZ-qJOFPf4JSKw/videos
In Go Pro channel, I can also choose a video filter: "Uploads", "Liked" and "Posted Videos". I am much puzzled by the "Uploads" and "Posted Videos" filter, which from my observation, on this channel, they are giving the same result. But in YouTube curated sports channel, there is only "Posted Video" option there.
For the past hours, I can not find any definitive explanation from YouTube v2/v3's API documentation, and what is more bothering me is, I can not find any API to retrieve the video entry data in those channels.
For Go Pro Channel, I could at least rely on the method mentioned here to get uploaded video: How do I get a list of uploaded videos for a certain channel with the new YouTube Data API (V3)?
But for curated channels, even this method does not work, the playlist given in channel query result is always empty:
Request
GET https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2Csnippet&id=UCEgdi0XIXXZ-qJOFPf4JSKw&key={YOUR_API_KEY}
Authorization: Bearer ya29.dwCMU6xpf5N9AxwAAABgIM94lgv7jGHw0h0oEjs6uZUdPFO28CDYhbvgXdKTjw
X-JavaScript-User-Agent: Google APIs Explorer
Response
200 OK
- Show headers -
{
"kind": "youtube#channelListResponse",
"etag": "\"WFPuK6TsnblcGPcnMex79s42ynQ/qpdedwjxXQ-COrk0dODO-8DTAx0\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"WFPuK6TsnblcGPcnMex79s42ynQ/TP96YXZ0G4VPdQ7fd2IYgW79rW0\"",
"id": "UCEgdi0XIXXZ-qJOFPf4JSKw",
"snippet": {
"title": "Sports",
"description": "Sport is all forms of usually competitive physical activity which, through casual or organised participation, aim to use, maintain or improve physical ability and skills while providing entertainment to participants, and in some cases, spectators. Hundreds of sports exist, from those requiring only two participants, through to those with hundreds of simultaneous participants, either in teams or competing as individuals. Sport is generally recognised as activities which are based in physical athleticism or physical dexterity, with the largest major competitions such as the Olympic Games admitting only sports meeting this definition, and other organisations such as the Council of Europe using definitions precluding activities without a physical element from classification as sports. However, a number of competitive, but non-physical, activities claim recognition as mind sports.\nThis channel was generated automatically by YouTube's video discovery system.",
"publishedAt": "2013-12-15T20:39:04.000Z",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/1.jpg"
},
"medium": {
"url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/mq1.jpg"
},
"high": {
"url": "https://i.ytimg.com/i/Egdi0XIXXZ-qJOFPf4JSKw/hq1.jpg"
}
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "LLEgdi0XIXXZ-qJOFPf4JSKw",
"uploads": "UUEgdi0XIXXZ-qJOFPf4JSKw"
}
}
}
]
}
--
Request
GET https://www.googleapis.com/youtube/v3/playlistItems?part=id%2CcontentDetails%2Csnippet&playlistId=UUEgdi0XIXXZ-qJOFPf4JSKw&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
Response
200 OK
- Show headers -
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"WFPuK6TsnblcGPcnMex79s42ynQ/0ky7gu-r2KEON6-qkmzKhU77B-Q\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
It seems to me this is a dead end now, so is there any way to get videos from this kind of curated channels?
If you've already got the channel ID of the curated channel, you can just use the search endpoint to get the videos; for example, this API call will receive the 50 most recent videos added to YouTube's sports channel:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCEgdi0XIXXZ-qJOFPf4JSKw&maxResults=50&order=date&key={YOUR_API_KEY}

Resources