Skip to content

Pagination

listArchives returns a Page<Archive> with cursor-based pagination:

const page = await client.listArchives("youtube", channelId);
console.log(page.items); // Archive[]
console.log(page.cursor); // string | undefined — pass to get next page
console.log(page.hasMore); // boolean — true if more pages exist
console.log(page.total); // number | undefined — total count (if available)
let cursor: string | undefined;
const allArchives: Archive[] = [];
do {
const page = await client.listArchives("youtube", channelId, cursor);
allArchives.push(...page.items);
cursor = page.cursor;
} while (cursor);
console.log(`Fetched ${allArchives.length} archives`);
const MAX_PAGES = 3;
let cursor: string | undefined;
const archives: Archive[] = [];
for (let i = 0; i < MAX_PAGES; i++) {
const page = await client.listArchives("twitch", channelId, cursor);
archives.push(...page.items);
cursor = page.cursor;
if (!cursor) break;
}

Pass ArchiveListOptions to filter results by period, sort order, or video type (platform support varies):

const page = await client.listArchives(
"twitch", // platform
channelId, // channel ID
undefined, // cursor (first page)
20, // page size
{
// filter options
period: "week",
sort: "views",
videoType: "highlight",
},
);
OptionValuesDescription
period"all", "day", "week", "month"Time range filter
sort"time", "trending", "views"Sort order
videoTypePlatform-specific (e.g., "archive", "highlight", "upload" for Twitch)Video type filter

listBroadcasts returns all currently active broadcasts for a channel. No pagination is needed — broadcasts are typically few.

const streams = await client.listBroadcasts("twitch", channelId);
for (const stream of streams) {
console.log(`${stream.title}${stream.viewerCount} viewers`);
}
  • Advanced — OpenTelemetry and direct plugin access