123

I'm trying to retrive the data from my channel using the YouTube Data API V3.
For that I need my channel ID.
I've tried to find my channel ID from my YouTube account, and I failed in every single way.
If anyone have a single tip for me, I would be incredible glad.

This is the URL that I'm using to retrieve the data:

https://www.googleapis.com/youtube/v3/channels?id=fjTOrCPnAblTngWAzpnlMA&key={YOUR_API_KEY}&part=snippet,contentDetails,statistics

The ID is for the channel ID, and the key, I'm replacing the {YOUR_API_KEY} with my API KEY generated at my Google API console.

My channel ID is not:
- klauskkpm
- klausmachado
- klausmachado@gmail.com
- fjTOrCPnAblTngWAzpnlMA

My channel is: http://www.youtube.com/user/klauskkpm

Peter O.
  • 30,765
  • 14
  • 76
  • 91
klauskpm
  • 2,607
  • 2
  • 17
  • 29

14 Answers14

219

To obtain the channel id you can view the source code of the channel page and find either data-channel-external-id="UCjXfkj5iapKHJrhYfAF9ZGg" or "externalId":"UCjXfkj5iapKHJrhYfAF9ZGg".

UCjXfkj5iapKHJrhYfAF9ZGg will be the channel ID you are looking for.

Lemmings19
  • 1,189
  • 2
  • 22
  • 33
Henry Moshkovich
  • 2,234
  • 2
  • 12
  • 4
  • 5
    @Naveed Ahmad as this answer helps, view(in this case HTML) should not be used, since it's not reliable. They don't offer their HTML versionated or give an API access to it in anyway. To get any YouTube channel id, is wise to use the **mjlescano** answer, which uses the YouTube API. – klauskpm Apr 27 '16 at 18:56
  • 1
    @klauskpm true, since you were looking for your own id, but this answer gets you any channel ID and still does it 3 years later :) – Yevgeniy Jul 15 '16 at 11:19
  • @Yevgeniy, if you read my comment above, I told that it helps, but **mijlescano** answer can provide that using the official API, which is recommended. – klauskpm Jul 15 '16 at 12:25
  • Can you get a channel username using the channel ID? – BigMonkey89WithaLeg Jun 20 '17 at 05:49
  • 17
    You may have to search "externalId" now as I couldn't find anything for "channel-external-id" – Daniel Sep 22 '17 at 06:16
  • 1
    After getting a bunch of YouTube channel ids manually, it looks like `data-channel-external-id` is for older channels (channels that were created *before* a certain date) and `externalId` is for newer channels (channels that were created *after* a certain date). I'm not sure when this "certain date" is, but if one doesn't work for you - try the other one – derekantrican Sep 28 '17 at 04:14
  • This worked well. I did not have YouTube Channel login details for the client & this saved my time. Thank you. – tushonline Jul 25 '18 at 17:19
  • I just tried this on a channel that had the ID `UCW_OAaMdUH3fF00fh8_Koeg`. Their automatic "all uploads" playlist (which you can get to by clicking "play all" on the videos section of the channel) has the ID `UUW_OAaMdUH3fF00fh8_Koeg`. I don't know if it's always the same, but with U vs. C, but it might be. – Fabian Röling Nov 04 '20 at 10:32
  • 2
    This also works: View page source and search ` – TD540 Nov 16 '20 at 07:14
  • Doesn't work for not logged user – Atsuo Sakakihara Mar 12 '22 at 11:50
  • Also works searching on the html for "og:user" then you can get the full url with the respective channel id. – Manoel Stilpen May 27 '22 at 21:32
76

An easy answer is, your YouTube Channel ID is UC + {YOUR_ACCOUNT_ID}. To be sure of your YouTube Channel ID or your YouTube account ID, access the advanced settings at your settings page

And if you want to know the YouTube Channel ID for any channel, you could use the solution @mjlescano gave.

https://www.googleapis.com/youtube/v3/channels?key={YOUR_API_KEY}&forUsername={USER_NAME}&part=id

If this could be of any help, some user marked it was solved in another topic right here.

Asclepius
  • 49,954
  • 14
  • 144
  • 128
klauskpm
  • 2,607
  • 2
  • 17
  • 29
  • I take it that it is not possible to get a channel ID without having an account ID. Is that correct? – mrub May 17 '15 at 07:10
  • The account ID and channel ID can be very similar, taking the UC part. As I've said, you can enter the advanced settings page of your youtube account, or channel, and it will show you both IDs. Each channel/account creates both new channel and account ID. So, they will ever exist. – klauskpm May 18 '15 at 20:48
  • Sorry, I was a bit unclear. I meant without actually having a google or youtube account. – mrub May 27 '15 at 12:02
  • Yes. If your trying to get your Channel ID ou Account ID, and you don't have an account or channel, both will not exist. Still, you can get this information for other channels. There is an example above. – klauskpm May 27 '15 at 21:14
38

This website finds a YouTube Channel ID from its URL:

https://commentpicker.com/youtube-channel-id.php

Asclepius
  • 49,954
  • 14
  • 144
  • 128
Derber Alter
  • 577
  • 4
  • 12
30

You can get the channel ID with the username (in your case "klauskkpm") using the filter "forUsername", like this:

https://www.googleapis.com/youtube/v3/channels?key={YOUR_API_KEY}&forUsername=klauskkpm&part=id

More info here: https://developers.google.com/youtube/v3/docs/channels/list

mjlescano
  • 817
  • 9
  • 13
  • 1
    As heads up for others reading this, it does not always work. See [here](https://stackoverflow.com/questions/62576403/how-to-get-a-youtube-channel-id-from-the-channels-username-which-includes-cyril) and [here](https://stackoverflow.com/questions/37267324/how-to-get-youtube-channel-details-using-youtube-data-api-if-channel-has-custom) – Simone May 26 '22 at 13:45
29

At any channel page with "user" url for example http://www.youtube.com/user/klauskkpm, without API call, from YouTube UI, click a video of the channel (in its "VIDEOS" tab) and click the channel name on the video. Then you can get to the page with its "channel" url for example https://www.youtube.com/channel/UCfjTOrCPnAblTngWAzpnlMA.

kangkyu
  • 4,174
  • 2
  • 30
  • 34
19

I just found the simplest way to find the channel ID of any YouTube channel !!

Step 1: Play a video of that channel.

Step 2: Click the channel name under that video.

Step 3: Look at the browser address bar.

LinuxBabe
  • 359
  • 2
  • 6
8

An alternative to get youtube channel ID by channel url without API:

function get_youtube_channel_ID($url){
  $html = file_get_contents($url);
  preg_match("'<meta itemprop=\"channelId\" content=\"(.*?)\"'si", $html, $match);
  if($match && $match[1])
    return $match[1];
}
Arthur Ronconi
  • 2,032
  • 23
  • 21
6

Channel id with the current youtube version is obtained very easily if you login to YouYube website and select 'My channel'

My channel

Your channel ID will be displayed on the address bar of your browser channel id

Vas Giatilis
  • 1,076
  • 12
  • 15
5

June 2021 edition.

  1. Right click and view page source.
  2. Search for "externalId", the value follows.

Source: comment by Daniel 2017.

Alternative: run this JavaScript in console:

ytInitialData.metadata.channelMetadataRenderer.externalId
Avindra Goolcharan
  • 3,667
  • 1
  • 39
  • 38
3

https://www.youtube.com/account_advanced now provides both channel and user ids. See also https://developers.google.com/youtube/v3/guides/working_with_channel_ids .

3

2017 Update: Henry's answer may be a little off the mark here. If you look for data-channel-external-id in the source code you may find more than one ID, and only the first occurrence is actually correct. Get the channel_id used in <link rel="alternate" type="application/rss+xml" title="RSS" href="https://www.youtube.com/feeds/videos.xml?channel_id=<VALUE_HERE"> instead.

Community
  • 1
  • 1
vitorrrr
  • 70
  • 7
1

To obtain the channel id you can do the following request which gives you the channel id and playlist id.

https://www.googleapis.com/youtube/v3/channels?part=contentDetails%2C+statistics%2Csnippet&mine=true&key={YOUR_API_KEY}

mine parameter means the current authorized user

as u said channel id is perfixed with UC+{your account id} which you get while login, you can use this one also without requesting the above url you can directly call the channel api with your google id and just prefix with UC

https://www.googleapis.com/youtube/v3/channels?part=contentDetails%2C+statistics%2Csnippet&id=UC{your account id}&key={YOUR_API_KEY}

rakesh r
  • 395
  • 2
  • 3
  • 12
1

To get Channel id

Ex: Apple channel ID

enter image description here

Select any of the video in that channel

enter image description here

Select iPhone - Share photos (video)

Now click on channel name Apple bottom of the video.

enter image description here

Now you will get channel id in browser url

enter image description here

Here this is Apple channel id : UCE_M8A5yxnLfW0KghEeajjw

Naresh
  • 14,724
  • 6
  • 94
  • 103
1

Try to search for regular expression UC[-_0-9A-Za-z]{21}[AQgw] in source code. This ID is presented even if channel has non-ASCII characters in URL:

enter image description here

Here is screenshot of internal viewer/editor of Midnight Commander, it has regexp search:

enter image description here

shoorick
  • 131
  • 3