Reputation: 21
I'm using the YouTube Data API v3 to insert playlists and playlist items.
As noted in the title, I'm getting a 429 / resource exhausted response but don't believe we're really using the quota up -- or, I'm misunderstanding our quota.
Today I created 8 Playlists and 187 videos which I believe is 9,400 "units" of quota over about 90 minutes and got this message...
Error: {code: 429, message: "Resource has been exhausted (e.g. check quota).", errors: Array(1), status: "RESOURCE_EXHAUSTED"}
Here's what's listed on the Quota page in cloud console for this key which seems to have enough overhead for this...
Quota | Limit |
---|---|
Queries per day | 100,000 |
Then I got to thinking perhaps this is a "per user" limit being reached.
And here's what's listed on the Quota page in cloud console for this key...
Quota | Limit |
---|---|
Queries per minute per user | 180,000 |
Queries per minute | 1,800,000 |
And according to the "Queries Per Minute" report in the Dev platform our queries per minute maxed out at 1,600 and the graph for "Quota Exceeded" is empty.
So my first question is, are these numbers accurate? How could the per user or per minute quotas be so much higher than the daily quota?
Second question is, if these numbers are not accurate, where can the accurate numbers for "Queries per minute per user" and "Queries per minute" be found?
Lastly, is there a way to hit an endpoint to get more precise quote usage data or a more precise error message?
Thank you for any guidance here, Todd
Upvotes: 2
Views: 5584
Reputation: 170
Considering it's infeasible to expect Google to help or atleast document these limits, the best workaround I have found is to upload all playlists (after hitting the error) as private and convert them to public manually.
Upvotes: 3
Reputation: 6985
According to the official document Google APIs - Global domain errors, the error you have obtained from the API has the following specification:
TOO_MANY_REQUESTS (429)
rateLimitExceeded
Too many requests have been sent within a given time span.
Thus the API is signaling you that you've issued too many API requests in a small amount of time.
An accustomed solution to this is to have your program catch these kind of errors for to implement exponential backoff retrying the culprit API call.
Addendum
According to Google staff, you have to wait for a while before you're allowed to create new playlists:
Status: Won't Fix (Intended Behavior)
Creating high volumes of playlists via the API in a short amount of time may result in this error. The length of time to wait is variable. You may wish to use a method such as exponential backoff or queuing for a retry later in cases where you're attempting to fulfill a request on behalf of a user.
Do note that you hit an undocumented limit of YouTube Data API. Unfortunately, this API has quite a few of them. Stackoverflow and Google's own issue tracker did uncovered some of those limits.
Upvotes: 3