Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created October 15, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/20ac5928ece5f81b75f16f74593518b7 to your computer and use it in GitHub Desktop.
Save productioncoder/20ac5928ece5f81b75f16f74593518b7 to your computer and use it in GitHub Desktop.
Youtube API mostPopularVideos request
export function buildMostPopularVideosRequest(amount = 12, loadDescription = false, nextPageToken) {
let fields = 'nextPageToken,prevPageToken,items(contentDetails/duration,id,snippet(channelId,channelTitle,localized/title,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,
}, null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment