YouTube Data API v3 コマンドとエンドポイントまとめ
YouTube Data API v3を使用する際には、エンドポイントの設定が必要です。以下に、APIの各機能に対応するエンドポイントを含めて、詳細に説明します。
1. 認証と承認
1.1 認証方式
OAuth 2.0
認証エンドポイント: `https://accounts.google.com/o/oauth2/auth`
トークンエンドポイント: `https://oauth2.googleapis.com/token`
リダイレクトURI: `http://localhost`(アプリケーションの設定に依存)
2. 動画関連の操作
2.1 動画のアップロード
エンドポイント: `POST https://www.googleapis.com/upload/youtube/v3/videos`
メソッド: `videos.insert`
パラメータ:
`part` (例: `snippet,status`)
リクエストボディには動画のメタデータを含む。
2.2 動画の詳細情報取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/videos`
メソッド: `videos.list`
パラメータ:
`part` (例: `snippet,contentDetails,statistics`)
`id` (動画ID)
2.3 動画の更新
エンドポイント: `PUT https://www.googleapis.com/youtube/v3/videos`
メソッド: `videos.update`
パラメータ:
`part` (例: `snippet,status`)
リクエストボディには更新するメタデータを含む。
2.4 動画の削除
エンドポイント: `DELETE https://www.googleapis.com/youtube/v3/videos`
メソッド: `videos.delete`
パラメータ:
`id` (動画ID)
3. チャンネル関連の操作
3.1 チャンネル情報の取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/channels`
メソッド: `channels.list`
パラメータ:
`part` (例: `snippet,contentDetails,statistics`)
`id` (チャンネルID)または`forUsername` (ユーザー名)
3.2 チャンネルのサブスクリプション管理
エンドポイント:
メソッド:
取得: `subscriptions.list`
追加: `subscriptions.insert`
削除: `subscriptions.delete`
パラメータ:
取得:
`part` (例: `snippet,contentDetails`)
`mine` (認証ユーザーのサブスクリプションを取得する場合は`true`)
追加:
リクエストボディにはサブスクリプション情報を含む。
削除:
`id` (サブスクリプションID)
4. 再生リスト関連の操作
4.1 再生リストの作成
エンドポイント: `POST https://www.googleapis.com/youtube/v3/playlists`
メソッド: `playlists.insert`
パラメータ:
`part` (例: `snippet,status`)
リクエストボディには再生リストのメタデータを含む。
4.2 再生リストの取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/playlists`
メソッド: `playlists.list`
パラメータ:
`part` (例: `snippet,contentDetails`)
`channelId` (チャンネルID)または`id` (再生リストID)
4.3 再生リストへの動画追加
エンドポイント: `POST https://www.googleapis.com/youtube/v3/playlistItems`
メソッド: `playlistItems.insert`
パラメータ:
`part` (例: `snippet`)
リクエストボディには再生リストアイテム情報を含む。
4.4 再生リストの更新
エンドポイント: `PUT https://www.googleapis.com/youtube/v3/playlists`
メソッド: `playlists.update`
パラメータ:
`part` (例: `snippet,status`)
リクエストボディには更新するメタデータを含む。
4.5 再生リストの削除
エンドポイント: `DELETE https://www.googleapis.com/youtube/v3/playlists`
メソッド: `playlists.delete`
パラメータ:
`id` (再生リストID)
5. コメント関連の操作
5.1 コメントの取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/commentThreads`
メソッド: `commentThreads.list`
パラメータ:
`part` (例: `snippet,replies`)
`videoId` (動画ID)または`channelId` (チャンネルID)
5.2 コメントの投稿
エンドポイント: `POST https://www.googleapis.com/youtube/v3/commentThreads`
メソッド: `commentThreads.insert`
パラメータ:
`part` (例: `snippet`)
リクエストボディにはコメントのメタデータを含む。
5.3 コメントの返信
エンドポイント: `POST https://www.googleapis.com/youtube/v3/comments`
メソッド: `comments.insert`
パラメータ:
`part` (例: `snippet`)
リクエストボディにはコメントのメタデータを含む。
5.4 コメントの更新
エンドポイント: `PUT https://www.googleapis.com/youtube/v3/comments`
メソッド: `comments.update`
パラメータ:
`part` (例: `snippet`)
リクエストボディには更新するメタデータを含む。
5.5 コメントの削除
エンドポイント: `DELETE https://www.googleapis.com/youtube/v3/comments`
メソッド: `comments.delete`
パラメータ:
`id` (コメントID)
6. ライブストリーミング関連の操作
6.1 ライブイベントの管理
エンドポイント:
作成: `POST https://www.googleapis.com/youtube/v3/liveBroadcasts`
取得: `GET https://www.googleapis.com/youtube/v3/liveBroadcasts`
更新: `PUT https://www.googleapis.com/youtube/v3/liveBroadcasts`
削除: `DELETE https://www.googleapis.com/youtube/v3/liveBroadcasts`
バインド: `POST https://www.googleapis.com/youtube/v3/liveBroadcasts/bind`
メソッド:
作成: `liveBroadcasts.insert`
取得: `liveBroadcasts.list`
更新: `liveBroadcasts.update`
削除: `liveBroadcasts.delete`
バインド: `liveBroadcasts.bind`
パラメータ:
作成、更新、バインド:
`part` (例: `snippet,contentDetails,status`)
リクエストボディにはライブイベントのメタデータを含む。
取得:
`part` (例: `snippet,contentDetails,status`)
`id` (ライブイベントID)または`broadcastStatus` (例: `active`, `all`, `completed`, `upcoming`)
削除:
`id` (ライブイベントID)
6.2 ライブストリームの管理
エンドポイント:
メソッド:
作成: `liveStreams.insert`
取得: `liveStreams.list`
更新: `liveStreams.update`
削除: `liveStreams
.delete`
パラメータ:
作成、更新:
`part` (例: `snippet,cdn,contentDetails,status`)
リクエストボディにはライブストリームのメタデータを含む。
取得:
`part` (例: `snippet,cdn,contentDetails,status`)
`id` (ライブストリームID)または`mine` (認証ユーザーのライブストリームを取得する場合は`true`)
削除:
`id` (ライブストリームID)
7. レポートと分析
7.1 YouTube Analytics API
エンドポイント: `GET https://youtubeanalytics.googleapis.com/v2/reports`
メソッド: `reports.query`
パラメータ:
`ids` (例: `channel==MINE` などの識別子)
`startDate` (例: `2023-01-01`)
`endDate` (例: `2023-01-31`)
`metrics` (例: `views,estimatedMinutesWatched`)
その他のフィルターやディメンション
8. その他のAPI
8.1 動画カテゴリの取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/videoCategories`
メソッド: `videoCategories.list`
パラメータ:
`part` (例: `snippet`)
`regionCode` (例: `US`)
8.2 ガイドカテゴリーの取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/guideCategories`
メソッド: `guideCategories.list`
パラメータ:
`part` (例: `snippet`)
`regionCode` (例: `US`)
8.3 地域の取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/i18nRegions`
メソッド: `i18nRegions.list`
パラメータ:
`part` (例: `snippet`)
8.4 言語の取得
エンドポイント: `GET https://www.googleapis.com/youtube/v3/i18nLanguages`
メソッド: `i18nLanguages.list`
パラメータ:
`part` (例: `snippet`)
以上がYouTube Data API v3における主要なエンドポイントと機能の概要です。詳細なAPIリクエストやレスポンスの形式については、YouTube Data API v3の公式ドキュメントを参照することをお勧めします。