1.0.1 • Published 6 years ago

youtube-page-token v1.0.1

Weekly downloads
5
License
ISC
Repository
github
Last release
6 years ago

youtube-page-token

A function that translates a desired index to a YouTube pageToken. With the playlistItems.list method, the range of indexes that are accept has been found to be 0,100000, so that is also the restriction for this package.

Install:

npm install youtube-page-token

Usage:

var createPageToken = require('youtube-page-token');

var zero = createPageToken(0); // defaults to a token for fetching the next page
console.log(zero); // 'CAAQAA'

var one = createPageToken(1, { previous: true }); // previous page
console.log(zero); // 'CAEQAQ'

In context:

var desiredPosition = 10;
var pageToken = createPageToken(desiredPosition);

// get a page of ${maxResults} playlistItems, starting with the ${desiredPosition}th item.

buildApiRequest('GET',
                '/youtube/v3/playlistItems',
                {'maxResults': '10',
                 'part': 'snippet,contentDetails',
                 'playlistId': 'PLBCF2DAC6FFB574DE',
                 'pageToken': pageToken
                 });
1.0.1

6 years ago

1.0.0

6 years ago