Search code examples
javascriptgoogle-apiyoutube-data-api

Why do I run my daily quota at youtube api in an hour?


I use youtube API v3 for my site providing videos for lyrics translation. I got 250.000 quota but I run it out in about an hour though I don't send enough requests to exceed it.

daily requests

It says that I sent only 86k requests for the last day, but 89% were returned with 403 error.

But here it shows that I used all 250.000 limit quota

quota limits

I use HTTP source authorization so only my site could use this api key. And I logged the requests I sent to check that I don't double them by mistake.

Maybe I get something wrong?


Solution

  • Youtube has this to say about quotas:

    Google calculates your quota usage by assigning a cost to each request, but the cost is not the same for each request. Two primary factors influence a request's quota cost:

    Different types of operations have different quota costs.

    • A simple read operation that only retrieves the ID of each returned resource has a cost of approximately 1 unit.
    • A write operation has a cost of approximately 50 units.
    • A video upload has a cost of approximately 1600 units.

    Read and write operations use different amounts of quota depending on the number of resource parts that each request retrieves. Note that insert and update operations write data and also return a resource. So, for example, inserting a playlist has a quota cost of 50 units for the write operation plus the cost of the returned playlist resource.

    As discussed in the following section, each API resource is divided into parts. For example, a playlist resource has two parts, snippet and status, while a channel resource has six parts and a video resource has 10. Each part contains a group of related properties, and the groups are designed so that your application only needs to retrieve the types of data that it actually uses.

    An API request that returns resource data must specify the resource parts that the request retrieves. Each part then adds approximately 2 units to the request's quota cost. As such, a videos.list request that only retrieves the snippet part for each video might have a cost of 3 units. However, a videos.list request that retrieves all of the parts for each resource might have a cost of around 21 quota units.

    The takeaways are that your quota is a pool of points and different kinds of requests cost different amounts of points.