Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Youtube API: add ability to restrict most popular videos by id
export function buildMostPopularVideosRequest(amount = 12, loadDescription = false, nextPageToken, videoCategoryId = null) {
let fields = 'nextPageToken,prevPageToken,items(contentDetails/duration,id,snippet(channelId,channelTitle,publishedAt,thumbnails/medium,title),statistics/viewCount),pageInfo(totalResults)';
if (loadDescription) {
fields += ',items/snippet/description';
}
return buildApiRequest('GET',
'/youtube/v3/videos',
{
part: 'snippet,statistics,contentDetails',
chart: 'mostPopular',
maxResults: amount,
regionCode: 'US',
pageToken: nextPageToken,
fields,
videoCategoryId,
}, null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.