Greeting everyone. I was wondering why some channels don't have a items[] while others do, based on the forUsername parameter. Is it something with the channel itself? Thanks in advance.
Was expecting the Object to have a items[], along with the etag, kind etc.
It is related to the channel itself.
Example:
If you want to check the channel markiplier, for search this channel
using the channels.list endpoint, you have to use the value
markiplierGAME.
URL of the request:
https://developers.google.com/youtube/v3/docs/channels/list?hl=es&apix_params={"part":["id,snippet"],"forUsername":"markiplierGAME","maxResults":50}
Try-it here
Result:
{
"kind": "youtube#channelListResponse",
"etag": "JzsG_zawoWkLOCBSPYcVSSSLTYg",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#channel",
"etag": "vre8w7LGy9EkWyA1AHthYN6UXbw",
"id": "UC7_YxT-KID8kRbqZo7MyscQ",
"snippet": {
"title": "Markiplier",
"description": "Hi, I'm Markiplier. I make videos. \n\nFrom quality content to meme-able garbage, from scary games to full-on interactive movies you'll find it all. You will, actually. I have over 5000 videos so I'm sure there's something you'd like. \n\nMaybe you like horror games, or funny games, or comedy sketches, or animations, or compilations, or reactions, or reviews, or challenges, or cryptic lore, or mind-crippling ennui, or stuff-that-is-guaranteed-to-probably-make-you-cry? Whatever you're into I'm sure there's something for you down in the briny deep of my video page. So why not dive in?\n\nOr don't. Life is yours to choose after all.\n",
"customUrl": "#markiplier",
"publishedAt": "2012-05-26T20:30:52Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AL5GRJVVORzLF5qyUfe9bpQffFSRsNB2OURZrS5237Lrpw=s88-c-k-c0x00ffffff-no-rj",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AL5GRJVVORzLF5qyUfe9bpQffFSRsNB2OURZrS5237Lrpw=s240-c-k-c0x00ffffff-no-rj",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AL5GRJVVORzLF5qyUfe9bpQffFSRsNB2OURZrS5237Lrpw=s800-c-k-c0x00ffffff-no-rj",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Markiplier",
"description": "Hi, I'm Markiplier. I make videos. \n\nFrom quality content to meme-able garbage, from scary games to full-on interactive movies you'll find it all. You will, actually. I have over 5000 videos so I'm sure there's something you'd like. \n\nMaybe you like horror games, or funny games, or comedy sketches, or animations, or compilations, or reactions, or reviews, or challenges, or cryptic lore, or mind-crippling ennui, or stuff-that-is-guaranteed-to-probably-make-you-cry? Whatever you're into I'm sure there's something for you down in the briny deep of my video page. So why not dive in?\n\nOr don't. Life is yours to choose after all.\n"
},
"country": "US"
}
}
]
}
You clearly see the difference between the title of the channel and the supplied value in the forUsername field.
Unfortunately, I don't know if this feature is documented anywhere and for avoid such complications, I rather user the channel_id - which is an unique value.
Related
I've built an app for skiers. The first version of it is in the app stores now. I'd like to add another feature, but I'm not sure it's possible. Hopefully someone here will know.
A favourite pastime of skiers before they go on holiday is finding out what the skiing conditions are like at the resort they are about to visit. Luckily people in the resorts regularly make videos describing the conditions (colloquially known as 'snow reports') and upload them to YouTube and TikTok.
My app has sections for hundreds of ski resorts around the world. Accordingly what I'd like to do is automatically search for and pull these 'snow report' videos and put them in my app, sorted by date posted and the resort they pertain to.
An example might make things clearer. Here is a 'snow report' video for the ski resort of Sauze d'Oulx, posted on 3rd Feb 2023: https://www.youtube.com/watch?v=oT2q-Eu_uNU
I'd like to pull this video into the Sauze d'Oulx section of my app, either by utilising words in the title, or by hashtags if the creator attaches any (in this case the relevant hashtags would be #snowreport and #sauzedoulx).
Can this kind of thing be done?
I haven't tried anything yet.
Concerning searching videos based on:
their title, you can use YouTube Data API v3 Search: list endpoint thanks to q filter and Videos: list endpoint with part=snippet.
their hashtags, I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/search?part=snippet&hashtag=YOUR_HASHTAG, you will get the videos you are looking for in items.
With the hashtag snowreport you would get:
{
"kind": "youtube#searchListResponse",
"etag": "NotImplemented",
"nextPageToken": "4qmFsgKhCRIJRkVoYXNodGFnGvwIQ0R4NndBWkRS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TYVVjMVRsQm1NV1EyTmpSVGExbDNURXhVY25WWFNERTBVMFJCVW1vNU4xOWhXbkJhTjNOcFkydENSMG95T1hRNFVEY3hUMGhDWTJocE4zZFBSSFZvTjNwcWVuZEZXVE5mWmtreVRrZERhMjlvVTBkTGJsUTJZVEpoTTJGUWMwTkNhbEowYzB4UWREVkhUelJqVlVKSFNsQXpOMjl5ZVcwMExXWjVVVVZaZGsxSFVXNWFiazF6TFdOMFIwbDZkSEJLUzFaZlMxQXhWRkpxU21sT1psVnVkaTF3TjFWRldYZHphVUY0V2pKQ00xbGpjVWRQUjJOeFNYbzJOelpsUlZGQ2FtVXpkQzFKYmt4VE1UbFFiMEpIUzB0eWJEaFRYM1JpZG14WlFtbFhhUzFUYW0wNWRVWnNTVVZDNmdVUUNncHpibTkzY21Wd2IzSjBFQUFZQVElM0QlM0SaAhRicm93c2UtZmVlZEZFaGFzaHRhZw==",
"items": [
{
"kind": "youtube#searchResult",
"etag": "NotImplemented",
"id": {
"kind": "youtube#video",
"videoId": "R_a5nsD8TQo"
},
"snippet": {
"channelId": "UCPIHD_lP7798nXNM8YQSk9Q",
"title": "M\u00e9ribel Snow Report (11 January 2023)",
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/R_a5nsD8TQo\/hqdefault.jpg?sqp=-oaymwEiCKgBEF5IWvKriqkDFQgBFQAAAAAYASUAAMhCPQCAokN4AQ==&rs=AOn4CLCbHAQMkFAhGqGsnSELZvsOZVoKwA",
"width": 168,
"height": 94
},
...
],
"channelTitle": "Skipedia",
"channelHandle": null,
"timestamp": "4 weeks ago",
"duration": 137,
"views": 1025,
"badges": [],
"channelApproval": null,
"channelThumbnails": [
{
"url": "https:\/\/yt3.ggpht.com\/ytc\/AL5GRJXLZ5UkDlL2HztSvmhRCb-z3Q47dnga4efZQ_BV=s68-c-k-c0x00ffffff-no-rj",
"width": 68,
"height": 68
}
],
"detailedMetadataSnippet": null,
"chapters": []
}
},
...
]
}
Note that my API supports the pagination mechanism à la YouTube Data API v3.
I want to use the YouTube API to get the snippet of their description. However, I want it to be the primary text snippet describing the video YouTube uses as the snippet, which is different from the data api's response.
Let me give an example to clear things up:
This video will be the demonstration: https://www.youtube.com/watch?v=ADPFEw-7FtU
At the top of this description is the text "Compress Decades Into Days. Get Dan Lok’s World-Class Training Solutions to Grow Your Income, Influence and Wealth Today. Start Here ► [redacted]"
On the YouTube data API search snippet the response is: "Compress Decades Into Days. Get Dan Lok's World-Class Training Solutions to Grow Your Income, Influence and Wealth Today.". This makes sense because they're both at the start of the description. Now this is where I get confused.
If you search the title on YouTube (not the API), you'll actually see that the description is "Have you ever thought of starting an exciting YouTube career on YouTube doing what you love? Or maybe you have started, but ..."
This is the snippet I want. I want their video's "Primary SEO Search Snippet", which describes the video. Is there anyway to calculate this or get this from the API using another method? I don't want to use any non-official API/library to do this.
What this is not:
This is not any caching that has yet to expire/update
Unique to this video. There are plenty of videos where this happens
As far as I know there isn't any official API providing the data you are looking for. Anyway if you change your mind about not using unofficial APIs, then you can proceed as follows by trying out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/search?part=snippet&q=YOUR_QUERY, you will notably get the primary SEO search snippet you are looking for in item["snippet"]["detailedMetadataSnippet"].
For instance with "How To Grow With 0 Views And 0 Subscribers" you would get:
{
"kind": "youtube#searchListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#searchResult",
"etag": "NotImplemented",
"id": {
"kind": "youtube#video",
"videoId": "ADPFEw-7FtU"
},
"snippet": {
"channelId": "UCs_6DXZROU29pLvgQdCx4Ww",
"title": "How To Grow With 0 Views And 0 Subscribers",
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/ADPFEw-7FtU\/hq720.jpg?sqp=-oaymwEjCOgCEMoBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLCKNA5T652tMTvnOw22llDniM9O6Q",
"width": 360,
"height": 202
},
...
],
"channelTitle": "Dan Lok",
"channelHandle": "DanLok",
"timestamp": "3 years ago",
"duration": 887,
"views": 4495095,
"badges": [
"CC"
],
"channelApproval": "Verified",
"channelThumbnails": [
{
"url": "https:\/\/yt3.ggpht.com\/ytc\/AMLnZu_TXnQ07ufj6eGxco9yHndCCcV5KfAizZ9jbI8vmA=s68-c-k-c0x00ffffff-no-rj",
"width": 68,
"height": 68
}
],
"detailedMetadataSnippet": "Have you ever thought of starting an exciting YouTube career on YouTube doing what you love? Or maybe you have started, but\u00a0...",
"chapters": [
{
"title": "Intro",
"time": 0,
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/ADPFEw-7FtU\/hqdefault_25933.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLBVOtOt_jLJd1dRRt5_dj3SlGBtRA",
"width": 336,
"height": 188
}
]
},
...
]
}
},
...
]
}
I wanted to add an answer for anyone trying to do this in 2023 and onwards.
I opened a ticket on the Google Issue Tracker regarding this issue: This was their response.
Hi Conor,
I was able to reproduce this behavior, and also found that neither a search resource description nor a video resource description will display the "Primary SEO Search Snippet" that you are seeking. Thus, I have opened up a feature request with our internal team to request this functionality, but I can't guarantee this feature will be implemented. Thus for updates regarding this, I recommend keeping an eye on our revision history.
You can use the unofficial API as per Benjamin's answer, but unfortunately, that can cause other issues depending on the scale you need to use this feature.
Is it possible to fetch links and email for a channel or a user through API?
I looked at the docs, but could not find it there.
One more time YouTube Data API v3 doesn't provide a basic feature.
I would suggest you to use my open-source YouTube operational API, indeed by requesting https://yt.lemnoslife.com/channels?part=about&id=CHANNEL_ID you would get a JSON with the channel about info (description, stats, details and links) you are looking for in item['about'].
Note that the email can't be retrieved automatically as it is protected by a Google captcha as discussed in this StackOverflow question.
Example of result with the YouTube channel id you shared UCp4DtLatjb5dBNHHYcvVXCw:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "UCp4DtLatjb5dBNHHYcvVXCw",
"about": {
"stats": {
"joinedDate": 1258671600,
"viewCount": "18004212"
},
"description": "FREE Online Piano Lessons, featuring concepts that will greatly assist students in developing a solid and sound technique. Also, this channel features performances by #1 Classical Billboard artist Josh Wright. For questions or video requests, click the link! Josh also offers private online piano lessons through Skype - for more information about how to join his studio, please email him at josh#joshwrightpiano.com",
"details": {
"location": "United States"
},
"links": [
{
"url": "http:\/\/www.joshwrightpiano.com\/contact",
"thumbnail": "https:\/\/encrypted-tbn0.gstatic.com\/favicon-tbn?q=tbn:ANd9GcSI6T1qSJhEF6q1lGXjosLrKLn-8LCOIrI-An-Jq4YgPHlWxdASCMOkA-LB_xpHQyUyaZkglhOVCfhsr6XXlqKwQHIHp9vvDUl-rsS2Q7lHmzuUQTBh1E5qQW6i",
"title": "CLICK TO ASK JOSH A QUESTION"
},
...
{
"url": "https:\/\/plus.google.com\/u\/0\/117288545879529996393\/posts",
"thumbnail": "https:\/\/encrypted-tbn1.gstatic.com\/favicon-tbn?q=tbn:ANd9GcQhmnWcjVxlBhv3BZSHT6S8x7H25cC4vVPKESQba14oYS_WiNOyF2zPPJcHWcseS6lKo4DJ9xWOfAYikH-7n8_VWo9tUcEBHB7It5VEbgYZndFDYgk",
"title": "CLICK TO JOIN JOSH ON GOOGLE+"
}
]
}
}
]
}
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.
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}