// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * YouTube Data API v3 Client for Deno * =================================== * * The YouTube Data API v3 is an API that provides access to YouTube data, such as videos, playlists, and channels. * * Docs: https://developers.google.com/youtube/ * Source: https://googleapis.deno.dev/v1/youtube:v3.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * The YouTube Data API v3 is an API that provides access to YouTube data, such * as videos, playlists, and channels. */ export class YouTube { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://youtube.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Inserts a new resource into this collection. * */ async abuseReportsInsert(req: AbuseReport, opts: AbuseReportsInsertOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/abuseReports`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as AbuseReport; } /** * Retrieves a list of resources, possibly filtered. * */ async activitiesList(opts: ActivitiesListOptions = {}): Promise { opts = serializeActivitiesListOptions(opts); const url = new URL(`${this.#baseUrl}youtube/v3/activities`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.home !== undefined) { url.searchParams.append("home", String(opts.home)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.publishedAfter !== undefined) { url.searchParams.append("publishedAfter", String(opts.publishedAfter)); } if (opts.publishedBefore !== undefined) { url.searchParams.append("publishedBefore", String(opts.publishedBefore)); } if (opts.regionCode !== undefined) { url.searchParams.append("regionCode", String(opts.regionCode)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeActivityListResponse(data); } /** * Deletes a resource. * */ async captionsDelete(opts: CaptionsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/captions`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOf !== undefined) { url.searchParams.append("onBehalfOf", String(opts.onBehalfOf)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Downloads a caption track. * * @param id The ID of the caption track to download, required for One Platform. */ async captionsDownload(id: string, opts: CaptionsDownloadOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/captions/${ id }`); if (opts.onBehalfOf !== undefined) { url.searchParams.append("onBehalfOf", String(opts.onBehalfOf)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.tfmt !== undefined) { url.searchParams.append("tfmt", String(opts.tfmt)); } if (opts.tlang !== undefined) { url.searchParams.append("tlang", String(opts.tlang)); } const data = await request(url.href, { client: this.#client, method: "GET", }); } /** * Inserts a new resource into this collection. * */ async captionsInsert(req: Caption, opts: CaptionsInsertOptions = {}): Promise { req = serializeCaption(req); const url = new URL(`${this.#baseUrl}youtube/v3/captions`); if (opts.onBehalfOf !== undefined) { url.searchParams.append("onBehalfOf", String(opts.onBehalfOf)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.sync !== undefined) { url.searchParams.append("sync", String(opts.sync)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeCaption(data); } /** * Retrieves a list of resources, possibly filtered. * */ async captionsList(opts: CaptionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/captions`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOf !== undefined) { url.searchParams.append("onBehalfOf", String(opts.onBehalfOf)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.videoId !== undefined) { url.searchParams.append("videoId", String(opts.videoId)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeCaptionListResponse(data); } /** * Updates an existing resource. * */ async captionsUpdate(req: Caption, opts: CaptionsUpdateOptions = {}): Promise { req = serializeCaption(req); const url = new URL(`${this.#baseUrl}youtube/v3/captions`); if (opts.onBehalfOf !== undefined) { url.searchParams.append("onBehalfOf", String(opts.onBehalfOf)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.sync !== undefined) { url.searchParams.append("sync", String(opts.sync)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeCaption(data); } /** * Inserts a new resource into this collection. * */ async channelBannersInsert(req: ChannelBannerResource, opts: ChannelBannersInsertOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channelBanners/insert`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as ChannelBannerResource; } /** * Deletes a resource. * */ async channelSectionsDelete(opts: ChannelSectionsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channelSections`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async channelSectionsInsert(req: ChannelSection, opts: ChannelSectionsInsertOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channelSections`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as ChannelSection; } /** * Retrieves a list of resources, possibly filtered. * */ async channelSectionsList(opts: ChannelSectionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channelSections`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ChannelSectionListResponse; } /** * Updates an existing resource. * */ async channelSectionsUpdate(req: ChannelSection, opts: ChannelSectionsUpdateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channelSections`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return data as ChannelSection; } /** * Retrieves a list of resources, possibly filtered. * */ async channelsList(opts: ChannelsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/channels`); if (opts.categoryId !== undefined) { url.searchParams.append("categoryId", String(opts.categoryId)); } if (opts.forHandle !== undefined) { url.searchParams.append("forHandle", String(opts.forHandle)); } if (opts.forUsername !== undefined) { url.searchParams.append("forUsername", String(opts.forUsername)); } if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.managedByMe !== undefined) { url.searchParams.append("managedByMe", String(opts.managedByMe)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.mySubscribers !== undefined) { url.searchParams.append("mySubscribers", String(opts.mySubscribers)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeChannelListResponse(data); } /** * Updates an existing resource. * */ async channelsUpdate(req: Channel, opts: ChannelsUpdateOptions = {}): Promise { req = serializeChannel(req); const url = new URL(`${this.#baseUrl}youtube/v3/channels`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeChannel(data); } /** * Deletes a resource. * */ async commentsDelete(opts: CommentsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/comments`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async commentsInsert(req: Comment, opts: CommentsInsertOptions = {}): Promise { req = serializeComment(req); const url = new URL(`${this.#baseUrl}youtube/v3/comments`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeComment(data); } /** * Retrieves a list of resources, possibly filtered. * */ async commentsList(opts: CommentsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/comments`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.parentId !== undefined) { url.searchParams.append("parentId", String(opts.parentId)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.textFormat !== undefined) { url.searchParams.append("textFormat", String(opts.textFormat)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeCommentListResponse(data); } /** * Expresses the caller's opinion that one or more comments should be flagged * as spam. * */ async commentsMarkAsSpam(opts: CommentsMarkAsSpamOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/comments/markAsSpam`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "POST", }); } /** * Sets the moderation status of one or more comments. * */ async commentsSetModerationStatus(opts: CommentsSetModerationStatusOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/comments/setModerationStatus`); if (opts.banAuthor !== undefined) { url.searchParams.append("banAuthor", String(opts.banAuthor)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.moderationStatus !== undefined) { url.searchParams.append("moderationStatus", String(opts.moderationStatus)); } const data = await request(url.href, { client: this.#client, method: "POST", }); } /** * Updates an existing resource. * */ async commentsUpdate(req: Comment, opts: CommentsUpdateOptions = {}): Promise { req = serializeComment(req); const url = new URL(`${this.#baseUrl}youtube/v3/comments`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeComment(data); } /** * Inserts a new resource into this collection. * */ async commentThreadsInsert(req: CommentThread, opts: CommentThreadsInsertOptions = {}): Promise { req = serializeCommentThread(req); const url = new URL(`${this.#baseUrl}youtube/v3/commentThreads`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeCommentThread(data); } /** * Retrieves a list of resources, possibly filtered. * */ async commentThreadsList(opts: CommentThreadsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/commentThreads`); if (opts.allThreadsRelatedToChannelId !== undefined) { url.searchParams.append("allThreadsRelatedToChannelId", String(opts.allThreadsRelatedToChannelId)); } if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.moderationStatus !== undefined) { url.searchParams.append("moderationStatus", String(opts.moderationStatus)); } if (opts.order !== undefined) { url.searchParams.append("order", String(opts.order)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.searchTerms !== undefined) { url.searchParams.append("searchTerms", String(opts.searchTerms)); } if (opts.textFormat !== undefined) { url.searchParams.append("textFormat", String(opts.textFormat)); } if (opts.videoId !== undefined) { url.searchParams.append("videoId", String(opts.videoId)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeCommentThreadListResponse(data); } /** * Retrieves a list of resources, possibly filtered. * */ async i18nLanguagesList(opts: I18nLanguagesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/i18nLanguages`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as I18nLanguageListResponse; } /** * Retrieves a list of resources, possibly filtered. * */ async i18nRegionsList(opts: I18nRegionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/i18nRegions`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as I18nRegionListResponse; } /** * Bind a broadcast to a stream. * */ async liveBroadcastsBind(opts: LiveBroadcastsBindOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts/bind`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.streamId !== undefined) { url.searchParams.append("streamId", String(opts.streamId)); } const data = await request(url.href, { client: this.#client, method: "POST", }); return deserializeLiveBroadcast(data); } /** * Delete a given broadcast. * */ async liveBroadcastsDelete(opts: LiveBroadcastsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new stream for the authenticated user. * */ async liveBroadcastsInsert(req: LiveBroadcast, opts: LiveBroadcastsInsertOptions = {}): Promise { req = serializeLiveBroadcast(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeLiveBroadcast(data); } /** * Insert cuepoints in a broadcast * */ async liveBroadcastsInsertCuepoint(req: Cuepoint, opts: LiveBroadcastsInsertCuepointOptions = {}): Promise { req = serializeCuepoint(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts/cuepoint`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeCuepoint(data); } /** * Retrieve the list of broadcasts associated with the given channel. * */ async liveBroadcastsList(opts: LiveBroadcastsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts`); if (opts.broadcastStatus !== undefined) { url.searchParams.append("broadcastStatus", String(opts.broadcastStatus)); } if (opts.broadcastType !== undefined) { url.searchParams.append("broadcastType", String(opts.broadcastType)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeLiveBroadcastListResponse(data); } /** * Transition a broadcast to a given status. * */ async liveBroadcastsTransition(opts: LiveBroadcastsTransitionOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts/transition`); if (opts.broadcastStatus !== undefined) { url.searchParams.append("broadcastStatus", String(opts.broadcastStatus)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "POST", }); return deserializeLiveBroadcast(data); } /** * Updates an existing broadcast for the authenticated user. * */ async liveBroadcastsUpdate(req: LiveBroadcast, opts: LiveBroadcastsUpdateOptions = {}): Promise { req = serializeLiveBroadcast(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveBroadcasts`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeLiveBroadcast(data); } /** * Deletes a chat ban. * */ async liveChatBansDelete(opts: LiveChatBansDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/bans`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async liveChatBansInsert(req: LiveChatBan, opts: LiveChatBansInsertOptions = {}): Promise { req = serializeLiveChatBan(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/bans`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeLiveChatBan(data); } /** * Deletes a chat message. * */ async liveChatMessagesDelete(opts: LiveChatMessagesDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/messages`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async liveChatMessagesInsert(req: LiveChatMessage, opts: LiveChatMessagesInsertOptions = {}): Promise { req = serializeLiveChatMessage(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/messages`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeLiveChatMessage(data); } /** * Retrieves a list of resources, possibly filtered. * */ async liveChatMessagesList(opts: LiveChatMessagesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/messages`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.liveChatId !== undefined) { url.searchParams.append("liveChatId", String(opts.liveChatId)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.profileImageSize !== undefined) { url.searchParams.append("profileImageSize", String(opts.profileImageSize)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeLiveChatMessageListResponse(data); } /** * Transition a durable chat event. * */ async liveChatMessagesTransition(opts: LiveChatMessagesTransitionOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/messages/transition`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.status !== undefined) { url.searchParams.append("status", String(opts.status)); } const data = await request(url.href, { client: this.#client, method: "POST", }); return deserializeLiveChatMessage(data); } /** * Deletes a chat moderator. * */ async liveChatModeratorsDelete(opts: LiveChatModeratorsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/moderators`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async liveChatModeratorsInsert(req: LiveChatModerator, opts: LiveChatModeratorsInsertOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/moderators`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as LiveChatModerator; } /** * Retrieves a list of resources, possibly filtered. * */ async liveChatModeratorsList(opts: LiveChatModeratorsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveChat/moderators`); if (opts.liveChatId !== undefined) { url.searchParams.append("liveChatId", String(opts.liveChatId)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as LiveChatModeratorListResponse; } /** * Deletes an existing stream for the authenticated user. * */ async liveStreamsDelete(opts: LiveStreamsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveStreams`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new stream for the authenticated user. * */ async liveStreamsInsert(req: LiveStream, opts: LiveStreamsInsertOptions = {}): Promise { req = serializeLiveStream(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveStreams`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeLiveStream(data); } /** * Retrieve the list of streams associated with the given channel. -- * */ async liveStreamsList(opts: LiveStreamsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/liveStreams`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeLiveStreamListResponse(data); } /** * Updates an existing stream for the authenticated user. * */ async liveStreamsUpdate(req: LiveStream, opts: LiveStreamsUpdateOptions = {}): Promise { req = serializeLiveStream(req); const url = new URL(`${this.#baseUrl}youtube/v3/liveStreams`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeLiveStream(data); } /** * Retrieves a list of all pricing levels offered by a creator to the fans. * */ async membershipsLevelsList(opts: MembershipsLevelsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/membershipsLevels`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as MembershipsLevelListResponse; } /** * Retrieves a list of members that match the request criteria for a channel. * */ async membersList(opts: MembersListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/members`); if (opts.filterByMemberChannelId !== undefined) { url.searchParams.append("filterByMemberChannelId", String(opts.filterByMemberChannelId)); } if (opts.hasAccessToLevel !== undefined) { url.searchParams.append("hasAccessToLevel", String(opts.hasAccessToLevel)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mode !== undefined) { url.searchParams.append("mode", String(opts.mode)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as MemberListResponse; } /** * Deletes a resource. * */ async playlistImagesDelete(opts: PlaylistImagesDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistImages`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async playlistImagesInsert(req: PlaylistImage, opts: PlaylistImagesInsertOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistImages`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as PlaylistImage; } /** * Retrieves a list of resources, possibly filtered. * */ async playlistImagesList(opts: PlaylistImagesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistImages`); if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.parent !== undefined) { url.searchParams.append("parent", String(opts.parent)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as PlaylistImageListResponse; } /** * Updates an existing resource. * */ async playlistImagesUpdate(req: PlaylistImage, opts: PlaylistImagesUpdateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistImages`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return data as PlaylistImage; } /** * Deletes a resource. * */ async playlistItemsDelete(opts: PlaylistItemsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistItems`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async playlistItemsInsert(req: PlaylistItem, opts: PlaylistItemsInsertOptions = {}): Promise { req = serializePlaylistItem(req); const url = new URL(`${this.#baseUrl}youtube/v3/playlistItems`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializePlaylistItem(data); } /** * Retrieves a list of resources, possibly filtered. * */ async playlistItemsList(opts: PlaylistItemsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlistItems`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.playlistId !== undefined) { url.searchParams.append("playlistId", String(opts.playlistId)); } if (opts.videoId !== undefined) { url.searchParams.append("videoId", String(opts.videoId)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializePlaylistItemListResponse(data); } /** * Updates an existing resource. * */ async playlistItemsUpdate(req: PlaylistItem, opts: PlaylistItemsUpdateOptions = {}): Promise { req = serializePlaylistItem(req); const url = new URL(`${this.#baseUrl}youtube/v3/playlistItems`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializePlaylistItem(data); } /** * Deletes a resource. * */ async playlistsDelete(opts: PlaylistsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlists`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async playlistsInsert(req: Playlist, opts: PlaylistsInsertOptions = {}): Promise { req = serializePlaylist(req); const url = new URL(`${this.#baseUrl}youtube/v3/playlists`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializePlaylist(data); } /** * Retrieves a list of resources, possibly filtered. * */ async playlistsList(opts: PlaylistsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/playlists`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializePlaylistListResponse(data); } /** * Updates an existing resource. * */ async playlistsUpdate(req: Playlist, opts: PlaylistsUpdateOptions = {}): Promise { req = serializePlaylist(req); const url = new URL(`${this.#baseUrl}youtube/v3/playlists`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializePlaylist(data); } /** * Retrieves a list of search resources * */ async searchList(opts: SearchListOptions = {}): Promise { opts = serializeSearchListOptions(opts); const url = new URL(`${this.#baseUrl}youtube/v3/search`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.channelType !== undefined) { url.searchParams.append("channelType", String(opts.channelType)); } if (opts.eventType !== undefined) { url.searchParams.append("eventType", String(opts.eventType)); } if (opts.forContentOwner !== undefined) { url.searchParams.append("forContentOwner", String(opts.forContentOwner)); } if (opts.forDeveloper !== undefined) { url.searchParams.append("forDeveloper", String(opts.forDeveloper)); } if (opts.forMine !== undefined) { url.searchParams.append("forMine", String(opts.forMine)); } if (opts.location !== undefined) { url.searchParams.append("location", String(opts.location)); } if (opts.locationRadius !== undefined) { url.searchParams.append("locationRadius", String(opts.locationRadius)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.order !== undefined) { url.searchParams.append("order", String(opts.order)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.publishedAfter !== undefined) { url.searchParams.append("publishedAfter", String(opts.publishedAfter)); } if (opts.publishedBefore !== undefined) { url.searchParams.append("publishedBefore", String(opts.publishedBefore)); } if (opts.q !== undefined) { url.searchParams.append("q", String(opts.q)); } if (opts.regionCode !== undefined) { url.searchParams.append("regionCode", String(opts.regionCode)); } if (opts.relevanceLanguage !== undefined) { url.searchParams.append("relevanceLanguage", String(opts.relevanceLanguage)); } if (opts.safeSearch !== undefined) { url.searchParams.append("safeSearch", String(opts.safeSearch)); } if (opts.topicId !== undefined) { url.searchParams.append("topicId", String(opts.topicId)); } if (opts.type !== undefined) { url.searchParams.append("type", String(opts.type)); } if (opts.videoCaption !== undefined) { url.searchParams.append("videoCaption", String(opts.videoCaption)); } if (opts.videoCategoryId !== undefined) { url.searchParams.append("videoCategoryId", String(opts.videoCategoryId)); } if (opts.videoDefinition !== undefined) { url.searchParams.append("videoDefinition", String(opts.videoDefinition)); } if (opts.videoDimension !== undefined) { url.searchParams.append("videoDimension", String(opts.videoDimension)); } if (opts.videoDuration !== undefined) { url.searchParams.append("videoDuration", String(opts.videoDuration)); } if (opts.videoEmbeddable !== undefined) { url.searchParams.append("videoEmbeddable", String(opts.videoEmbeddable)); } if (opts.videoLicense !== undefined) { url.searchParams.append("videoLicense", String(opts.videoLicense)); } if (opts.videoPaidProductPlacement !== undefined) { url.searchParams.append("videoPaidProductPlacement", String(opts.videoPaidProductPlacement)); } if (opts.videoSyndicated !== undefined) { url.searchParams.append("videoSyndicated", String(opts.videoSyndicated)); } if (opts.videoType !== undefined) { url.searchParams.append("videoType", String(opts.videoType)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeSearchListResponse(data); } /** * Deletes a resource. * */ async subscriptionsDelete(opts: SubscriptionsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/subscriptions`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async subscriptionsInsert(req: Subscription, opts: SubscriptionsInsertOptions = {}): Promise { req = serializeSubscription(req); const url = new URL(`${this.#baseUrl}youtube/v3/subscriptions`); if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeSubscription(data); } /** * Retrieves a list of resources, possibly filtered. * */ async subscriptionsList(opts: SubscriptionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/subscriptions`); if (opts.channelId !== undefined) { url.searchParams.append("channelId", String(opts.channelId)); } if (opts.forChannelId !== undefined) { url.searchParams.append("forChannelId", String(opts.forChannelId)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.mine !== undefined) { url.searchParams.append("mine", String(opts.mine)); } if (opts.myRecentSubscribers !== undefined) { url.searchParams.append("myRecentSubscribers", String(opts.myRecentSubscribers)); } if (opts.mySubscribers !== undefined) { url.searchParams.append("mySubscribers", String(opts.mySubscribers)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.onBehalfOfContentOwnerChannel !== undefined) { url.searchParams.append("onBehalfOfContentOwnerChannel", String(opts.onBehalfOfContentOwnerChannel)); } if (opts.order !== undefined) { url.searchParams.append("order", String(opts.order)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeSubscriptionListResponse(data); } /** * Retrieves a list of resources, possibly filtered. * */ async superChatEventsList(opts: SuperChatEventsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/superChatEvents`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.maxResults !== undefined) { url.searchParams.append("maxResults", String(opts.maxResults)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeSuperChatEventListResponse(data); } /** * POST method. * */ async testsInsert(req: TestItem, opts: TestsInsertOptions = {}): Promise { req = serializeTestItem(req); const url = new URL(`${this.#baseUrl}youtube/v3/tests`); if (opts.externalChannelId !== undefined) { url.searchParams.append("externalChannelId", String(opts.externalChannelId)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeTestItem(data); } /** * Deletes a resource. * */ async thirdPartyLinksDelete(opts: ThirdPartyLinksDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/thirdPartyLinks`); if (opts.externalChannelId !== undefined) { url.searchParams.append("externalChannelId", String(opts.externalChannelId)); } if (opts.linkingToken !== undefined) { url.searchParams.append("linkingToken", String(opts.linkingToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.type !== undefined) { url.searchParams.append("type", String(opts.type)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Inserts a new resource into this collection. * */ async thirdPartyLinksInsert(req: ThirdPartyLink, opts: ThirdPartyLinksInsertOptions = {}): Promise { req = serializeThirdPartyLink(req); const url = new URL(`${this.#baseUrl}youtube/v3/thirdPartyLinks`); if (opts.externalChannelId !== undefined) { url.searchParams.append("externalChannelId", String(opts.externalChannelId)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeThirdPartyLink(data); } /** * Retrieves a list of resources, possibly filtered. * */ async thirdPartyLinksList(opts: ThirdPartyLinksListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/thirdPartyLinks`); if (opts.externalChannelId !== undefined) { url.searchParams.append("externalChannelId", String(opts.externalChannelId)); } if (opts.linkingToken !== undefined) { url.searchParams.append("linkingToken", String(opts.linkingToken)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.type !== undefined) { url.searchParams.append("type", String(opts.type)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeThirdPartyLinkListResponse(data); } /** * Updates an existing resource. * */ async thirdPartyLinksUpdate(req: ThirdPartyLink, opts: ThirdPartyLinksUpdateOptions = {}): Promise { req = serializeThirdPartyLink(req); const url = new URL(`${this.#baseUrl}youtube/v3/thirdPartyLinks`); if (opts.externalChannelId !== undefined) { url.searchParams.append("externalChannelId", String(opts.externalChannelId)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PUT", body, }); return deserializeThirdPartyLink(data); } /** * As this is not an insert in a strict sense (it supports uploading/setting * of a thumbnail for multiple videos, which doesn't result in creation of a * single resource), I use a custom verb here. * */ async thumbnailsSet(opts: ThumbnailsSetOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/thumbnails/set`); if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } if (opts.videoId !== undefined) { url.searchParams.append("videoId", String(opts.videoId)); } const data = await request(url.href, { client: this.#client, method: "POST", }); return data as ThumbnailSetResponse; } /** * Retrieves a list of resources, possibly filtered. * */ async videoAbuseReportReasonsList(opts: VideoAbuseReportReasonsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/videoAbuseReportReasons`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as VideoAbuseReportReasonListResponse; } /** * Retrieves a list of resources, possibly filtered. * */ async videoCategoriesList(opts: VideoCategoriesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/videoCategories`); if (opts.hl !== undefined) { url.searchParams.append("hl", String(opts.hl)); } if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.part !== undefined) { url.searchParams.append("part", String(opts.part)); } if (opts.regionCode !== undefined) { url.searchParams.append("regionCode", String(opts.regionCode)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as VideoCategoryListResponse; } /** * Deletes a resource. * */ async videosDelete(opts: VideosDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/videos`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); } /** * Retrieves the ratings that the authorized user gave to a list of specified * videos. * */ async videosGetRating(opts: VideosGetRatingOptions = {}): Promise { const url = new URL(`${this.#baseUrl}youtube/v3/videos/getRating`); if (opts.id !== undefined) { url.searchParams.append("id", String(opts.id)); } if (opts.onBehalfOfContentOwner !== undefined) { url.searchParams.append("onBehalfOfContentOwner", String(opts.onBehalfOfContentOwner)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as VideoGetRatingResponse; } /** * Inserts a new resource into this collection. * */ async videosInsert(req: Video, opts: VideosInsertOptions = {}): Promise