2017-07-13 51 views
0

我收到一個錯誤,通知我超出了API配額。但是,我有150,000個請求的配額,並且只用了其中的12,000個。什麼導致了這個錯誤?的代碼Google Places API:OVER_QUERY_LIMIT

例如:

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 

回答

1

從錯誤消息中的請求不是鄰居API請求。這是地理編碼API請求。

https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Vancouver%2C+Canada

它不包含任何API密鑰。這意味着每天只有2500個地理編碼請求沒有API密鑰。此外,地理編碼請求具有每秒50個查詢的每秒查詢限制(QPS)。您也可能超過QPS限制。

https://developers.google.com/maps/documentation/geocoding/usage-limits

不知道爲什麼應該在現實中被調用Places API的Web服務庫調用API地址解析網絡服務。如果Places API不提供任何結果,那麼這可能是某種回退。