Youtube data api v3 - how to request only part of a snippet in playlists?

When I fetch a video list from a playlist with youtube api v3 data (using youtube.playlists.list), I can define the list of parts to retrieve with a "parts" parameter to minimize the data load.

The api asserts (multiple places) where a property with child properties is requested, it will include all child properties as well. But I can't find anywhere how to restrict the request to a child property without getting all the other parts?

In particular, I'm interested in a specific thumbnail, but not in identifiers, descriptions, titles, other thumbs. So how do I specify the child property (gran) without getting all the parent and sibling properties as well?

This is what the request looks like:

gapi.client.request({
    'path': '/youtube/v3/playlistItems',
    'method': 'get',
    'params' : {
        'part' : 'id, snippet.thumbnails.default',
        'maxResults': numberOfItems,
        'playlistId': playlistId,
        'order': 'date'
    }
}).execute(function (jsonResp, rawResp) {
    // do the funky chicken dance
});

      

I've tried the following:

part : 'snippet.thumbnails.default',

part : 'snippet#thumbnails#default',

part : 'default'

      

It didn't work.

But I could bark the wrong tree here? Is it too much of a hassle to break a piece apart? Should I just take the whole snippet and dig out some of the clients' interests?

Thanks in advance.

+3


source to share


1 answer


Use the fields parameter to specify which subset you want to get:



gapi.client.request({
    'path': '/youtube/v3/playlistItems',
    'method': 'get',
    'params' : {
        'part' : 'id, snippet',
        'maxResults': numberOfItems,
        'playlistId': playlistId,
        'order': 'date',
        'fields': 'items(snippet/thumbnails/default)'
    }
}).execute(function (jsonResp, rawResp) {
    // do the funky chicken dance
});

      

+3


source







All Articles