I'm using an autosuggestion for addresses through Google Maps API that I want to be as fast as possible.
Currently, I have added a 10ms delay to my script in order to a开发者_JAVA百科void being banned for too many requests. Is this necessary? How many requests can be made without getting banned?
P.S. I'd love some appropriate tags for this, I really can't come up with anything good.
I'm not sure if I fully understand your question. But in any case Google Maps like most other APIs has a limit on the number of requests you are allowed to perform daily:
You have a limit of 2,500 requests per day per IP for geocoding requests made by a regualr user, see here. If you are a premier user the limit is 100,000 requests per day per IP, however, you have a 15,000 requests/day limit when using the Javascript API or the Flash Maps API, see here.
As for too many requests at the same time, since it depends on the load google allow on their servers (which may change) I recommend you do what google suggested in the above document.
Query as much as you can and when you receive a 620 error code throttle back the speed of your requests. If you do that you will be able to dynamically determine how many requests they will allow you to do in any given time.
Unless someone can provide you with a hard limit... I know the hard limit specified in the premier user faq is said to be 10 requests/second:
"These limits apply to each Maps API Premier client id and must be shared across all applications and IP addresses using a given client id. There is also a rate limit of 10 requests per second that applies to all Google Maps API Web Services. If you need higher usage limits, please contact your Maps API Premier Account Manager for purchase information."
This information has probably changed since @Asaf answered the question on 29 August 2010, certainly for regular users (non-Premier), as there were updates effective 1 October 2011 for usage of Google Maps API. These are the new limits for non-Premier users:
From October 1st 2011, commercial web sites and apps using the Maps API at no cost may generate:
- max of 2,500 calls/day, if modified using Styled Maps feature
- max of 25,000 calls/day in total
There are currently no limits on the number of web based JavaScript or Flash maps a site can generate. The Google Maps API Web Services and Google Static Maps API do have daily limits that are specified in their documentation. Also
Non-profits and applications deemed in the public interest (as determined by Google at its discretion) are not subject to these transaction limits.
Criteria for applications deemed in the public interest follow.
Also, Google says that your app won't just stop working if you exceed usage limits, but you WILL be contacted by a "Maps API Premier sales manager" if your site qualifies for and consistently exceeds the free usage allowances.
Final suggestion: The GeoCoding Strategies section for regular users, which mentions how often you can submit requests before getting flagged and uses of caching, server side requests etc. hasn't been updated since June 2010. It might be worth glancing at that link. @Asaf didn't include it specifically in his (very fine answer), although I found it on a page that he did provide the URL for.
Check below Google documentation regarding Google Map Api Usage Limit:
https://developers.google.com/maps/documentation/business/faq#usage_limits
https://developers.google.com/maps/documentation/business/articles/usage_limits
http://maps.google.co.in/help/maps/getmaps/compare.html
精彩评论