When we come across a term Quota in a Google API, it makes a strange feeling and buzz around many Questions like
What if I exceed this limit?
Will Google ask for money if my Qauta exceeds?
What is the meaning of these limits when I use Key in an API?
Now If you want to use any of Google API service like Google Maps, Youtube etc from their thousands of available API’s, you need a Key. This key will monitor, protect, limit your API service usage.
Here we will discuss Google’ YouTube Data API v3
1) How to See Your Available Quota in YouTube Data APIv3?
Go to Google Console
Select your project if you already have
Hover on “IAM & Admin” on left side menu then select “Quotas” on the secondary menu as shown in the image below:
Here you can filter API, we will discuss YouTube Data API V3
2) What will be the Limit of usage?
Here you can see “Queries per day” which is 1,000,000 (1 Million), this is unit number. Each operation is having different Unit Consumption for each operation like Reading, Upload, Edit, Search. You can check unit consumption here YouTube Data API (v3) – Quota Calculator
3) What will happen if my YouTube Dta API v3 Quota Exceeds or finish?
If we look from a broader and realistic perspective YouTube is providing API services almost free for simple operations like Reading, Search etc. For example, if we check YouTube Data API (v3) – Quota Calculator
Suppose we want to view Tags of a video using the following URL
https://www.googleapis.com/youtube/v3/videos?key=[YOUR-KEY-HERE]&fields=items(snippet(title,tags,thumbnails(default(url))))&part=snippet&id=rhQmy93LZH8
In this URL we are getting Title, Tags, Thumbnail of lowest resolution. It will hardly change unit numbers with a change of 1-3 units.
Here 1,000,000 Units are for per day usage, so this is a very big number to finish in simple apps of web applications.
Suppose your limit is exceeded, then what? not a problem Google will simply return an error 403
{
error: {
errors: [{
domain: "youtube.quota",
reason: "quotaExceeded",
message: "The request cannot be completed because you have exceeded your <a href=" / youtube / v3 / getting - started# quota ">quota</a>."
}],
code: 403,
message: "The request cannot be completed because you have exceeded your <a href=" / youtube / v3 / getting - started# quota ">quota</a>."
}
}
4) How to Manually Change Limit API Quota?
If you want to manually change Daily Quota, you can do so by the following procedure.
Click on API for which you want to change Limit
Click on Edit pencil icon
Then put required value then Save
5) How to Protect Your API KEY from Unauthorized Usage?
In a JavaScript-based application, we simply put API URL to get a response from Google server, like given above in Q3. This URL can be seen easily and exposed to everyone. So how can we protect it?
Google is already having a good mechanism to check referer of requests. We simply need to provide URL, Application name or any other source which will hit this URL.
In Credential section you can set a source of URL reference then Google will give a response only if that reference matches otherwise it will give same 403 error as shown above in Q3.
Let me know if you find any more information about Google API Limit policy.
🙂
Leave a Reply