10

Can someone please explain me in simple language how these quotas work?

I know where is a similar question, but I want an explanation related to the screenshot below.

First, I opened the quotas page in Google Dev Console for YouTube API.

But I don't understand what these lines are and how they work, why there are several lines?

enter image description here

For example, I was trying to make a simple request like this

https://www.googleapis.com/youtube/v3/search?part=snippet&q=welcome&type=playlist&key=[MY_API-KEY]

Which returns me a json response:

{
  "error": {
    "code": 403,
    "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
    "errors": [
      {
        "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
        "domain": "youtube.quota",
        "reason": "quotaExceeded"
      }
    ]
  }
}

So, I assume it gives me an error because somewhere there is a quota = zero, because I only tried to make this request once.

What should I do to get rid of this error and be able to use the API?

Thank you.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
monstro
  • 6,254
  • 10
  • 65
  • 111

1 Answers1

9

project based quotas

The YouTube data api is a cost based quota as opposed to a request based quota.

With request based quotas you are given a quota of say 10000 requests that you can make, each request you make removes one from your quota.

The YouTube data api is a cost based quota. This means you are given a quota of say 10000 points which you can spend on requests. Each requests has a different cost.

uploading videos costs around 1600 points against your request so you can upload a limited number of videos yet list only costs 50 so you could do more lists then uploads before running out of quota.

I recommend having a look at the quota calculator which will help you understand the cost of each request against your quota allotment.

This video may also help you understand cost based quotas YouTube API and cost based quota demystified

As far as the error you are getting from the following request

https://www.googleapis.com/youtube/v3/search

As search.list method costs 100 quota points each time you request it, this and the error message would suggest that you have exceeded your quota. You need to either apply for an extension or make fewer reqeusts.

How to check your current quota allotment:

Go to https://console.cloud.google.com/ -> library -> search for youtube data api -> quota

enter image description here

user based quotas.

Besides that there are also user based quotas which are the number of requests a user can make per second these are flood protection quotas.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • So, where do I see this information in Dev Console? Why there are multiple lines? Why I cannot make a request? Where is that parameter that says that I have no quota for making this request? – monstro Mar 17 '21 at 13:28
  • edited to give you an idea of where to find your quota allotment. – Linda Lawton - DaImTo Mar 17 '21 at 13:38
  • Yes, I saw that page, but I dont understand it. For example I have 2 sections both named "Queries". Dont know what the difference is and why there are 2 sections. Also, for the first one I have "Queries per day" = 0, "Queries per minute per user" = 180,000 and "Queries per minute" = 1,800,000. If I have a 1,800,000 per minute, how can I have 0 per day? – monstro Mar 17 '21 at 13:55
  • 1
    Per user are user based queries, that's the number of queries a user can make per day. You have 0 because its a new project or an old project and you didnt apply for verification. Try clicking on the pencil icon and setting it to 10000, if that doesn't work you will need to apply for quota. – Linda Lawton - DaImTo Mar 17 '21 at 15:15
  • Any examples of how to request based on userIp to use user quotas? I'm taking the public ip of the user's machine and passing it along with the http request, but that doesn't seem to work, as I've already had problems with quotas being exceeded. The request is a get that queries playlists and videos. I'm using jquery and ajax for the request. – Leonardo Silva Nov 24 '21 at 03:46
  • It depends upon the language you are using its just an optional parm so adding quotas=xyz or userip=127.0.0.1. Remember depending upon which quota you hit it make take a while for it to reset its midnight west cost usa that some of them reset. I am also not sure this trick still works its a five year old question. Just request addional qouta. – Linda Lawton - DaImTo Nov 24 '21 at 07:55
  • My language is Brazilian Portuguese – Leonardo Silva Nov 24 '21 at 22:21
  • @LeonardoSilva programming Language. Portuguese is not a programming language. – Linda Lawton - DaImTo Nov 25 '21 at 08:36
  • Sorry, there was no understanding. I'm making the requests in javascript and also in C#. This is an example of a request I've been making, with userip, but it hasn't had any effect: https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=12&key=mycredencialkey&userip=userip&type=playlist&q=Programing in C# – Leonardo Silva Nov 25 '21 at 22:51
  • Im not sure what effect you are expecting to see. Your still going to get quota errors. The initial quota is very small. There is also no documentation evidence that userip and quota user even work with the YouTube API, its not in the documentation at all. Only under the default parms – Linda Lawton - DaImTo Nov 26 '21 at 07:42