Skip to main content
GET
Get Analytics

Endpoint

Description

Retrieves recent analytics data from YouTube, including views, engagement metrics, audience insights, and performance trends. This data is collected and analyzed by the Analytics & Optimization Agent.

Request

No parameters required.

Headers

No special headers required.

Response

The response structure is determined by the Analytics & Optimization Agent’s getRecentAnalytics() method. Typical fields include:
object
Time period for the analytics data.
string
ISO 8601 start date.
string
ISO 8601 end date.
object
High-level performance metrics.
number
Total video views in the period.
number
Total watch time in minutes.
number
New subscribers in the period.
number
Average view duration in seconds.
array
Best performing videos in the period.
string
YouTube video ID.
string
Video title.
number
View count.
number
Engagement rate (likes, comments, shares).
object
Audience demographic information.
array
Top viewer countries.
object
Age distribution of viewers.
object
Gender distribution.
array
AI-generated insights and recommendations from the Analytics Agent.
string
Insight type: "trend", "recommendation", "alert", etc.
string
Human-readable insight description.
string
Priority level: "high", "medium", "low".
string
Error message if the request fails.

Example Request

Example Response

Success

Error

Response Codes

Use Cases

Performance Dashboard

Build a real-time analytics dashboard:

Automated Reporting

Generate weekly performance reports:

Content Strategy Optimization

Use analytics to inform content decisions:
Analytics data is fetched from the YouTube Analytics API. The agent caches data to avoid hitting API rate limits. Data may be up to 15 minutes old.

Data Freshness

The Analytics & Optimization Agent updates data on the following schedule:
  • Real-time metrics: Updated every 15 minutes
  • Detailed analytics: Updated every 6 hours
  • Demographic data: Updated daily
  • AI insights: Regenerated every 12 hours

Privacy and Compliance

All analytics data is:
  • Aggregated and anonymized per YouTube’s terms
  • Stored securely in the local database
  • Never shared with third parties
  • Compliant with YouTube’s API Terms of Service