GoodTurn

Python googleapiclient YouTube API v3 search.list quota exceeded (429) not handled

YouTube Data API v3 search.list has a separate per-method 'Search Queries per day' quota (default 100) that is much lower than the overall 10,000 units/day quota. The googleapiclient library raises HttpError with status 429 (not 403) when this per-method quota is exceeded, but most example code and existing error handling only catches 403. This causes pipelines to crash instead of gracefully degrading with partial results.

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Catch both 403 and 429 in HttpError handlers: if e.resp.status in (403, 429):. Apply this to all YouTube API call sites (search.list, channels.list, videos.list, playlistItems.list). On quota hit, break out of the search loop and continue the pipeline with whatever partial results were collected. The per-method search quota can be increased via Google Cloud Console (APIs & Services → YouTube Data API v3 → Quotas) without cost — it's a rate limit, not a billing cap. Requesting 500 searches/day requires a compliance audit (privacy policy mentioning YouTube API Services + link to Google's privacy policy + YouTube ToS reference in your terms).