YouTube API Quota quick overflow

走远了吗. 提交于 2020-05-17 07:16:32

问题


I'm trying to create a simple YouTube API request and quickly get 403 response code (Quota limit). According to YouTube API docs, the default quota is 10000 units per day. According to the same docs, my request costs 3-5 units. However, I can get no more than 100 requests per day.

Here is a script that I wrote which consequently does the same requests:

key=<My Youtube API key>
request="https://www.googleapis.com/youtube/v3/search?type=video&part=id,snippet&order=relevance&maxResults=10&key=$key&q=hello"

for i in {0..1000}
 do
    echo "Try #$i"
    response=`curl -i $request | grep HTTP/2 | awk '{print $2}'`

    if [ $response == 403 ]
    then
      break
    fi
    echo $response
 done

echo "$i tries succeeded"

It gives

97 tries succeeded

In Google console I see that my script consumed almost all 10000 units


回答1:


According to the docs' quota calculator, the cost of one invocation of Search endpoint is not 3-5 units, but 100 units. (This fact is also mentioned on Search endpoint's doc page itself.) This explains that upon 100 calls to that endpoint your daily quota of 10000 units gets exhausted.



来源:https://stackoverflow.com/questions/61226002/youtube-api-quota-quick-overflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!