In the list of APIs, find the YouTube Analytics API and change its status to ON.
Familiarize yourself with YouTube Analytics. If you haven't used YouTube Analytics before, log in to YouTube and try the YouTube Analytics user interface before you start coding.
Read the authentication guide to learn how to implement OAuth 2.0 authorization. All API requests must be authorized, and users may only retrieve reports for their own content.
Review the Reports page for general information about the types of reports that are available and for information about quota usage. Then review the documents explaining channel reports and content owner reports for details about the data that you can retrieve and your options for aggregating that data.
Read the API Reference Guide to understand the API response format. In that document, the definition of the ids parameter, which is a required parameter for all API requests, explains how to identify the API user for whom you are retrieving Analytics data.