Skip to main content
RapidDev - Software Development Agency

How to Automate YouTube Analytics Reports using the API

Pull YouTube channel performance data using YouTube Analytics API v2 reports.query. The critical recent change: youtube.readonly scope is now REQUIRED in addition to yt-analytics.readonly — integrations that only had the analytics scope will break. Service accounts DO NOT work with YouTube APIs — returns NoLinkedYouTubeAccount. The YouTube Data API has a 10,000 quota unit daily cap per project (not per user) that resets at midnight Pacific Time. Analytics API quota is separate and visible only in Cloud Console.

Need help automating? Talk to an expert
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate6 min read30–60 minutesYouTubeLast updated May 2026RapidDev Engineering Team
TL;DR

Pull YouTube channel performance data using YouTube Analytics API v2 reports.query. The critical recent change: youtube.readonly scope is now REQUIRED in addition to yt-analytics.readonly — integrations that only had the analytics scope will break. Service accounts DO NOT work with YouTube APIs — returns NoLinkedYouTubeAccount. The YouTube Data API has a 10,000 quota unit daily cap per project (not per user) that resets at midnight Pacific Time. Analytics API quota is separate and visible only in Cloud Console.

Quick facts about this guide
FactValue
PlatformYouTube
Rate limitsYouTube Data API: 10,000 quota units/day PER PROJECT, resets midnight Pacific…
DifficultyIntermediate
Time required30–60 minutes
Last updatedMay 2026

API Quick Reference

Auth

Rate limit

YouTube Data API: 10,000 quota units/day PER PROJECT, resets midnight Pacific Time. Analytics API: separate quota visible in Cloud Console.

Format

SDK

REST only

YouTube Analytics API v2 — Performance Reports

YouTube Analytics API v2 provides access to channel performance metrics including views, watch time, subscribers, revenue, and audience demographics. The core endpoint is youtubeAnalytics.reports.query which accepts dimensions (day, video, country, deviceType, trafficSourceType) and metrics (views, likes, estimatedMinutesWatched, averageViewDuration, subscribersGained). For revenue data, add yt-analytics-monetary.readonly scope. There are no webhooks — this is purely pull-based. A common companion call is YouTube Data API v3 videos.list to enrich analytics data with video metadata (titles, thumbnails). These two APIs share the same 10,000 quota units/day per project limit.

Base URLhttps://youtubeanalytics.googleapis.com/v2 (Analytics) / https://www.googleapis.com/youtube/v3 (Data)

Authentication

Key endpoints

GET

The primary analytics endpoint. Query metrics over a date range with optional dimensions and filters. Required scopes: both youtube.readonly AND yt-analytics.readonly (or monetary variant).

GET

Get channel metadata including the channel ID needed for analytics queries. Use mine=true to get the authenticated user's channel ID.

GET

Get video metadata to enrich analytics data with titles, thumbnails, and descriptions. Cheap at 1 unit per call — use to look up titles when you have video IDs from analytics.

GET

List analytics groups — up to 500 videos, playlists, channels, or assets grouped for combined analytics. Useful for tracking a series or campaign.

Step-by-step automation

1

Step 1: Set Up OAuth Authentication

Configure OAuth 2.0 with both youtube.readonly and yt-analytics.readonly scopes. Service accounts do NOT work with YouTube APIs.

request.sh
1# Step 1: Build the authorization URL and open in browser
2# Replace with your client_id and redirect_uri
3https://accounts.google.com/o/oauth2/v2/auth?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&scope=https://www.googleapis.com/auth/youtube.readonly%20https://www.googleapis.com/auth/yt-analytics.readonly&access_type=offline&prompt=consent
4
5# Step 2: Exchange the code for tokens
6curl -X POST https://oauth2.googleapis.com/token \
7 -d 'code=AUTH_CODE&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&redirect_uri=REDIRECT_URI&grant_type=authorization_code'
2

Step 2: Get Your Channel ID

Most analytics queries require your channel ID. Get it from channels.list with mine=true. This costs only 1 quota unit — cache this ID to avoid repeated calls.

request.sh
1# Get the authenticated user's channel ID
2curl -H 'Authorization: Bearer ACCESS_TOKEN' \
3 'https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&mine=true'
4
5# Lookup by YouTube handle
6curl -H 'Authorization: Bearer ACCESS_TOKEN' \
7 'https://www.googleapis.com/youtube/v3/channels?part=snippet&forHandle=@YourChannelHandle'
3

Step 3: Query Analytics Data

Query performance data with reports.query. Build flexible queries with different dimensions for different report types: daily overview, per-video breakdown, geographic distribution.

request.sh
1# Daily overview for the last 30 days
2curl -H 'Authorization: Bearer ACCESS_TOKEN' \
3 'https://youtubeanalytics.googleapis.com/v2/reports?ids=channel%3D%3DMINE&startDate=2025-10-16&endDate=2025-11-15&metrics=views%2Clikes%2CestimatedMinutesWatched%2CaverageViewDuration%2CsubscribersGained&dimensions=day&sort=day'
4
5# Top 10 videos by views in last 30 days
6curl -H 'Authorization: Bearer ACCESS_TOKEN' \
7 'https://youtubeanalytics.googleapis.com/v2/reports?ids=channel%3D%3DMINE&startDate=2025-10-16&endDate=2025-11-15&metrics=views%2CestimatedMinutesWatched%2CaverageViewDuration&dimensions=video&sort=-views&maxResults=10'
4

Step 4: Enrich Analytics with Video Metadata

When analytics return video IDs, fetch titles and metadata from YouTube Data API. Batch up to 50 IDs per videos.list call at 1 quota unit total.

request.sh
1# Get metadata for up to 50 videos in one call (1 quota unit)
2curl -H 'Authorization: Bearer ACCESS_TOKEN' \
3 'https://www.googleapis.com/youtube/v3/videos?part=snippet,statistics&id=VIDEO_ID_1%2CVIDEO_ID_2%2CVIDEO_ID_3'
5

Step 5: Export Report to Google Sheets

Write the analytics report to a Google Sheet for easy sharing with stakeholders. Use values.append with all metrics in one call.

request.sh
1# Write analytics summary rows to Google Sheets
2curl -X POST \
3 -H 'Authorization: Bearer ACCESS_TOKEN' \
4 -H 'Content-Type: application/json' \
5 'https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/Reports:append?valueInputOption=USER_ENTERED' \
6 -d '{
7 "values": [
8 ["2025-11-01", 14523, 87891, 365, 142],
9 ["2025-11-02", 12847, 77234, 348, 128]
10 ]
11 }'

Complete working code

Weekly YouTube analytics report generator: pulls 7-day and 30-day performance data, enriches with video titles, calculates key metrics, and exports a structured JSON report. Designed to run as a scheduled job.

Error handling

Cause

You're missing the youtube.readonly scope. As of a recent API update, reports.query now REQUIRES youtube.readonly in addition to yt-analytics.readonly. Existing integrations that only requested yt-analytics.readonly will start returning this error.

Fix

Cause

You're trying to use a Service Account with YouTube APIs. YouTube APIs do not support service accounts — they only work with OAuth 2.0 (user authorization). A service account has no YouTube channel linked to it.

Fix

Cause

You've used all 10,000 YouTube Data API quota units for the day. The quota resets at midnight Pacific Time. This is a per-project limit shared across all users and API keys in the project.

Fix

Cause

Some dimension combinations are invalid. Not all metrics can be combined with all dimensions — for example, revenue metrics cannot be combined with the video dimension in the same query. Also, ageGroup and gender cannot be combined with geographic dimensions.

Fix

Cause

YouTube Analytics data is not real-time. There is typically a 24–72 hour processing delay before analytics data is available. Querying for 'today' or 'yesterday' often returns empty or incomplete rows.

Fix

Rate limits & throttling

Security checklist

  • Store OAuth tokens (token.json) with restricted file permissions and never commit to version control — refresh tokens provide permanent access to the YouTube account
  • Request only the scopes your application actually needs — use yt-analytics.readonly (no revenue) unless your app specifically requires revenue data
  • Add yt-analytics-monetary.readonly scope only if the channel is in the YouTube Partner Program — requesting it for non-partner channels causes scope acceptance confusion
  • Implement token revocation in your app settings to allow users to disconnect their YouTube account
  • Rate-limit your own scheduled jobs — running analytics queries too frequently on multiple accounts from the same GCP project can exhaust the shared 10,000 unit daily quota
  • Treat analytics data as confidential — view counts, revenue, and audience demographics are sensitive business data that should not be stored in unencrypted form
  • For multi-channel analytics services, use separate GCP projects per customer to isolate quota and prevent one customer's usage from affecting another's
  • Log all API calls with timestamps to help diagnose quota exhaustion and identify which operations consume the most units

Automation use cases

No-code alternatives

Don't want to write code? These platforms can automate the same workflows visually.

Zapier

YouTube integration in Zapier supports triggers for new videos and comments, but does NOT provide analytics query access. For analytics, Zapier connects to Google Sheets where you can use IMPORTDATA formulas — limited compared to direct API access.

Pros
    Cons

      Make (Integromat)

      YouTube module in Make supports video and playlist management but limited analytics. Use the HTTP module to call YouTube Analytics API directly with your OAuth token for full reports.query access.

      Pros
        Cons

          n8n

          YouTube node plus HTTP Request node for Analytics API calls. Best no-code option for full Analytics API access with scheduling. Store results in Google Sheets or Airtable via dedicated nodes.

          Pros
            Cons

              Best practices

              • Request both youtube.readonly and yt-analytics.readonly scopes — youtube.readonly is now required for Analytics API even if you only need analytics data
              • Never use service accounts for YouTube APIs — they are fundamentally unsupported and will always return NoLinkedYouTubeAccount
              • Avoid search.list in analytics workflows — it costs 100 quota units per call and depletes your 10,000 unit daily budget in 100 calls
              • Account for 24–72 hour analytics data delay — use endDate at least 2 days before today for reliable data in automated reports
              • Batch video metadata lookups: pass up to 50 video IDs in one videos.list call instead of one call per video
              • Cache channel IDs and report data locally — the channel ID never changes, and historical analytics data doesn't change after processing
              • Use the 'MINE' identifier in the ids parameter (channel==MINE) rather than hard-coding channel IDs — this makes your code portable across channels
              • Monitor your project's quota usage in Cloud Console > APIs & Services > Quotas regularly — you want to see warning signs before hitting the daily limit

              Ask AI to help

              Copy one of these prompts to get a personalized, working implementation.

              ChatGPT / Claude Prompt

              I'm building a YouTube analytics report automation using YouTube Analytics API v2. Key constraints: (1) BOTH youtube.readonly AND yt-analytics.readonly scopes are required — OAuth only, NO service accounts, (2) 10,000 quota units/day per project resets midnight Pacific Time, search.list costs 100 units so avoid it, (3) batch video metadata lookups with up to 50 IDs per videos.list call. I need weekly reports with daily breakdown, top 10 videos, and traffic sources. Use Python with google-api-python-client. Export to JSON and CSV.

              Lovable / V0 Prompt

              Create a YouTube analytics dashboard. After OAuth login with youtube.readonly and yt-analytics.readonly scopes, show: (1) 30-day overview cards (total views, watch time, subscriber change), (2) line chart of daily views, (3) table of top 10 videos with titles, views, and average view duration. Data comes from YouTube Analytics API v2 reports.query. Store token in Supabase. Handle 10,000 daily quota limit gracefully with caching — don't re-fetch data that was pulled today.

              Frequently asked questions

              Why do I need youtube.readonly scope for the Analytics API? That seems redundant.

              It does seem redundant, but it's a real requirement. Google updated the Analytics API to require youtube.readonly in addition to yt-analytics.readonly. If your integration predates this change and only requested yt-analytics.readonly, you'll now get 403 insufficientPermissions errors on reports.query calls. Add youtube.readonly to your scopes and have users re-authorize your app.

              Can I use a service account to automate YouTube analytics pulls on a schedule?

              No. YouTube APIs fundamentally do not support service accounts — they return NoLinkedYouTubeAccount because a service account has no YouTube channel. You must use OAuth 2.0 with a real user who has authorized your app. For scheduled jobs, store the refresh token securely and use it to get new access tokens automatically without user interaction.

              Why is my analytics data empty or showing zeros for recent dates?

              YouTube Analytics data has a 24–72 hour processing delay. Data for today or yesterday is typically incomplete or absent. For reliable report data, use endDate set to at least 2–3 days ago. For scheduled weekly reports, a good pattern is: run on Sunday, report on the week ending Thursday (3 days ago).

              The 10,000 daily quota feels very restrictive. How do I get more?

              Submit the YouTube API Services Audit and Quota Extension Form at console.cloud.google.com. You'll need to describe your application, provide usage patterns, and demonstrate compliance with YouTube API Terms of Service. There is no monetary cost for quota increases — it's a compliance review. The process typically takes 2–4 weeks. In the meantime, optimize your code: avoid search.list (100 units), batch video metadata lookups, and cache results.

              How do I get revenue and CPM data in my analytics reports?

              Add the yt-analytics-monetary.readonly scope to your OAuth scopes, and your channel must be in the YouTube Partner Program (monetized). Then add revenue metrics to your reports.query: estimatedRevenue, grossRevenue, adImpressions, monetizedPlaybacks, cpm, playbackBasedCpm. Channels not in YPP will get zero values for revenue metrics even with the scope authorized.

              Can RapidDev build a YouTube analytics dashboard for my channel or agency?

              Yes. If you need a custom analytics dashboard — showing performance trends, comparing videos, tracking campaign ROI, or managing multiple channels — RapidDev can build that. We handle the YouTube OAuth integration, data caching to stay within quota limits, and real-time visualization so you always have the insights you need.

              How do I avoid hitting the search.list quota trap in my analytics workflow?

              Don't use search.list at all for analytics workflows. It costs 100 quota units per call — calling it 100 times depletes your entire 10,000 daily quota. Instead, use videos.list with specific video IDs (1 unit per call for up to 50 videos), or channels.list with mine=true to get your video list from your channel's contentDetails. If you need to find videos by keyword, do that once and store the IDs rather than searching every time.

              RapidDev

              Need this automated?

              Our team has built 600+ apps with API automations. We can build this for you.

              Book a free consultation
              Matt Graham

              Written by

              Matt Graham · CEO & Founder, RapidDev

              1,000+ client projects delivered. Columbia University & Harvard Business School alumnus, U.S. Navy veteran. About the author →

              Want this built for you?

              We ship production apps at a fixed price — $13K–$25K, 6–10 weeks, source code yours. You've seen what it takes; we do it every week.

              Get a fixed-price quote

              We put the rapid in RapidDev

              Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.