Created
October 15, 2018 18:38
-
-
Save productioncoder/20ac5928ece5f81b75f16f74593518b7 to your computer and use it in GitHub Desktop.
Youtube API mostPopularVideos request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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