10

Given a "vanity url" for a channel (e.g. youtube.com/wheelockcollege, which points to youtube.com/wheelockmarketing1), is there a way to retrieve the channel details?

I'm using the new version 3 of the API, with the latest Python package.

Mark Costello
  • 4,334
  • 4
  • 23
  • 26

1 Answers1

19

May be using search first:

GET https://www.googleapis.com/youtube/v3/search?part=snippet&q=wheelockcollege&type=channel&key={YOUR_API_KEY}

and then with the channel id you can get the channel details:

GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UC6ltI41W4P14NShIBHU8z1Q&key={YOUR_API_KEY}

In this case the result is:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"PsChdkLfsD-u3yuH7KChIH1CRFg/fl8vHBnZ66nKyI7QvfTRQchTAAA\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "id": "UC6ltI41W4P14NShIBHU8z1Q",
   "kind": "youtube#channel",
   "etag": "\"PsChdkLfsD-u3yuH7KChIH1CRFg/zyApGa6dWMliWq5iBE5SL4ewNaQ\"",
   "snippet": {
    "channelId": "UC6ltI41W4P14NShIBHU8z1Q",
    "title": "wheelockmarketing1",
    "description": "Since 1888, Wheelock College has been providing a transformational education to students passionate about making the world a better place—especially for children and families.\n\nWhile most of our students elect to work in the helping professions of education, social work, child life, and juvenile justice and youth advocacy, many pursue—and make exceptional contributions to—a wide variety of professions.\n\nAs a highly respected advocate for social policy, Wheelock also helps to shape and strengthen the social systems that positively impact children and families around the globe.",
    "thumbnails": {
     "default": {
      "url": "https://i3.ytimg.com/i/6ltI41W4P14NShIBHU8z1Q/1.jpg?v=4fdf2807"
     }
    }
   },
   "contentDetails": {
    "relatedPlaylists": {
     "likes": "LL6ltI41W4P14NShIBHU8z1Q",
     "favorites": "FL6ltI41W4P14NShIBHU8z1Q",
     "uploads": "UU6ltI41W4P14NShIBHU8z1Q"
    }
   },
   "statistics": {
    "viewCount": "10354",
    "commentCount": "1",
    "subscriberCount": "43",
    "videoCount": "91"
   }
  }
 ]
}

We have a problem if the initial search returns more than one result, but I believe that it is a good strategy :)

Matias Molinas
  • 2,246
  • 15
  • 11
  • I'm already doing this through the search feature with the API, however as you said, multiple results will cause problems. – Mark Costello Nov 28 '12 at 13:44
  • Those "vanity" display names are not necessarily unique, so yes, there is always going to be the chance that multiple results will be returned. That's just a fact of life when searching for something that's not unique. Think of having to search for a Google+ user (or Facebook user...) based on display name—"John Smith" might return thousands of results. – Jeff Posnick Nov 30 '12 at 16:48
  • 1
    @JeffPosnick From your comment, I don't understand how channel links might not be unique? I do understand that "John Smith" will not return a unique result on YouTube, but the channel https://www.youtube.com/johnsmith is unique. It is that specific channel name that I am looking for. – Mark Costello Dec 03 '12 at 21:51
  • Okay, fair enough. Channel links, i.e. URLs, will always uniquely identify a specific channel. YouTube usernames are still part of many channel URLs. The focus in v3 is working with unique channel ids, not YouTube usernames, and the search method Matias mentioned is currently the only way of translating between a YouTube username and a channel id. – Jeff Posnick Dec 05 '12 at 16:51
  • 1
    FYI, we featured this as a our "Stack Overflow Question of the Week" on our YouTube Developers Live show: http://www.youtube.com/watch?v=Y-dY3wRDFo8#t=1794s – Jeff Posnick Dec 05 '12 at 20:22
  • Remember, Youtube Data API V3 is still in an **experimental** phase! – mate64 Jan 16 '13 at 20:17