🖥

Youtube API でチャンネルの動画一覧を得る

2023/09/01に公開

URLの例

https://www.googleapis.com/youtube/v3/search?key=[API_KEY]&part=id,snippet&channelId=[CHANNEL_ID]&maxResults=50

結果の例

{
  "kind": "youtube#searchListResponse",
  "etag": "R4I4J-eQX-wbhqyIqeiXp6IpDLw",
  "nextPageToken": "CDIQAA",
  "regionCode": "JP",
  "pageInfo": {
    "totalResults": 2585,
    "resultsPerPage": 50
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "2njzLJdx8kgKxsCgqjkejkcGo6w",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCCAjS7ufSdGeYla5B_5d-Rg"
      },
      "snippet": {
        "publishedAt": "2013-02-20T03:26:49Z",
        "channelId": "UCCAjS7ufSdGeYla5B_5d-Rg",
        "title": "いなうらゆうま 稲浦悠馬",
        "description": "ゲーム実況、猫や犬、日常など.",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/PFePiqA-3wx7mQlYfsou1GBT63olck6P1MbKLo57sSYXkKxtBaX5pj_xTc8IB2e5hmKtMOT0HMU=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/PFePiqA-3wx7mQlYfsou1GBT63olck6P1MbKLo57sSYXkKxtBaX5pj_xTc8IB2e5hmKtMOT0HMU=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/PFePiqA-3wx7mQlYfsou1GBT63olck6P1MbKLo57sSYXkKxtBaX5pj_xTc8IB2e5hmKtMOT0HMU=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "いなうらゆうま 稲浦悠馬",
        "liveBroadcastContent": "none",
        "publishTime": "2013-02-20T03:26:49Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "3sBEM9PwTYFyXGjq9zfBmi1ptAo",
      "id": {
        "kind": "youtube#video",
        "videoId": "aMkvNDf1IXU"
      },
      "snippet": {
        "publishedAt": "2018-12-24T06:31:05Z",
        "channelId": "UCCAjS7ufSdGeYla5B_5d-Rg",
        "title": "\u202a#うし君 が #行方不明 だ! #390マート から #3coins へ向かう! でも #バットマン とか #パンダコパンダ の #エコバック とかあるし #クリスマスイプ だし何か買いたいな!\u202c",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/aMkvNDf1IXU/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/aMkvNDf1IXU/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/aMkvNDf1IXU/hqdefault.jpg",
            "width": 480,
            "height": 360
          }
        },
        "channelTitle": "いなうらゆうま 稲浦悠馬",
        "liveBroadcastContent": "none",
        "publishTime": "2018-12-24T06:31:05Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "sRkYSVaHY0JGJGC8nCAvXrceDmQ",
      "id": {
        "kind": "youtube#video",
        "videoId": "zURXkHE4OME"
      },
...

この中の nextPageToken を利用するとページめくりができる模様

例:

https://www.googleapis.com/youtube/v3/search?key=[API_KEY]&part=id,snippet&channelId=[CHANNEL_ID]&maxResults=50&pageToken=CDIQAA

参考

https://developers.google.com/youtube/v3/docs/search/list?hl=ja&apix=true&apix_params={"part"%3A["id"]%2C"channelId"%3A"UCCAjS7ufSdGeYla5B_5d-Rg"%2C"maxResults"%3A1000}#try-it

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2022-11-27

Discussion