本文介绍了YouTube API 配额,请解释一下.超出配额.怎么解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能用简单的语言解释一下这些配额是如何工作的?

我知道哪里有类似的问题,但我想要一个与下面的屏幕截图相关的解释.

首先,我在 Google Dev Console 中为 YouTube API 打开了配额页面.

但我不明白这些行是什么以及它们是如何工作的,为什么会有几行?

例如,我试图发出这样的简单请求

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

返回一个 json 响应:

{错误":{代码":403,消息":请求无法完成,因为您已超出您的 u003ca href="/youtube/v3/getting-started#quotau003equotau003c/au003e.",错误":[{消息":请求无法完成,因为您已超出您的 u003ca href="/youtube/v3/getting-started#quotau003equotau003c/au003e.",域":youtube.quota",原因":超出";}]}}

所以,我认为它给了我一个错误,因为某处有一个配额 = 零,因为我只尝试过一次这个请求.

我应该怎么做才能摆脱这个错误并能够使用 API?

谢谢.

解决方案

基于项目的配额

YouTube 数据 API 是基于成本的配额,而不是基于请求的配额.

使用基于请求的配额,您可以获得一个配额,例如可以发出 10000 个请求,您发出的每个请求都会从您的配额中删除一个.

YouTube 数据 API 是基于成本的配额.这意味着您可以获得 10000 积分的配额,您可以将其用于请求.每个请求都有不同的成本.

根据您的要求上传视频大约需要 1600 点,因此您可以上传有限数量的视频,但列表只需 50 点,因此您可以在配额用完之前做更多列表然后上传.

我建议您查看

基于用户的配额.

此外还有基于用户的配额,即用户每秒可以发出的请求数,这些都是防洪配额.

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?

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"u003equotau003c/au003e.",
    "errors": [
      {
        "message": "The request cannot be completed because you have exceeded your u003ca href="/youtube/v3/getting-started#quota"u003equotau003c/au003e.",
        "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.

解决方案

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

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.

这篇关于YouTube API 配额,请解释一下.超出配额.怎么解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-01 12:23