Package youtubeanalytics provides access to the YouTube Analytics API.

For product documentation, see:

Creating a client

Usage example:

import ""
ctx := context.Background()
youtubeanalyticsService, err := youtubeanalytics.NewService(ctx)

In this example, Google Application Default Credentials are used for authentication.

For information on how to create and obtain Application Default Credentials, see

Other authentication options

To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:

youtubeanalyticsService, err := youtubeanalytics.NewService(ctx, option.WithAPIKey("AIza..."))

To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:

config := &oauth2.Config{...}
// ...
token, err := config.Exchange(ctx, ...)
youtubeanalyticsService, err := youtubeanalytics.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))

See for details on options.



This section is empty.


This section is empty.


This section is empty.


type Service

type Service struct {
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment
	// contains filtered or unexported fields

func New

func New(client *http.Client) (*Service, error)

    New creates a new Service. It uses the provided http.Client for requests.

    Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using, use option.WithAPIKey with NewService instead.

    func NewService

    func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error)

      NewService creates a new Service.