Disclosure: fix 3 uses an Apify Actor I made, so I'm biased. Apify links here are referral links. Fixes 1 and 2 are free and need nothing but the official API.
If your script suddenly dies with this:
googleapiclient.errors.HttpError: <HttpError 403 ... "The request cannot be completed because you have exceeded your quota.">
and the error reason is quotaExceeded, your Google Cloud project has used up its daily YouTube Data API allowance. Retrying will not help until the quota resets. Here is why it runs out so fast, and three ways to deal with it.
Why the quota runs out
From Google's quota calculator (checked 19 November 2026):
- A project gets 100
search.listcalls a day, in their own bucket, plus 10,000 units a day shared by everything else. -
videos.list,channels.list,playlistItems.listandcommentThreads.listcost 1 unit per call. - Every page of results is a separate call, and even invalid requests cost at least one unit.
- Quotas reset at midnight Pacific Time, not at midnight where you are.
So a loop that calls search.list once per keyword, or pages through a big channel with search, hits the 100-search cap long before the 10,000 units. And a script that fetches one video per videos.list call burns 1 unit per video instead of 1 unit per batch.
First, tell a quota error apart from other 403s (a bad key or a forbidden resource also returns 403):
from googleapiclient.errors import HttpError
def is_quota_error(e: HttpError) -> bool:
reasons = {d.get("reason") for d in (e.error_details or []) if isinstance(d, dict)}
return e.status_code == 403 and "quotaExceeded" in reasons
(error_details and status_code are attributes of HttpError in google-api-python-client; I tested this against 2.202.0.)
Fix 1: spend fewer units on the same data (free)
Don't use search to list a channel's videos. Every channel has an "uploads" playlist. Get its ID once with channels.list, then page through it with playlistItems.list. That uses the 10,000-unit pool instead of the 100-search bucket.
uploads = youtube.channels().list(
part="contentDetails", id=CHANNEL_ID
).execute()["items"][0]["contentDetails"]["relatedPlaylists"]["uploads"]
video_ids, page = [], None
while True:
resp = youtube.playlistItems().list(
part="contentDetails", playlistId=uploads,
maxResults=50, pageToken=page,
).execute()
video_ids += [i["contentDetails"]["videoId"] for i in resp["items"]]
page = resp.get("nextPageToken")
if not page:
break
Batch your videos.list calls. The id parameter takes a comma-separated list of IDs, so send them in chunks (50 per call is the usual chunk size) instead of one per call. That is 1 unit per chunk, not per video.
Cache what you already fetched. Titles and durations barely change. Store results on disk and only refresh view counts when you need them. This is the cheapest fix of all.
Fix 2: ask Google for more quota (free, slow)
Google's quota and compliance audit page says that to get more than the default allocation, your project must first pass an audit against the YouTube API Services Terms, using the YouTube API Services – Audit and Quota Extension Form. A member of the YouTube API team then contacts you. It is the right path for a real product, but it is not a same-day fix.
Fix 3: send only the overflow somewhere else
If you have a daily job that sometimes needs more than your quota, keep the official API as the main path and send only the videos left over after a quotaExceeded to a scraper. This version uses my YouTube Data Scraper on Apify, which reads public YouTube pages and needs no YouTube key. It costs $0.002 per video returned (you need a free Apify account and its API token).
pip install -U google-api-python-client apify-client
export YOUTUBE_API_KEY="..."
export APIFY_TOKEN="..."
import os
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from apify_client import ApifyClient
def is_quota_error(e: HttpError) -> bool:
reasons = {d.get("reason") for d in (e.error_details or []) if isinstance(d, dict)}
return e.status_code == 403 and "quotaExceeded" in reasons
def video_stats_official(youtube, chunk):
resp = youtube.videos().list(
part="snippet,statistics,contentDetails",
id=",".join(chunk),
).execute()
out = {}
for item in resp.get("items", []):
out[item["id"]] = {
"title": item["snippet"]["title"],
"viewCount": int(item["statistics"].get("viewCount", 0)),
"likeCount": item["statistics"].get("likeCount"),
"duration": item["contentDetails"]["duration"],
}
return out
def video_stats_apify(ids):
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("logicbase_systems/youtube-data-scraper").call(run_input={
"videoUrls": ids,
"maxVideosTotal": len(ids),
})
out = {}
for r in client.dataset(run.default_dataset_id).iterate_items():
if r.get("type") == "video":
out[r["id"]] = {
"title": r["title"],
"viewCount": r.get("viewCount"),
"likeCount": r.get("likeCount"),
"duration": r.get("duration"),
}
return out
def video_stats(ids):
youtube = build("youtube", "v3", developerKey=os.environ["YOUTUBE_API_KEY"])
out = {}
for i in range(0, len(ids), 50):
try:
out.update(video_stats_official(youtube, ids[i:i + 50]))
except HttpError as e:
if not is_quota_error(e):
raise
print(f"Quota used up after {i} videos; sending the rest to Apify")
out.update(video_stats_apify(ids[i:]))
break
return out
print(video_stats(["aircAruvnKk", "IHZwWFHWa-w"]))
I tested both paths on 19 November 2026 by forcing a real HttpError 403 quotaExceeded from the official client: when the first chunk succeeds and the second hits the quota, the first 50 results are kept and only the rest go to Apify. A non-quota 403 is still raised. Two videos through the fallback took about 6 seconds inside the Apify run.
Two things to know:
- The fields don't match one-to-one. The official API gives duration as ISO 8601 (
PT18M40S); the Actor gives18:40plus adurationSecondsfield. Normalise before you merge. - A scraper reads what YouTube shows on public pages. It can't see private or members-only videos, and you should still respect YouTube's terms and creators' rights with the data.
Summary
- Check that it really is
quotaExceeded, not some other 403. - Stop using
search.listfor channel listings, batchvideos.list, and cache. - If you need more for a real product, go through Google's audit and quota extension form.
- If you only need to get through the occasional big day, send the overflow to a fallback.
More detail on the Actor (search, channels, playlists, comments) is in my earlier walkthrough: How to scrape YouTube video stats, search results and comments without an API key.
Top comments (0)