videoyoutubeyoutube-apiyoutube-channels

Youtube api v3 cannot retrieve all videos from a channel


I am trying to use youtube data api to get all videos from a channel. But it didn't work for a particular channel. (It works for several other channels.)

As you can see from the screenshot, this channel has 135 videos.

enter image description here

However, I used playlistitems and search api, as below. They only return 9 videos. What is the problem here? Thanks.

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UUhTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY} 

GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UChTMiw43iw4w-ggOEXmPtfg&maxResults=50&type=video&key={YOUR_API_KEY}

Solution

  • Basically you're dealing with two different channels with the same title but this is acceptable because of the customUrls are different, here the details:

    1. DharmaYogaCenter: UChTMiw43iw4w-ggOEXmPtfg - title: DharmaYogaCenter

    GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UChTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY}

    ``` json 
    {
        "title": "DharmaYogaCenter",
        "description": "We are a full yoga center located in Bremerton Washington.  We believe yoga and meditation is for everyone.  Stop by our Yoga Center and enjoy a blissful meditation, yoga class or just some good community.  We offer many free classes every month.  www.dharmayogacenter.net",
        "customUrl": "DharmaYogaCenter",
        "publishedAt": "2009-06-11T21:43:56.000Z",
        ...
        "relatedPlaylists": {
         "uploads": "UChTMiw43iw4w-ggOEXmPtfg",
        ...
        "videoCount": "9"
        ...
    ```
    

    You can check there are only few videos in here: uploaded videos in channel UC8hnoz74NP5V5sxkuxXk2kA

    "youtube#channel" "id": UChTMiw43iw4w-ggOEXmPtfg

    GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UChTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY} get the playlist id of channel's "uploads": "UUhTMiw43iw4w-ggOEXmPtfg"

    uploads playlist: UUhTMiw43iw4w-ggOEXmPtfg "totalResults": 9

    GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UUhTMiw43iw4w-ggOEXmPtfg&key={YOUR_API_KEY}

    {
     "kind": "youtube#playlistItemListResponse",
     "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/yvjEzYc-CE8RBoXkFDTMPf_O1XM\"",
     "pageInfo": {
      "totalResults": 9,
      "resultsPerPage": 50
     },...
    

    2. TheDharmaTube: UC8hnoz74NP5V5sxkuxXk2kA - title: DharmaYogaCenter

    GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UC8hnoz74NP5V5sxkuxXk2kA&key={YOUR_API_KEY}

    { 
        "title": "DharmaYogaCenter",
        "description": "Be receptive",
        "customUrl": "TheDharmaTube",
        "publishedAt": "2011-02-24T22:54:31.000Z",
        ...
        "relatedPlaylists": {
         "uploads": "UU8hnoz74NP5V5sxkuxXk2kA",
        ...
        "videoCount": "142"
    

    You can check there are a lot more videos in here: uploaded videos in channel UC8hnoz74NP5V5sxkuxXk2kA ..scroll down once opened to load all the videos

    "youtube#channel" "id": UC8hnoz74NP5V5sxkuxXk2kA

    GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UC8hnoz74NP5V5sxkuxXk2kA&key={YOUR_API_KEY} get the playlist id of channel's "uploads": "UU8hnoz74NP5V5sxkuxXk2kA"

    uploads playlist: UU8hnoz74NP5V5sxkuxXk2kA "totalResults": 142

    GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=UU8hnoz74NP5V5sxkuxXk2kA&key={YOUR_API_KEY} "totalResults": 142,

    {
     "kind": "youtube#playlistItemListResponse",
     "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/jm3DhRxnqdMzu1DGtIoiLbpEFY4\"",
     "nextPageToken": "CDIQAA",
     "pageInfo": {
      "totalResults": 142,
      "resultsPerPage": 50
     },...