//Note:AppsScriptautomaticallyrequestsauthorization//basedontheAPI's used in the code.functionchannelsListByUsername(part,params){varresponse=YouTube.Channels.list(part,params);varchannel=response.items[0];vardataRow=[channel.id,channel.snippet.title,channel.statistics.viewCount];SpreadsheetApp.getActiveSpreadsheet().appendRow(dataRow);}functiongetChannel(){varui=SpreadsheetApp.getUi();varchannelName=ui.prompt("Enter the channel name: ").getResponseText();channelsListByUsername('snippet,contentDetails,statistics',{'forUsername':channelName});}functiongetGoogleDevelopersChannel(){channelsListByUsername('snippet,contentDetails,statistics',{'forUsername':'GoogleDevelopers'});}functiononOpen(){varfirstCell=SpreadsheetApp.getActiveSheet().getRange(1,1).getValue();if(firstCell!='ID'){varheaderRow=["ID","Title","View count"];SpreadsheetApp.getActiveSpreadsheet().appendRow(headerRow);}varui=SpreadsheetApp.getUi();ui.createMenu('YouTube Data').addItem('Add channel data','getChannel').addSeparator().addItem('Add GoogleDevelopers data','getGoogleDevelopersChannel').addToUi();}
왼쪽 상단에서 제목 없는 프로젝트를 클릭하고 시작하기를 입력한 다음 이름 바꾸기를 클릭합니다.
2단계: YouTube Data API 사용 설정
왼쪽에서 편집기code를 클릭합니다.
왼쪽의 '서비스' 옆에 있는 서비스 추가 add를 클릭합니다.
YouTube Data API를 클릭한 다음 추가를 클릭합니다.
3단계: 샘플 실행
스프레드시트를 새로고침합니다. 코드를 추가한 후 스프레드시트를 처음 로드하는 경우 첫 번째 행에 ID, 제목, 조회수 헤더가 채워집니다.
메뉴 바에서 YouTube 데이터 > GoogleDevelopers 데이터 추가를 클릭하여 GoogleDevelopers 채널에 관한 정보를 스프레드시트에 추가합니다.
(YouTube 데이터 메뉴는 표준 메뉴(파일, 수정, 보기 등) 옆에 표시됩니다.)
샘플을 처음 실행하면 액세스 권한을 부여하라는 메시지가 표시됩니다.
권한 검토를 클릭합니다.
계정을 선택합니다.
허용을 클릭합니다.
메뉴 바에서 YouTube 데이터 > 채널 데이터 추가를 클릭하여 원하는 채널의 데이터를 추가합니다. 메시지가 표시되면 채널 이름(예: 'GoogleDevelopers' 또는 'SaturdayNightLive')을 입력하고 확인을 클릭합니다. 스크립트는 해당 채널의 데이터를 가져와 스프레드시트에 추가합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-21(UTC)"],[[["\u003cp\u003eThis guide provides a quickstart for creating a Google Apps Script that interacts with the YouTube Data API to add YouTube channel data to a Google Sheet.\u003c/p\u003e\n"],["\u003cp\u003eThe script retrieves channel ID, title, and view count and populates a spreadsheet with this information, including the ability to add data for a specified channel or the GoogleDevelopers channel.\u003c/p\u003e\n"],["\u003cp\u003eUsers need a Google account, internet access, a web browser, and access to Google Drive to follow the steps and can turn on the YouTube Data API directly within the Apps Script editor.\u003c/p\u003e\n"],["\u003cp\u003eThe guide offers a method to run a sample script, which first prompts for authorization, then allows the user to select from a menu to add data either for the GoogleDevelopers channel or for a custom-selected channel.\u003c/p\u003e\n"],["\u003cp\u003eA troubleshooting section is available to help resolve common issues, such as the "[API NAME]" is not defined error, and also provides further reading with documentation on the topic.\u003c/p\u003e\n"]]],["This guide details how to create a Google Apps Script to fetch and add YouTube channel data to a Google Sheet. The script, once set up, can retrieve channel ID, title, and view count. Key actions include: creating a new Google Sheet, pasting provided code into the Apps Script editor, enabling the YouTube Data API service, and running script options to add either GoogleDevelopers channel data or a user-specified channel's data to the sheet.\n"],null,[]]