Ken Ingram
Ken Ingram

Reputation: 1608

Whay are these same Youtube API REST urls returning different results?

My code uses this URL https://www.googleapis.com/youtube/v3/channels?part=id&snippet&id=UC9ctsJZ2aD1nCexfqj342NQ&key=[API_KEY] which returns

{
  "kind": "youtube#channelListResponse",
  "etag": "69nKH4yrkGqjpjRH2T_M86dyIUI",
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "A0IqlEsff608TjGHRdSAoqyeaiw",
      "id": "UC9ctsJZ2aD1nCexfqj342NQ"
    }
  ]
}

The sample code at https://developers.google.com/youtube/v3/docs/channels/list has this call

curl \
  'https://youtube.googleapis.com/youtube/v3/channels?part=id%2C%20snippet&id=UC9ctsJZ2aD1nCexfqj342NQ&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed

And it returns the data I'm expecting:

{
  "kind": "youtube#channelListResponse",
  "etag": "oMV3kRZIiTu9TJSfDOaPpFGwsV0",
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "-XETGcPmF-U5W8ONzQEJ9R8w-OI",
      "id": "UC9ctsJZ2aD1nCexfqj342NQ",
      "snippet": {
        "title": "Better Bachelor",
        "description": "Better Bachelor is a channel for open minded men (and women if so inclined) to talk about current events, news, opinions, humor and ways to better yourself and find happiness and understanding in today's society. This is an open forum where comments, talking points, concerns and discussion about topics are encouraged. Most content is focused towards single men's issues but may be applicable to others. I focus on viewing many issues from multiple or under represented angles.",
        "customUrl": "@betterbachelor",
        "publishedAt": "2019-02-08T10:23:44Z",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9WcURyY8M4f-RKmm8LrlneJjRxEcPeKhfefPeXXA=s88-c-k-c0x00ffffff-no-rj",
            "width": 88,
            "height": 88
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9WcURyY8M4f-RKmm8LrlneJjRxEcPeKhfefPeXXA=s240-c-k-c0x00ffffff-no-rj",
            "width": 240,
            "height": 240
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9WcURyY8M4f-RKmm8LrlneJjRxEcPeKhfefPeXXA=s800-c-k-c0x00ffffff-no-rj",
            "width": 800,
            "height": 800
          }
        },
        "localized": {
          "title": "Better Bachelor",
          "description": "Better Bachelor is a channel for open minded men (and women if so inclined) to talk about current events, news, opinions, humor and ways to better yourself and find happiness and understanding in today's society. This is an open forum where comments, talking points, concerns and discussion about topics are encouraged. Most content is focused towards single men's issues but may be applicable to others. I focus on viewing many issues from multiple or under represented angles."
        },
        "country": "US"
      }
    }
  ]
}

I can't see why snippet is being left out of the response for my API call.

Upvotes: 0

Views: 200

Answers (1)

mmixLinus
mmixLinus

Reputation: 1714

Your URL is slightly incorrect.

Your code says &part=id&snippet& but the YouTube example says &part=id, snippet& (with ", " escaped to %2C%20).

Upvotes: 2

Related Questions