TypeScript typings for YouTube Analytics API v2
Retrieves your YouTube Analytics data.
For detailed description please check documentation.
Installing
Install typings for YouTube Analytics API:
npm install @types/gapi.client.youtubeanalytics@v2 --save-dev
Usage
You need to initialize Google API client in your code:
gapi.load('client', () => {
});
Then load api client wrapper:
gapi.client.load('youtubeanalytics', 'v2', () => {
});
Don't forget to authenticate your client before sending any request to resources:
var client_id = '',
scope = [
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtubepartner',
'https://www.googleapis.com/auth/yt-analytics-monetary.readonly',
'https://www.googleapis.com/auth/yt-analytics.readonly',
],
immediate = true;
gapi.auth.authorize(
{ client_id: client_id, scope: scope, immediate: immediate },
authResult => {
if (authResult && !authResult.error) {
} else {
}
});
After that you can use YouTube Analytics API resources:
await gapi.client.youtubeanalytics.groupItems.delete({ });
await gapi.client.youtubeanalytics.groupItems.insert({ });
await gapi.client.youtubeanalytics.groupItems.list({ });
await gapi.client.youtubeanalytics.groups.delete({ });
await gapi.client.youtubeanalytics.groups.insert({ });
await gapi.client.youtubeanalytics.groups.list({ });
await gapi.client.youtubeanalytics.groups.update({ });
await gapi.client.youtubeanalytics.reports.query({ });