Get YouTube daily views
Returns daily view counts for a YouTube video including views, watch time, and subscriber changes. Requires yt-analytics.readonly scope (re-authorization may be needed). YouTube finalizes analytics with a ~3-day delay; by default only finalized days are returned, and an explicit endDate can reach into the delay window (see the endDate parameter). Max 90 days, defaults to last 30 days.
API key authentication - use your Zernio API key as a Bearer token
In: header
Query Parameters
The YouTube video ID (e.g., "dQw4w9WgXcQ")
The Zernio account ID for the YouTube account
Start date (YYYY-MM-DD). Defaults to 30 days ago.
dateEnd date (YYYY-MM-DD). Defaults to 3 days ago, the newest fully finalized day (YouTube finalizes analytics with a ~3-day delay). An explicit endDate is honored up to today: days inside the delay window are provisional and may still be revised by YouTube (see provisionalSince in the response), and days YouTube has not processed yet are omitted from dailyViews.
dateResponse Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.analytics.getYouTubeDailyViews({ query: { videoId: 'video_abc123', accountId: 'account_abc123', },});console.log(data);{
"success": true,
"videoId": "dQw4w9WgXcQ",
"durationSeconds": 213,
"dateRange": {
"startDate": "2025-01-01",
"endDate": "2025-01-12"
},
"totalViews": 12345,
"dailyViews": [
{
"date": "2025-01-12",
"views": 1234,
"estimatedMinutesWatched": 567.5,
"averageViewDuration": 45.2,
"averageViewPercentage": 21.2,
"subscribersGained": 10,
"subscribersLost": 2,
"likes": 89,
"comments": 12,
"shares": 5
},
{
"date": "2025-01-11",
"views": 987,
"estimatedMinutesWatched": 432.1,
"averageViewDuration": 43.8,
"averageViewPercentage": 20.6,
"subscribersGained": 8,
"subscribersLost": 1,
"likes": 67,
"comments": 8,
"shares": 3
}
],
"lastSyncedAt": "2025-01-15T12:00:00Z",
"scopeStatus": {
"hasAnalyticsScope": true
}
}{
"error": "videoId is required"
}{
"error": "Unauthorized"
}{
"error": "Analytics add-on required",
"code": "analytics_addon_required"
}{
"error": "Access denied to this account"
}{
"success": false,
"error": "To access daily video analytics, please reconnect your YouTube account to grant the required permissions.",
"code": "youtube_analytics_scope_missing",
"scopeStatus": {
"hasAnalyticsScope": false,
"requiresReauthorization": true,
"reauthorizeUrl": "https://accounts.google.com/o/oauth2/auth?client_id=..."
}
}{
"success": false,
"error": "string"
}Get YouTube channel insights GET
Returns channel-scoped aggregate metrics from YouTube Analytics API v2. Saves you from looping /v1/analytics/youtube/daily-views over every video when you only need channel totals. Response shape matches /v1/analytics/instagram/account-insights so the same client handling works. Requires yt-analytics.readonly scope (412 with reauthorizeUrl if missing). Data has a 2-3 day delay (endDate is clamped accordingly). Max 89 days, defaults to last 30 days. Requires the Analytics add-on. NOT exposed: impressions (Studio thumbnail impressions) and impressionsClickThroughRate. YouTube Analytics API v2 does not expose these for any principal type, not channel owners, not Partner Program channels, not content owners with CMS access. The only way to get them is Studio CSV export. This is a Google-side limitation.
Get YouTube video retention curve GET
Returns the audience retention curve for a single YouTube video, plus the video's duration for rendering the curve on a time axis. The curve has up to 100 points (elapsedVideoTimeRatio 0.01-1.0) aggregated over the whole date range; YouTube does not support per-day retention breakdowns. audienceWatchRatio is the absolute share of viewers watching at that point in the video and can exceed 1 (rewinds and looping, common on Shorts). relativeRetentionPerformance compares against videos of similar length (0 = worst, 0.5 = median, 1 = best). YouTube returns an empty curve for videos with very few views or before analytics processing completes (2-3 day delay). Requires yt-analytics.readonly scope (re-authorization may be needed).