Enable the YouTube Analytics API in the Google Cloud Console and obtain OAuth 2.0 credentials with the yt-analytics.readonly scope.
Construct a request to the reports.query endpoint specifying ids=channel==MINE (or a specific channel ID), startDate, endDate in YYYY-MM-DD format, and the metrics you want (e.g., views, estimatedMinutesWatched, averageViewDuration).
Add optional dimensions (e.g., day, country) and filters to narrow the report scope.
Send the GET request with the access token in the Authorization header and parse the columnHeaders and rows in the JSON response.
Iterate over the rows array, matching each row's values to the corresponding column header names to build your dataset.
Known gotchas
YouTube Analytics API uses its own separate quota from the YouTube Data API; monitor both independently in the Cloud Console.
Data for the most recent 2–3 days may be incomplete or subject to revision; avoid treating very recent figures as final.
The ids parameter value must be URL-encoded when constructing the query string.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp