问题描述
我遇到了一个错误,通知我超出了API配额.但是,我有150,000个请求的配额,只用完了12,000个.是什么导致此错误?
代码的示例:
from googleplaces import GooglePlaces api_key = '' google_places = GooglePlaces(api_key) query_result = google_places.nearby_search(location="Vancouver, Canada", keyword="Subway") for place in query_result.places: print(place.name)
错误消息:
googleplaces.GooglePlacesError: Request to URL https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Vancouver%2C+Canada failed with response code: OVER_QUERY_LIMIT
推荐答案
错误消息的请求不是位置API请求.这是地理编码API请求.
https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Vancouver%2C+Canada
它不包含任何API键.这意味着您只能在没有API键的情况下每天有2500个地理编码请求.同样,地理编码请求具有每秒限制的查询(QP),每秒50个查询.您可能也超出了QPS限制.
不确定为什么应该调用的库将API Web服务在现实中呼叫地理编码API Web服务.如果位置API不提供任何结果,也许这是某种后备.
其他推荐答案
对于任何在最近的时间内看这篇文章的人,Google做到了这一点,因此有必要拥有一个API键来使用其MAPS API.因此,请确保您的程序有一个API密钥.还要记住不同的节气门极限.
有关更多信息,请参见下文:
问题描述
I am getting an error notifying me of exceeding the API Quota. However, I have a quota of 150,000 requests and have only used up 12,000 of them. What is causing this error?
example of code:
from googleplaces import GooglePlaces api_key = '' google_places = GooglePlaces(api_key) query_result = google_places.nearby_search(location="Vancouver, Canada", keyword="Subway") for place in query_result.places: print(place.name)
Error Message:
googleplaces.GooglePlacesError: Request to URL https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Vancouver%2C+Canada failed with response code: OVER_QUERY_LIMIT
推荐答案
The request from error message is not a Places API request. This is Geocoding API request.
https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Vancouver%2C+Canada
It doesn't include any API key. That means you can have only 2500 daily geocoding requests without an API key. Also, geocoding requests have a query per second limits (QPS) which is 50 queries per second. You might be exceeding the QPS limit as well.
https://developers.google.com/maps/documentation/geocoding/usage-limits
Not sure why the library that supposed to be calling Places API web service in reality calls Geocoding API web service. Maybe this is some kind of fallback in case if Places API doesn't provide any result.
其他推荐答案
For anyone looking at this post in a more recent time period, Google has made it so it is NECESSARY to have an api key to use their maps api. So please ensure you have an api key for your program. Also keep in mind the different throttle limits.
See below for more info: