Code Meets Culture: Analyzing Hari Raya Music with YouTube API in R
TLDR;
📊 Here’s what we discovered:
- YouTube API provides powerful tools to analyze video statistics and trends
- The most viewed Hari Raya music video is Omar dan Hana’s song, highlighting YouTube’s popularity among children
- As of April 28, 2025, “Serumpun” holds the record for most liked Hari Raya music video, while “Meriah Lain Macam” has the highest view count
Introduction
Hello, World! Selamat Hari Raya Aidilfitri to everyone celebrating! 🌙
I recently had the honor of presenting at the Brunei R>aya Meetup on April 18, 2025, hosted by the Brunei R User Group at UBD Library. The event was a fantastic opportunity to share knowledge alongside brilliant speakers:
- Dr. Daphne Lai: Presented on Principal Component Analysis clustering of kuih raya
- Muaz Mahdi: Explored eating behaviors during open houses using Markov chains
You can find more details about the event on the Brunei R website.
In this blog post, I’ll share my presentation on working with APIs in R, specifically focusing on using the YouTube API to analyze Hari Raya music trends.
Understanding APIs 🔌
An Application Programming Interface (API) serves as a communication bridge between different software systems. To better understand this concept, let’s use a restaurant analogy:
APIs can be broadly categorized into two types:
- Data Retrieval APIs: Used to fetch information (what we’ll focus on in this post)
- Command/Action APIs: Used to perform specific actions
APIs can be either:
- 🔓 Keyless: Free to use without authentication
- 🔑 Key-based: Require authentication through API keys
Required R Packages 📦
To work with APIs in R, we’ll primarily use two essential packages:
# Install required packages
install.packages(c("httr", "jsonlite", "tuber"))
# Load the packages
library(httr) # For making HTTP requests
library(jsonlite) # For parsing JSON responses
library(tuber) # For YouTube API interactions
Setting Up YouTube API 🎥
To access YouTube’s data, you’ll need to:
- Create a project in Google Cloud Console
- Enable the YouTube Data API v3
- Generate an API key
- Use the
tuber
package in R to interact with the API
Data Analysis: Hari Raya Music Videos 📊
Our analysis covers several aspects of Hari Raya music videos:
Top Performers 🏆
- Top 10 most viewed videos
- Top 10 most liked videos
- Top 10 most commented videos
Trend Analysis 📈
- Correlation between views, likes, and comments
- Historical ranking of videos (2009-2025)
- Seasonal patterns in engagement
Limitations and Considerations ⚠️
While working with the YouTube API, we encountered some limitations:
- Search results are limited to short videos
- API quotas and rate limits
- Data freshness and update frequency
Beyond YouTube: Other API Applications 🌐
The world of APIs offers endless possibilities for data analysis:
- 🌤️ Weather forecasting
- 🎵 Spotify music trends
- 📰 News headline analysis
- 📱 Social media analytics
- 🏛️ Government datasets
Resources and Further Reading 📚
Conclusion 🎯
Working with APIs opens up a world of real-time data analysis possibilities. Whether you’re analyzing music trends, weather patterns, or social media engagement, APIs provide a powerful way to access and analyze data. I hope this post has inspired you to explore the world of APIs in your data analysis projects.
Thank you! 🙏
Feel free to reach out if you have any questions or would like to discuss API integration in your projects.