Back to articles
API Rate Limiting Strategies for YouTube Data API

API Rate Limiting Strategies for YouTube Data API

via Dev.to Webdevahmet gedik

The YouTube Data API v3 gives you 10,000 quota units per day by default. That sounds like a lot until you start fetching trending videos from 8 regions every 2 hours. Here are the quota management strategies I've developed for DailyWatch . Understanding Quota Costs Not all API calls cost the same: Operation Cost videos.list (chart=mostPopular) 1 unit videos.list (by ID, up to 50) 1 unit search.list 100 units videoCategories.list 1 unit channels.list 1 unit Notice that search.list costs 100x more than videos.list . This is the most important thing to internalize. Strategy 1: Avoid Search API Instead of using the expensive search.list endpoint, use videos.list with chart=mostPopular and filter client-side: // Expensive: 100 units per call // DON'T DO THIS for browsing $searchUrl = 'https://www.googleapis.com/youtube/v3/search?' . http_build_query ([ 'part' => 'snippet' , 'q' => 'trending music' , 'type' => 'video' , 'key' => $apiKey , ]); // Cheap: 1 unit per call // DO THIS instead $tre

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles