A comprehensive AI-powered YouTube analytics backend API that uses multiple AI agents to analyze YouTube videos, extract insights, and generate content. Built with Flask, LangChain, and OpenAI for production-ready AI processing.
- Analytics Agent: Analyzes video performance, comments, and transcripts
- Critique Agent: Reviews and improves outputs using ReAct methodology
- Content Agent: Generates social media posts and images
- Orchestrator Agent: Coordinates all agents and manages workflows
- Video performance metrics and engagement analysis
- Comment sentiment analysis with sarcasm detection
- Comment categorization (questions, feedback, appreciation, etc.)
- Video transcript analysis and topic extraction
- Channel-level analytics
- Multi-video comparison
- Advanced Sentiment Analysis: VADER sentiment analysis with sarcasm detection
- Language Detection: Automatic English comment filtering
- Tagged Insights: 5-category insights (High Impact, Medium Impact, Content, Sponsorship, Comment Sentiment)
- Community Health Assessment: Overall community sentiment and engagement quality
- Content Performance Metrics: Engagement rates, comment ratios, and performance scoring
- Priority Recommendations: Actionable insights ranked by impact
- Benchmark Comparisons: Industry standard comparisons for engagement and sentiment
- Enhanced Metrics: Sentiment scores, community health scores, and performance assessments
- Content Performance Prediction: Predict how well a video will perform
- Audience Behavior Analysis: Identify influencers, engagement patterns, topic clusters
- Content Optimization Suggestions: Title, thumbnail, tag, and SEO improvements
- Content Gap Analysis: Find underserved topics in your niche
- Trend Analysis: Identify trending topics and content patterns
- Competitor Analysis: Compare performance against competitors
- Market Position Analysis: Understand your competitive position
- AI-generated social media posts for multiple platforms
- Platform-optimized content (Twitter, Instagram, LinkedIn, Facebook)
- Hashtag optimization
- Image generation for posts
- Content critique and improvement
- ReAct methodology for quality assurance
- Asynchronous processing
- Workflow tracking and history
- Real-time status monitoring
- Comprehensive error handling
- Python 3.8+
- OpenAI API key (for production)
- YouTube Data API v3 key
- Optional: Ollama for local development
-
Clone the repository
git clone <repository-url> cd charizard
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp env.example .env # Edit .env with your API keys
Create a .env file with the following variables:
# YouTube API Configuration
YOUTUBE_API_KEY=your_youtube_api_key_here
# OpenAI Configuration (Primary for production)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4o-mini
# Ollama Configuration (Fallback for development)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=gemma3
# Flask Configuration
PORT=5000
FLASK_ENV=production
FLASK_DEBUG=False
# Logging Configuration
LOG_LEVEL=INFO
# Database Configuration (if needed)
DATABASE_URL=sqlite:///analytics.db- Go to Google Cloud Console
- Create a new project or select existing one
- Enable YouTube Data API v3
- Create credentials (API Key)
- Add the API key to your
.envfile
- Go to OpenAI Platform
- Create an account or sign in
- Navigate to API Keys section
- Create a new API key
- Add the API key to your
.envfile
python src/app.pyThe server will start on http://localhost:8000
GET /healthPOST /api/analyze
Content-Type: application/json
{
"video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}Response includes:
- Video metadata (title, channel, views, likes, comments)
- Sentiment analysis with sarcasm detection
- Tagged insights (5 categories with actionable recommendations)
- Additional metrics (engagement rate, sentiment score, community health)
- Priority recommendations ranked by impact
- Benchmark comparisons against industry standards
POST /api/extract-video-id
Content-Type: application/json
{
"video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}GET /routesPOST /api/analytics
Content-Type: application/json
{
"video_id": "dQw4w9WgXcQ"
}POST /api/video/enhanced-insights
Content-Type: application/json
{
"video_id": "dQw4w9WgXcQ"
}POST /api/content-gap-analysis
Content-Type: application/json
{
"channel_id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"niche_keywords": ["python", "programming", "tutorial"]
}POST /api/trend-analysis
Content-Type: application/json
{
"keywords": ["artificial intelligence", "machine learning", "AI"]
}POST /api/competitor-analysis
Content-Type: application/json
{
"channel_id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"competitor_channels": ["UC8butISFwT-Wl7EV0hUK0BQ", "UCWv7vMbMWH4-V0ZXdmDpPBA"]
}POST /api/insights/summary
Content-Type: application/json
{
"video_id": "dQw4w9WgXcQ"
}POST /api/comments
Content-Type: application/json
{
"video_id": "dQw4w9WgXcQ"
}GET /api/channel/{channel_id}POST /api/video/technical-insights
Content-Type: application/json
{
"video_id": "dQw4w9WgXcQ",
"max_results": 5
}