YouTube에서 Shorts 동영상의 조회수를 집계하는 방식에 맞게 Data API를 업데이트하고 있습니다.
자세히 알아보기
채널 ID 사용
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
제프 포스닉, YouTube 개발자 관계팀 – 2013년 6월
1년 넘게 Google+ 프로필을 YouTube 채널에 연결할 수 있었으며, 프로필 연결의 결과 일부 Data API v2 응답이 어떻게 변경되었는지 블로그에 게시했습니다. 최근에는 기존 YouTube 사용자 이름이 연결되지 않고 Google+ 프로필로만 식별되는 새 YouTube 채널을 만들 수 있게 되었습니다. 이 블로그 게시물의 대부분의 정보는 여전히 적용되지만, 이 추가적인 문제로 인해 YouTube 채널에 대한 몇 가지 기본 가정(예: 각 채널이 항상 고유한 YouTube 사용자 이름과 연결된다)이 무효화됩니다. 이에 따라 모든 유형의 채널에서 작동하는 코드를 작성하기 위한 몇 가지 추가 권장사항을 안내하고자 합니다.
Data API v2의 채널 ID
참고: YouTube Data API (v2)는 2014년 2월 26일부터 지원 중단되었으며 API가 사용 중지되었습니다. 아직 v2 API를 사용하는 애플리케이션은 즉시 v3 API로 이전해야 합니다.
이전 Data API v2를 사용하는 개발자에게 가장 중요한 점은 모든 YouTube 채널에 고유한 사용자 이름이 있는 것은 아닙니다. 다행히 모든 YouTube 채널에는 고유한 채널 ID가 연결되어 있으며, 이 ID는 <yt:channelId>
태그의 값으로 표시됩니다. 개발자는 이 값을 사용자 이름 대신 사용하는 것이 좋습니다. 예를 들어 YouTube 사용자 이름을 해당 채널에 대한 정보에 매핑하는 데이터베이스가 있는 경우 이전 항목이 계속 작동합니다. 기존 채널의 사용자 이름은 삭제되지 않습니다. 하지만 시간이 지남에 따라 사용자 이름으로 고유하게 식별할 수 없는 채널로 작업해야 할 경우가 많아집니다.
사용자 이름에서 채널 ID로 전환하는 방법은 다음과 같이 몇 가지 요인에 따라 간소화됩니다. 첫째, Data API v2는 YouTube 사용자 이름을 허용하는 모든 곳에서 요청 URL의 채널 ID를 허용합니다. 즉, 채널 ID를 기존 코드로 원활하게 전환할 수 있습니다. 예를 들어 UC_x5XG1OV2P6uZZ5FSM9Ttw
는 기존 사용자 이름이 GoogleDevelopers
인 채널의 채널 ID이므로 다음 두 URL은 동일한 API 요청입니다.
https://gdata.youtube.com/feeds/api/users/GoogleDevelopers?v=2.1
https://gdata.youtube.com/feeds/api/users/UC_x5XG1OV2P6uZZ5FSM9Ttw?v=2.1
인증된 v2 요청을 할 때마다 요청 URL을 구성할 때 승인된 채널의 사용자 이름을 포함할 필요가 없습니다. 사용자 이름 (또는 채널 ID) 대신 항상 default
값을 사용할 수 있습니다. 예를 들어 현재 승인된 사용자의 동영상 업로드 피드를 가져오려면 https://gdata.youtube.com/feeds/api/users/default/uploads?v=2.1
에서 가져오면 됩니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-11-23(UTC)
[null,null,["최종 업데이트: 2024-11-23(UTC)"],[[["\u003cp\u003eYouTube channels can now be identified solely by their Google+ profile, without a traditional YouTube username.\u003c/p\u003e\n"],["\u003cp\u003eThe YouTube Data API v3 exclusively uses channel IDs to identify channels, offering consistency for channels with or without legacy usernames.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the \u003ccode\u003echannels.list\u003c/code\u003e method in v3 to retrieve a channel ID based on the authorized user or a legacy username.\u003c/p\u003e\n"],["\u003cp\u003eIn v2, it's crucial to recognize that not every YouTube channel has a unique username, but all have a unique channel ID, which is the recommended identifier.\u003c/p\u003e\n"],["\u003cp\u003eThe deprecated Data API v2 can use channel IDs in place of usernames in request URLs, and \u003ccode\u003edefault\u003c/code\u003e can be used instead of usernames for authenticated v2 requests.\u003c/p\u003e\n"]]],["YouTube introduced channels solely identified by Google+ profiles, lacking traditional usernames. Data API v3 exclusively uses channel IDs to identify channels, simplifying the process for developers. To get the authorized user's channel ID, use `channels.list(part=\"id\", mine=true)`. To translate a username to a channel ID, use `channels.list(part=\"id\", forUsername=\"username\")`. For display names, use `search.list(part=\"snippet\", type=\"channel\", q=\"display name\")`. Data API v2, now deprecated, also utilizes channel IDs, allowing them to replace usernames in requests.\n"],null,["# Work with Channel IDs\n\n*Jeff Posnick, YouTube Developer Relations -- June 2013*\nFor more than a year, it's been possible to link Google+ profiles with YouTube channels, and we've [blogged](http://apiblog.youtube.com/2012/03/youtube-google-api-and-you.html) about how some of the Data API v2 responses have changed as a result of that profile link. More recently, it has become possible to create new YouTube channels that don't have a traditional YouTube username associated with them and, instead, are [solely identified by their Google+ profile](http://youtubecreator.blogspot.com/2013/04/using-google-page-identity-on-youtube.html). Much of the information from that blog post still applies, but this extra wrinkle does invalidate some fundamental assumptions about YouTube channels -- like that each one will always be associated with a unique YouTube username -- and we wanted to follow up with some additional best practices to write code that works with all flavors of channels.\n\nChannel IDs in the Data API v3\n------------------------------\n\nAll v3 operations that work with channels use [channel IDs](/youtube/v3/docs/channels#id) exclusively as a means of identifying those channels. The ID for a specific YouTube user's channel is identical in both v2 and v3 of the API, simplifying migrations between versions. This complete reliance on channel IDs might be perplexing for developers who were previously used to passing YouTube usernames to API methods, but v3 was designed to treat channels with and without legacy usernames identically, and that means using channel IDs everywhere.\n\nIf you are using v3 and want to retrieve the channel ID that corresponds to the currently authorized user, you can call the [channels.list(part=\"id\", mine=true)](https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=id&mine=true) method. This is equivalent to asking for the channel profile of the `default` user in v2.\n\nIf you ever do find yourself with an arbitrary legacy YouTube username that you need to translate into a channel ID using v3 of the API, you can make a [channels.list(part=\"id\", forUsername=\"\u003cvar class=\"apiparam\" translate=\"no\"\u003eusername\u003c/var\u003e\")](https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=id&forUsername=YouTubeDev) call to the API.\n\nIf you only know a display name and are looking to find the corresponding channel, the [search.list(part=\"snippet\", type=\"channel\", q=\"\u003cvar class=\"apiparam\" translate=\"no\"\u003edisplay name\u003c/var\u003e\")](https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&q=YouTube+for+Developers&type=channel) method will come in handy. You should be prepared to deal with the possibility of the call returning more than one item in the response, since display names are not unique.\n\nChannel IDs in the Data API v2\n------------------------------\n\n**Note:** The YouTube Data API (v2) has been deprecated since February 26, 2014, and the API has been [turned down](http://youtube-eng.blogspot.com/2015/04/bye-bye-youtube-data-api-v2.html). Applications still using the v2 API should migrate to the v3 API immediately.\n\nThe biggest takeaway for developers using the older [Data API v2](/youtube/2.0/developers_guide_protocol_audience) is that you must be aware that **not every YouTube channel has a unique username** . Fortunately, every YouTube channel is guaranteed to have a unique channel ID associated with it, represented by the value in the [`\u003cyt:channelId\u003e` tag](/youtube/2.0/reference#youtube_data_api_tag_yt:channelId), and that's the value that we recommend developers use instead of usernames. For instance, if you have a database that maps YouTube usernames to information about that channel, your older entries should continue to work. (Existing channels won't lose their usernames.) However, as time goes on, it will become more and more likely that you'll have to work with channels that can't be uniquely identified by a username.\n\nA couple of factors simplify the transition from usernames to channel IDs. First, the Data API v2 accepts channel IDs in request URLs wherever it accepts YouTube usernames, meaning that you can seamlessly swap a channel ID into your existing code. For example, since `UC_x5XG1OV2P6uZZ5FSM9Ttw` is the channel ID for the channel with the legacy username `GoogleDevelopers`, the following two URLs are equivalent API requests: \n\n https://gdata.youtube.com/feeds/api/users/GoogleDevelopers?v=2.1\n https://gdata.youtube.com/feeds/api/users/UC_x5XG1OV2P6uZZ5FSM9Ttw?v=2.1\n\nAnother thing to keep in mind is that whenever you're making [authenticated](/youtube/2.0/developers_guide_protocol_authentication) v2 requests, you never need to include the authorized channel's username when constructing request URLs. You can always use the value `default` in place of a username (or channel ID). So if you want to retrieve the video uploads feed for the currently authorized user, for instance, you can do so at `https://gdata.youtube.com/feeds/api/users/default/uploads?v=2.1`."]]