Reputation: 478
I use the geocoding API to process lists of addresses using the 'geocoder' module in Python. As recently as a few weeks ago I was able to do this successfully, but today the API stopped responding after 2,500 calls. I did not get any error responses, and if I restarted the process I was able to get an additional 2,500 responses, but then nothing after that again. Does anyone know why this might be happening? The only reference to a cap at 2,500 was the daily free call limit on the previous pricing model.
edit: Interestingly, the issue seems to be isolated to my usage of the geocoder module. When I roll my own, I'm not having the same problem.
Function using geocoder:
def get_data(query):
result = geocoder.google(query, key=apikey)
return {'formatted_address':result.address,
'lat':result.lat,
'long':result.lng}
Function using just requests:
def get_data(query):
try:
api_response = requests.get('https://maps.googleapis.com/maps/api/geocode/json?address='+query+'&key='+apikey)
read_response = api_response.json()
address = read_response['results'][0]['formatted_address']
lat = read_response['results'][0]['geometry']['location']['lat']
lng = read_response['results'][0]['geometry']['location']['lng']
return {'formatted_address':address, 'lat':lat, 'lng':lng}
except:
return None
Worth noting that I'm on a new computer since the last successful run and I was running into some intermittent corporate firewall weirdness since I switched. It just seemed like such strange behavior for the issue to be on my side, I thought for sure I was running into an API limitation. I guess I will just log the issue on geocoder's git and move on.
Upvotes: 1
Views: 870
Reputation: 66
You need to pass the parameter
rate_limit = False
in your your query. Thus your query above should be
result = geocoder.google(query, key=apikey, rate_limit=False)
Note: This works because the 'google.py' module by default calls the decorator
@ratelim.greedy(2500, 60 * 60 * 24) # Line 271 in google.py
So an alternative option would be to change that value in the source code.
Upvotes: 2
Reputation: 43
Google standard API usage limit is 2,500 free requests per day, calculated as the sum of client-side and server-side queries.
If you want to increase your daily limit, you have to upgrade your API usage package from Billing console.
See this link for more information.
Upvotes: 1