YouTube_Trend_Analyzer / src /backend /routes /data_visualization_page_api.py
molehh's picture
youtube trend analyer project
74bdacd
from fastapi import APIRouter
import trending_videos_page
from sqlalchemy.orm import Session
router=APIRouter()
@router.get("/trending_videos_count")
def trending_videos_count():
data = trending_videos_page.get_trending_videos_count()
return {"trending_video_counts": data.to_dict()}
@router.get("/most_popular_categories")
def most_popular_categories():
data = trending_videos_page.get_most_popular_categories()
return {"most_popular_categories": data.to_dict()}
@router.get("/engagement/like_ratio_distribution")
def like_ratio_distribution():
data = trending_videos_page.get_like_ratio_distribution()
return {"like_ratio_distribution": data.to_dict(orient="records")}
@router.get("/engagement/top_liked_videos")
def top_liked_videos():
data = trending_videos_page.get_top_liked_videos()
return {"top_liked_videos": data.to_dict(orient="records")}
@router.get("/channel-performance/top-trending")
def top_trending_channels():
data = trending_videos_page.get_trending_channels()
channel_counts = data["channelTitle"].value_counts().to_dict()
return {"top_trending_channels": channel_counts}
@router.get("/channel-performance/growth-over-time")
def channel_growth_over_time():
growth_data =trending_videos_page.calculate_channel_growth()
return growth_data.to_dict(orient="records")
@router.get("/analysis")
def get_tags_analysis():
popular_tags = trending_videos_page.process_tags()
return popular_tags
@router.get("/duration_vs_likes")
def get_trending_by_day():
analyze_trending_daily=trending_videos_page.analyze_upload_patterns("day")
return analyze_trending_daily
@router.get("/category-like-view-ratio")
def get_category_like_view_ratio():
data = trending_videos_page.category_like_view_ratio()
return {"data": data}
@router.get("/category-comment-engagement")
def get_category_comment_engagement():
data = trending_videos_page.category_comment_engagement()
return {"data": data}