YouTube Data API v3 - playlistItems returning playlistNotFound

I followed the instructions in this Google video and elsewhere:

  • connect to API v3 using a static API key
  • get the download playlist id for a channel using the legacy channel id (eg "GoogleDevelopers").
  • use the playlistItems endpoint for this playlist to get a list of videos uploaded to this YouTube account.

The first two steps work and I can get the channel / playlist id but it playlistItems

returns playlistNotFound

every time (I tested it with several different YouTube accounts).

I try to check carefully for typos - I don't see anything wrong with the queries.

Any ideas, or can anyone reproduce the problem?

Sample API call (using the GoogleDevelopers feed as shown in their video) - you need to create your own API key to test this

https://www.googleapis.com/youtube/v3/channels?key= [myAPIkey ]&forUsername=GoogleDevelopers&part=id

Answer:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/9Uu_LJKSiIBlJOBZoZLkKcjhUUE\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/JgZIwrlCnsd1wzjssCxaCFp8mRU\"",
   "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw"
  }
 ]
}

      

Trying to get the first video in the playlist:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=1&key= [myAPIkey ]&playlistId=UC_x5XG1OV2P6uZZ5FSM9Ttw

{
 "error": {
  "errors": [
   {
    "domain": "youtube.playlistItem",
    "reason": "playlistNotFound",
    "message": "Not Found",
    "locationType": "parameter",
    "location": "playlistId"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

      

Note. I created a server key because it will run on the server. But I'm testing in a browser (with whitelisted IPs.) This shouldn't cause any problems? (there are still no auth errors.)

+3


source to share


1 answer


William, what you used as the playlist id is the channel id to get the list of playlists with the id needed to add contentDetails for the partial parameter.

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&maxResults=50&forUsername=GoogleDevelopers&key=<APIKEY>

      

Answer:

{
  kind: "youtube#channelListResponse",
  etag: ""iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/rGUGLTaUoy_huV1Qfc0wvulpr7M"",
  pageInfo: {
    totalResults: 1,
    resultsPerPage: 50
  },
  items: [
    {
      kind: "youtube#channel",
      etag: ""iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/Il2dF5SRdky6_tqanN3hNuDyfxc"",
      id: "UC_x5XG1OV2P6uZZ5FSM9Ttw",
      contentDetails: {
        relatedPlaylists: {
          uploads: "UU_x5XG1OV2P6uZZ5FSM9Ttw"
        },
      googlePlusUserId: "111395306401981598462"
      }
    }
  ]
}

      



Then use "UU_x5XG1OV2P6uZZ5FSM9Ttw" as the loadable playlist, so the next call looks like this:

https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=1&playlistId=UU_x5XG1OV2P6uZZ5FSM9Ttw&key=<APIKEY>

      

Answer:

{
  kind: "youtube#playlistItemListResponse",
  etag: ""iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/AqAMzBB7CuVjpCKtQDHbbIvjtMU"",
  nextPageToken: "CAEQAA",
  pageInfo: {
    totalResults: 3761,
    resultsPerPage: 1
  },
  items: [{
    kind: "youtube#playlistItem",
    etag: ""iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/qjqde7mm3USo4TmUrxDN8KdbyaQ"",
    id: "UUj6hVp42BfAXGn9SkmnI_HudylmOycmdp",
    contentDetails: {
      videoId: "tjmRUgUca1g"
    }
  }]
}

      

+1


source







All Articles