A powerful web application that analyzes YouTube videos using Google's Gemini AI with URL context support. Simply paste a YouTube URL and get detailed insights about the video content.
- YouTube Video Analysis: Analyze any public YouTube video using Google's Gemini AI
- URL Context Support: Leverages Gemini's
urlContexttool for direct video processing - Beautiful Web Interface: Clean, responsive design with loading states and error handling
- RESTful API: Well-documented API endpoints for programmatic access
- Comprehensive Testing: Full test suite with 9 automated tests
- Production Ready: Deployed on Vercel with proper error handling and CORS support
- Web Interface: https://gemini-youtube-new.vercel.app
- API Endpoint:
POST /api/analyze
- Node.js 18+
- Google Gemini API key (Get one here)
-
Clone the repository
git clone https://github.com/aviz85/gemini-youtube-analyzer.git cd gemini-youtube-analyzer -
Install dependencies
npm install
-
Set up environment variables
echo "GEMINI_API_KEY=your_api_key_here" > .env
-
Run locally
# Option 1: Using Vercel dev npm run vercel-dev # Option 2: Simple Express server node -e " const express=require('express'); const app=express(); app.use(express.json(),express.static('.')); app.all('/api/*',(req,res)=>require('./api/'+req.path.split('/')[2])(req,res)); app.listen(8080,()=>console.log('β Running: http://localhost:8080')); "
-
Run tests
npm test
Endpoint: POST /api/analyze
Request Body:
{
"youtubeUrl": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"prompt": "What is this video about? Provide a detailed summary."
}Response:
{
"success": true,
"analysis": "This video is the official music video for Rick Astley's iconic song 'Never Gonna Give You Up.' It features Rick Astley singing and dancing in various locations..."
}Error Response:
{
"error": "Please provide a valid YouTube URL"
}Endpoint: GET /api/analyze
Response:
{
"message": "YouTube Analyzer API is working",
"timestamp": "2025-08-19T08:52:36.715Z",
"endpoints": {
"POST /api/analyze": "Analyze YouTube video content"
}
}GEMINI_API_KEY(required): Your Google Gemini API key
Vercel (recommended):
npm run deployOther platforms:
- The app works on any Node.js hosting platform
- API functions are in the
/apidirectory - Static files are served from the root
The project includes comprehensive tests covering:
- CORS handling
- Input validation
- YouTube URL format validation
- API error handling
- Streaming response aggregation
- Edge cases and error scenarios
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageβββ api/
β βββ analyze.js # Main YouTube analyzer endpoint
β βββ hello.js # Test endpoint
βββ __tests__/
β βββ analyze.test.js # Comprehensive test suite
βββ index.html # Beautiful web interface
βββ vercel.json # Vercel deployment config
βββ package.json # Dependencies and scripts
βββ README.md # This file
- Input validation and sanitization
- CORS headers properly configured
- Environment variable protection
- Error message sanitization
- Rate limiting ready (can be easily added)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Run tests (
npm test) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see the LICENSE file for details.
- Google Gemini AI for the powerful video analysis capabilities
- Vercel for seamless deployment platform
- The open-source community for inspiration and tools
- Streaming responses for faster perceived performance
- Efficient error handling
- Minimal dependencies
- Optimized for both development and production
Made with β€οΈ by aviz85