Google Places API: OVER_QUERY_LIMIT

2019-09-20 16:29发布

问题:

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

回答1:

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.