Answer the question
In order to leave comments, you need to log in
Youtube API how to request all videos from a channel?
Actually how? I use Node.JS and the "request" library https://github.com/request/request
I read the documentation, the maximum I can request is only 50 videos from the channel, in the response from the api server, there is a nextPageToken key, but I don’t understand how to do it a chain of requests for this very nextPageToken in order to go further along the entire chain.
`https://www.googleapis.com/youtube/v3/search?key=${key}&channelId=${channelId}&part=snippet,id&order=date&maxResults=50`;
request({url:url}, function(err, response, body){
let data = JSON.parse(body);
for(let i = 0; i < Math.fround(data.pageInfo.totalResults / maxResults); i++){
let newUrl = url + '&pageToken=' + data.nextPageToken;
request({url: newUrl}, function(err, response, body){
newUrl = url + '&pageToken=' + JSON.parse(body).nextPageToken;
console.log(JSON.parse(body).nextPageToken);
})
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question