@adrienne
Building the GM Farcaster Mini App in public, today's lesson: YouTube API limits
The challenge: How can I check if our YouTube channel is live without blowing through our API quota?
- Default quota for the YouTube Data API = 10,000 units/day
- The API’s search?eventType=live costs 100 units per call
- That means you can only check ~100 times/day → or once every ~15 minutes ☹️☹️
We've been maxing out the API quota well before the day is over. Which means we couldn't get the latest video, and just defaulted to a hard coded one (that's why you might have been seeing older videos in the app)
But our app is only fun if you can rely on it to show our live stream, when we are live.
2 part solution:
1.) Redis cache with a 3-minute window to avoid hitting YouTube repeatedly
2.) Time-based filter, only doing the expensive isLive status during possible broadcast hours (8 AM – 2 PM ET). Outside those hours, we skip the check entirely and just show the latest recorded video.