javascript - Detect Google Maps API quota limit -
javascript - Detect Google Maps API quota limit -
does know way test via javascript or http-request, if quota of google maps javascript api v3 reached? getting error-message, displayed user, sufficient.
we enabled billing , have quota google maps javascript api v3 on around 100,000, break , not realize it. monitor our api access tool nagios (perhaps using phantomjs) instant warning. not find info on how test, if our quota has exceeded.
update2
a similar request ist found here: how observe 25000 request per day limit has been reached in google maps?
but there reference api-console. if managed fallback static maps using javascript, modify script case.
update
here illustration of localized quota error-message google maps, appears user instead of map. prefer remove maps container if happens:
i assume want find out if you've exceeded google maps api web services request limit. here's official documentation says:
usage limits exceeded
if exceed usage limits over_query_limit status code response.
this means web service stop providing normal responses , switch returning status code over_query_limit until more usage allowed again. can happen:
within few seconds, if error received because application sent many requests per second. some time in next 24 hours, if error received because application sent many requests per day. time of day at daily quota service reset varies between customers , each api, , can alter on time.upon receiving response status code over_query_limit, application should determine usage limit has been exceeded. can done pausing 2 seconds , resending same request. if status code still over_query_limit, application sending many requests per day. otherwise, application sending many requests per second.
and code sample:
url = "maps_api_webservice_url" attempts = 0 success = false while success != true , attempts < 3: raw_result = urllib.urlopen(url).read() attempts += 1 # getstatus function parses reply , returns status code # function out of scope of illustration (you can utilize sdk). status = getstatus(raw_result) if status == "over_query_limit": time.sleep(2) # retry go on success = true if attempts == 3: # send alert means daily limit has been reached print "daily limit has been reached"
quoted google maps documentation: https://developers.google.com/maps/documentation/business/articles/usage_limits#limitexceeded
tldr: create request, if over_query_limit response, seek 1 time again in 2 seconds. if response still same, you've nail daily limit.
javascript google-maps google-maps-api-3
Comments
Post a Comment