Pagination
Fetching Archives
Section titled “Fetching Archives”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 pageconsole.log(page.hasMore); // boolean — true if more pages existconsole.log(page.total); // number | undefined — total count (if available)Fetching Multiple Pages
Section titled “Fetching Multiple Pages”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`);Fetching a Limited Number of Pages
Section titled “Fetching a Limited Number of Pages”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;}Filtering Archives
Section titled “Filtering Archives”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", },);| Option | Values | Description |
|---|---|---|
period | "all", "day", "week", "month" | Time range filter |
sort | "time", "trending", "views" | Sort order |
videoType | Platform-specific (e.g., "archive", "highlight", "upload" for Twitch) | Video type filter |
Broadcasts
Section titled “Broadcasts”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`);}Next Steps
Section titled “Next Steps”- Advanced — OpenTelemetry and direct plugin access