Documentation
ΒΆ
Overview ΒΆ
Package youtube is a Go client library for the YouTube Data API v3.
Index ΒΆ
- type Category
- type CategoryListParams
- type CategoryListResponse
- type CategoryService
- type CategorySnippet
- type Channel
- type ChannelContentDetails
- type ChannelListParams
- type ChannelListResponse
- type ChannelService
- type ChannelStatistics
- type ChannelStatus
- type Client
- type Comment
- type CommentListParams
- type CommentListResponse
- type CommentService
- type CommentSnippet
- type CommentThread
- type CommentThreadListParams
- type CommentThreadListResponse
- type CommentThreadReplies
- type CommentThreadSnippet
- type KeyParam
- type ListResponse
- type PageInfo
- type Playlist
- type PlaylistContentDetails
- type PlaylistItem
- type PlaylistItemListParams
- type PlaylistItemListResponse
- type PlaylistItemService
- type PlaylistItemSnippet
- type PlaylistItemStatus
- type PlaylistListParams
- type PlaylistListResponse
- type PlaylistPlayer
- type PlaylistService
- type PlaylistStatus
- type ResourceID
- type SearchItem
- type SearchParams
- type SearchResult
- type SearchService
- type Snippet
- type Thumbnail
- type ThumbnailService
- type ThumbnailSet
- type Video
- type VideoContentDetails
- type VideoListParams
- type VideoListResponse
- type VideoPlayer
- type VideoService
- type VideoStatistics
- type VideoStatus
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type Category ΒΆ
type Category struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *CategorySnippet `json:"snippet,omitempty"`
}
Category is a video category resource.
type CategoryListParams ΒΆ
type CategoryListParams struct {
Part string `url:"part,omitempty"`
ID string `url:"id,omitempty"`
RegionCode string `url:"regionCode,omitempty"`
}
CategoryListParams are the parameters for videoCategories.list.
type CategoryListResponse ΒΆ
type CategoryListResponse struct {
ListResponse
Items []Category `json:"items,omitempty"`
}
CategoryListResponse is the response from videoCategories.list.
type CategoryService ΒΆ
type CategoryService service
CategoryService provides access to the videoCategories collection.
func (*CategoryService) List ΒΆ
func (s *CategoryService) List(regionCode string) (*CategoryListResponse, error)
List returns video categories for a region.
type CategorySnippet ΒΆ
type CategorySnippet struct {
Title string `json:"title,omitempty"`
Assignable bool `json:"assignable,omitempty"`
ChannelID string `json:"channelId,omitempty"`
}
CategorySnippet holds category metadata.
type Channel ΒΆ
type Channel struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *Snippet `json:"snippet,omitempty"`
Statistics *ChannelStatistics `json:"statistics,omitempty"`
ContentDetails *ChannelContentDetails `json:"contentDetails,omitempty"`
Status *ChannelStatus `json:"status,omitempty"`
}
Channel is a single YouTube channel resource.
type ChannelContentDetails ΒΆ
type ChannelContentDetails struct {
RelatedPlaylists *struct {
Uploads string `json:"uploads,omitempty"`
Likes string `json:"likes,omitempty"`
WatchHistory string `json:"watchHistory,omitempty"`
WatchLater string `json:"watchLater,omitempty"`
} `json:"relatedPlaylists,omitempty"`
}
ChannelContentDetails holds channel content-related metadata.
type ChannelListParams ΒΆ
type ChannelListParams struct {
Part string `url:"part,omitempty"`
ID string `url:"id,omitempty"`
ForUsername string `url:"forUsername,omitempty"`
Mine bool `url:"mine,omitempty"`
ManagedByMe bool `url:"managedByMe,omitempty"`
CategoryID string `url:"categoryId,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
}
ChannelListParams are the parameters for channels.list.
type ChannelListResponse ΒΆ
type ChannelListResponse struct {
ListResponse
Items []Channel `json:"items,omitempty"`
}
ChannelListResponse is the response from channels.list.
type ChannelService ΒΆ
type ChannelService service
ChannelService provides access to the channels collection.
func (*ChannelService) List ΒΆ
func (s *ChannelService) List(part string, ids ...string) (*ChannelListResponse, error)
List returns channels by one or more channel IDs.
func (*ChannelService) ListByUsername ΒΆ
func (s *ChannelService) ListByUsername(part, username string) (*ChannelListResponse, error)
ListByUsername looks up a channel by its legacy username.
func (*ChannelService) ListMine ΒΆ
func (s *ChannelService) ListMine(part string) (*ChannelListResponse, error)
ListMine returns the authenticated user's channel.
type ChannelStatistics ΒΆ
type ChannelStatistics struct {
ViewCount int64 `json:"viewCount,omitempty,string"`
SubscriberCount int64 `json:"subscriberCount,omitempty,string"`
HiddenSubscriberCount bool `json:"hiddenSubscriberCount,omitempty"`
VideoCount int64 `json:"videoCount,omitempty,string"`
}
ChannelStatistics holds channel-level analytics.
type ChannelStatus ΒΆ
type ChannelStatus struct {
PrivacyStatus string `json:"privacyStatus,omitempty"`
IsLinked bool `json:"isLinked,omitempty"`
LongUploadsStatus string `json:"longUploadsStatus,omitempty"`
MadeForKids bool `json:"madeForKids,omitempty"`
}
ChannelStatus holds channel status information.
type Client ΒΆ
type Client struct {
Category *CategoryService
Channel *ChannelService
Comment *CommentService
Playlist *PlaylistService
PlaylistItem *PlaylistItemService
Search *SearchService
Thumbnail *ThumbnailService
Video *VideoService
// contains filtered or unexported fields
}
Client manages communication with the YouTube Data API v3.
func NewClient ΒΆ
NewClient creates a new YouTube API client authenticated with an OAuth2 access token and an API key. Pass an empty string for either if not needed.
func NewClientWithKey ΒΆ
NewClientWithKey creates a client that uses only an API key (no OAuth). Suitable for public, read-only YouTube Data API operations.
type Comment ΒΆ
type Comment struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *CommentSnippet `json:"snippet,omitempty"`
}
Comment is a single comment resource.
type CommentListParams ΒΆ
type CommentListParams struct {
Part string `url:"part,omitempty"`
ID string `url:"id,omitempty"`
ParentID string `url:"parentId,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
TextFormat string `url:"textFormat,omitempty"`
}
CommentListParams are the parameters for comments.list.
type CommentListResponse ΒΆ
type CommentListResponse struct {
ListResponse
Items []Comment `json:"items,omitempty"`
}
CommentListResponse is the response from comments.list.
type CommentService ΒΆ
type CommentService service
CommentService provides access to the commentThreads and comments collections.
func (*CommentService) CommentsList ΒΆ
func (s *CommentService) CommentsList(part, parentID string, maxResults int) (*CommentListResponse, error)
CommentsList returns replies to a comment thread (by parent comment ID).
func (*CommentService) ThreadsList ΒΆ
func (s *CommentService) ThreadsList(part, videoID string, maxResults int) (*CommentThreadListResponse, error)
ThreadsList returns comment threads for a video.
type CommentSnippet ΒΆ
type CommentSnippet struct {
VideoID string `json:"videoId,omitempty"`
ChannelID string `json:"channelId,omitempty"`
CommentThreadID string `json:"commentThreadId,omitempty"`
TextDisplay string `json:"textDisplay,omitempty"`
TextOriginal string `json:"textOriginal,omitempty"`
AuthorDisplayName string `json:"authorDisplayName,omitempty"`
AuthorChannelURL string `json:"authorChannelUrl,omitempty"`
AuthorProfileImageURL string `json:"authorProfileImageUrl,omitempty"`
AuthorChannelID *struct {
Value string `json:"value,omitempty"`
} `json:"authorChannelId,omitempty"`
CanRate bool `json:"canRate,omitempty"`
ViewerRating string `json:"viewerRating,omitempty"`
LikeCount int `json:"likeCount,omitempty"`
PublishedAt string `json:"publishedAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
ParentID string `json:"parentId,omitempty"`
ModerationStatus string `json:"moderationStatus,omitempty"`
}
CommentSnippet holds comment body and metadata.
type CommentThread ΒΆ
type CommentThread struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *CommentThreadSnippet `json:"snippet,omitempty"`
Replies *CommentThreadReplies `json:"replies,omitempty"`
}
CommentThread is a top-level comment thread on a video.
type CommentThreadListParams ΒΆ
type CommentThreadListParams struct {
Part string `url:"part,omitempty"`
VideoID string `url:"videoId,omitempty"`
ChannelID string `url:"channelId,omitempty"`
AllThreadsRelatedToChannelID string `url:"allThreadsRelatedToChannelId,omitempty"`
ID string `url:"id,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
ModerationStatus string `url:"moderationStatus,omitempty"`
Order string `url:"order,omitempty"`
SearchTerms string `url:"searchTerms,omitempty"`
TextFormat string `url:"textFormat,omitempty"`
}
CommentThreadListParams are the parameters for commentThreads.list.
type CommentThreadListResponse ΒΆ
type CommentThreadListResponse struct {
ListResponse
Items []CommentThread `json:"items,omitempty"`
}
CommentThreadListResponse is the response from commentThreads.list.
type CommentThreadReplies ΒΆ
type CommentThreadReplies struct {
Comments []Comment `json:"comments,omitempty"`
}
CommentThreadReplies holds paginated replies to a thread.
type CommentThreadSnippet ΒΆ
type CommentThreadSnippet struct {
VideoID string `json:"videoId,omitempty"`
TopLevelComment *Comment `json:"topLevelComment,omitempty"`
CanReply bool `json:"canReply,omitempty"`
TotalReplyCount int `json:"totalReplyCount,omitempty"`
IsPublic bool `json:"isPublic,omitempty"`
}
CommentThreadSnippet holds comment thread metadata.
type KeyParam ΒΆ
type KeyParam struct {
APIKey string `url:"key,omitempty"`
}
KeyParam holds the API key query parameter sent with every request.
type ListResponse ΒΆ
type ListResponse struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
NextPageToken string `json:"nextPageToken,omitempty"`
PrevPageToken string `json:"prevPageToken,omitempty"`
PageInfo *PageInfo `json:"pageInfo,omitempty"`
}
ListResponse is the common envelope for paginated list endpoints.
type PageInfo ΒΆ
type PageInfo struct {
TotalResults int `json:"totalResults,omitempty"`
ResultsPerPage int `json:"resultsPerPage,omitempty"`
}
PageInfo holds paging metadata returned by most list endpoints.
type Playlist ΒΆ
type Playlist struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *Snippet `json:"snippet,omitempty"`
Status *PlaylistStatus `json:"status,omitempty"`
ContentDetails *PlaylistContentDetails `json:"contentDetails,omitempty"`
Player *PlaylistPlayer `json:"player,omitempty"`
}
Playlist is a single playlist resource.
type PlaylistContentDetails ΒΆ
type PlaylistContentDetails struct {
ItemCount int `json:"itemCount,omitempty"`
}
PlaylistContentDetails holds item count for a playlist.
type PlaylistItem ΒΆ
type PlaylistItem struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *PlaylistItemSnippet `json:"snippet,omitempty"`
Status *PlaylistItemStatus `json:"status,omitempty"`
}
PlaylistItem is a single item within a playlist.
type PlaylistItemListParams ΒΆ
type PlaylistItemListParams struct {
Part string `url:"part,omitempty"`
PlaylistID string `url:"playlistId,omitempty"`
ID string `url:"id,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
}
PlaylistItemListParams are the parameters for playlistItems.list.
type PlaylistItemListResponse ΒΆ
type PlaylistItemListResponse struct {
ListResponse
Items []PlaylistItem `json:"items,omitempty"`
}
PlaylistItemListResponse is the response from playlistItems.list.
type PlaylistItemService ΒΆ
type PlaylistItemService service
PlaylistItemService provides access to the playlistItems collection.
func (*PlaylistItemService) List ΒΆ
func (s *PlaylistItemService) List(part, playlistID string, maxResults int) (*PlaylistItemListResponse, error)
List returns items in a playlist.
type PlaylistItemSnippet ΒΆ
type PlaylistItemSnippet struct {
PublishedAt string `json:"publishedAt,omitempty"`
ChannelID string `json:"channelId,omitempty"`
ChannelTitle string `json:"channelTitle,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Thumbnails *ThumbnailSet `json:"thumbnails,omitempty"`
PlaylistID string `json:"playlistId,omitempty"`
Position int `json:"position,omitempty"`
ResourceID *ResourceID `json:"resourceId,omitempty"`
VideoOwnerChannelTitle string `json:"videoOwnerChannelTitle,omitempty"`
VideoOwnerChannelID string `json:"videoOwnerChannelId,omitempty"`
}
PlaylistItemSnippet holds playlist item metadata.
type PlaylistItemStatus ΒΆ
type PlaylistItemStatus struct {
PrivacyStatus string `json:"privacyStatus,omitempty"`
}
PlaylistItemStatus holds the privacy status of a playlist item.
type PlaylistListParams ΒΆ
type PlaylistListParams struct {
Part string `url:"part,omitempty"`
ID string `url:"id,omitempty"`
ChannelID string `url:"channelId,omitempty"`
Mine bool `url:"mine,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
}
PlaylistListParams are the parameters for playlists.list.
type PlaylistListResponse ΒΆ
type PlaylistListResponse struct {
ListResponse
Items []Playlist `json:"items,omitempty"`
}
PlaylistListResponse is the response from playlists.list.
type PlaylistPlayer ΒΆ
type PlaylistPlayer struct {
EmbedHTML string `json:"embedHtml,omitempty"`
}
PlaylistPlayer holds the embed player for a playlist.
type PlaylistService ΒΆ
type PlaylistService service
PlaylistService provides access to the playlists collection.
func (*PlaylistService) List ΒΆ
func (s *PlaylistService) List(part string, ids ...string) (*PlaylistListResponse, error)
List returns playlists by one or more playlist IDs.
func (*PlaylistService) ListByChannel ΒΆ
func (s *PlaylistService) ListByChannel(part, channelID string, maxResults int) (*PlaylistListResponse, error)
ListByChannel returns playlists owned by the given channel.
func (*PlaylistService) ListMine ΒΆ
func (s *PlaylistService) ListMine(part string, maxResults int) (*PlaylistListResponse, error)
ListMine returns the authenticated user's playlists.
type PlaylistStatus ΒΆ
type PlaylistStatus struct {
PrivacyStatus string `json:"privacyStatus,omitempty"`
}
PlaylistStatus holds the privacy status of a playlist.
type ResourceID ΒΆ
type ResourceID struct {
Kind string `json:"kind,omitempty"`
VideoID *string `json:"videoId,omitempty"`
ChannelID *string `json:"channelId,omitempty"`
PlaylistID *string `json:"playlistId,omitempty"`
}
ResourceID identifies a YouTube resource (video, channel, playlist).
type SearchItem ΒΆ
type SearchItem struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID *ResourceID `json:"id,omitempty"`
Snippet *Snippet `json:"snippet,omitempty"`
}
SearchItem is a single search result item.
type SearchParams ΒΆ
type SearchParams struct {
Part string `url:"part,omitempty"`
Q string `url:"q,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
Order string `url:"order,omitempty"`
PageToken string `url:"pageToken,omitempty"`
RegionCode string `url:"regionCode,omitempty"`
RelevanceLanguage string `url:"relevanceLanguage,omitempty"`
SafeSearch string `url:"safeSearch,omitempty"`
Type string `url:"type,omitempty"`
VideoCaption string `url:"videoCaption,omitempty"`
VideoCategoryID string `url:"videoCategoryId,omitempty"`
VideoDuration string `url:"videoDuration,omitempty"`
VideoEmbeddable string `url:"videoEmbeddable,omitempty"`
VideoLicense string `url:"videoLicense,omitempty"`
VideoSyndicated string `url:"videoSyndicated,omitempty"`
VideoType string `url:"videoType,omitempty"`
ChannelID string `url:"channelId,omitempty"`
ChannelType string `url:"channelType,omitempty"`
Location string `url:"location,omitempty"`
LocationRadius string `url:"locationRadius,omitempty"`
PublishedAfter string `url:"publishedAfter,omitempty"`
PublishedBefore string `url:"publishedBefore,omitempty"`
}
SearchParams are the parameters for search.list.
type SearchResult ΒΆ
type SearchResult struct {
ListResponse
Items []SearchItem `json:"items,omitempty"`
}
SearchResult is the response envelope for search.list.
type SearchService ΒΆ
type SearchService service
SearchService provides access to the search collection.
func (*SearchService) Search ΒΆ
func (s *SearchService) Search(q string, params *SearchParams) (*SearchResult, error)
Search performs a YouTube search. Pass an empty SearchParams{} for defaults (part="snippet", maxResults=25).
type Snippet ΒΆ
type Snippet struct {
PublishedAt string `json:"publishedAt,omitempty"`
ChannelID string `json:"channelId,omitempty"`
ChannelTitle string `json:"channelTitle,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Thumbnails *ThumbnailSet `json:"thumbnails,omitempty"`
LiveBroadcastContent string `json:"liveBroadcastContent,omitempty"`
DefaultLanguage string `json:"defaultLanguage,omitempty"`
}
Snippet is the common snippet object shared by most resources.
type Thumbnail ΒΆ
type Thumbnail struct {
URL string `json:"url,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
Thumbnail represents a single thumbnail image.
type ThumbnailService ΒΆ
type ThumbnailService service
type ThumbnailSet ΒΆ
type ThumbnailSet struct {
Default *Thumbnail `json:"default,omitempty"`
Medium *Thumbnail `json:"medium,omitempty"`
High *Thumbnail `json:"high,omitempty"`
Standard *Thumbnail `json:"standard,omitempty"`
Maxres *Thumbnail `json:"maxres,omitempty"`
}
ThumbnailSet holds the standard thumbnail resolutions returned by the API.
type Video ΒΆ
type Video struct {
Kind string `json:"kind,omitempty"`
Etag string `json:"etag,omitempty"`
ID string `json:"id,omitempty"`
Snippet *Snippet `json:"snippet,omitempty"`
ContentDetails *VideoContentDetails `json:"contentDetails,omitempty"`
Statistics *VideoStatistics `json:"statistics,omitempty"`
Status *VideoStatus `json:"status,omitempty"`
Player *VideoPlayer `json:"player,omitempty"`
}
Video is a single video resource.
type VideoContentDetails ΒΆ
type VideoContentDetails struct {
Duration string `json:"duration,omitempty"`
Dimension string `json:"dimension,omitempty"`
Definition string `json:"definition,omitempty"`
Caption string `json:"caption,omitempty"`
LicensedContent bool `json:"licensedContent,omitempty"`
RegionRestriction *struct {
Allowed []string `json:"allowed,omitempty"`
Blocked []string `json:"blocked,omitempty"`
} `json:"regionRestriction,omitempty"`
ContentRating *struct {
YtRating string `json:"ytRating,omitempty"`
} `json:"contentRating,omitempty"`
Projection string `json:"projection,omitempty"`
}
VideoContentDetails holds video-level content metadata.
type VideoListParams ΒΆ
type VideoListParams struct {
Part string `url:"part,omitempty"`
ID string `url:"id,omitempty"`
Chart string `url:"chart,omitempty"`
RegionCode string `url:"regionCode,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
PageToken string `url:"pageToken,omitempty"`
VideoCategoryID string `url:"videoCategoryId,omitempty"`
MyRating string `url:"myRating,omitempty"`
MaxHeight int `url:"maxHeight,omitempty"`
MaxWidth int `url:"maxWidth,omitempty"`
}
VideoListParams are the parameters for videos.list.
type VideoListResponse ΒΆ
type VideoListResponse struct {
ListResponse
Items []Video `json:"items,omitempty"`
}
VideoListResponse is the response from videos.list.
type VideoPlayer ΒΆ
type VideoPlayer struct {
EmbedHTML string `json:"embedHtml,omitempty"`
EmbedHeight int `json:"embedHeight,omitempty"`
EmbedWidth int `json:"embedWidth,omitempty"`
}
VideoPlayer holds the embed HTML for a video.
type VideoService ΒΆ
type VideoService service
VideoService provides access to the videos collection.
func (*VideoService) List ΒΆ
func (s *VideoService) List(part string, ids ...string) (*VideoListResponse, error)
List returns videos by one or more video IDs.
func (*VideoService) ListByChart ΒΆ
func (s *VideoService) ListByChart(part, chart, regionCode string, maxResults int) (*VideoListResponse, error)
ListByChart returns videos from a chart (e.g., "mostPopular").
func (*VideoService) ListByRating ΒΆ
func (s *VideoService) ListByRating(part, rating string) (*VideoListResponse, error)
ListByRating returns videos the authenticated user has rated.
type VideoStatistics ΒΆ
type VideoStatistics struct {
ViewCount int64 `json:"viewCount,omitempty,string"`
LikeCount int64 `json:"likeCount,omitempty,string"`
DislikeCount int64 `json:"dislikeCount,omitempty,string"`
FavoriteCount int64 `json:"favoriteCount,omitempty,string"`
CommentCount int64 `json:"commentCount,omitempty,string"`
}
VideoStatistics holds video view/like/dislike/comment counts.
type VideoStatus ΒΆ
type VideoStatus struct {
UploadStatus string `json:"uploadStatus,omitempty"`
FailureReason string `json:"failureReason,omitempty"`
RejectionReason string `json:"rejectionReason,omitempty"`
PrivacyStatus string `json:"privacyStatus,omitempty"`
PubsubAutoFire bool `json:"pubsubAutoFire,omitempty,string"`
License string `json:"license,omitempty"`
Embeddable bool `json:"embeddable,omitempty"`
MadeForKids bool `json:"madeForKids,omitempty"`
}
VideoStatus holds video publishing/live status.