Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geocoding api over query limit

I'm using the geocoding API on the server side to translate addresses in latlng. I faced a OVER_QUERY_LIMIT status even though : - the server didn't exceed the 2500 limitation (just a few request on this day) - it didn't do many requests simultaneously (just one single request at a time)

how is that possible ? the next day the geocoding was working well but i'm concerned about my application working correctly in the long run.

Thanks in advance.

like image 311
user1283452 Avatar asked Mar 21 '12 13:03

user1283452


People also ask

What happens when you exceed the Google geocoding API rate limit?

If you exceed the per-day limit or otherwise abuse the service, the Google Maps Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Google Maps Geocoding API may be blocked.

What does over query limit mean?

If status code is still OVER_QUERY_LIMIT, your application is sending too many requests per day. Otherwise, your application is sending too many requests per second."

What is the maximum limit for the number of geocode requests?

While there is no maximum number of requests per day, the following usage limit is still in place for the Geocoding API: 50 requests per second, calculated as the sum of client-side and server-side queries.

Can I use geocoding API for free?

The Google Geocoding API has the following limits in place: Users of the free API: 2,500 requests per 24 hour period.


3 Answers

This is how I have handled this issue in the past. I check the result status and if I get and over the limit error I try it again after a slight delay.

function Geocode(address) {
    geocoder.geocode({
        'address': address
    }, function(results, status) {
        if (status === google.maps.GeocoderStatus.OK) {
            var result = results[0].geometry.location;
            var marker = new google.maps.Marker({
                position: result,
                map: map
            });
        } else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {    
            setTimeout(function() {
                Geocode(address);
            }, 200);
        } else {
            alert("Geocode was not successful for the following reason:" 
                  + status);
        }
    });
}

Update: whoops, accidentally glossed over the server side part. Here is a C# version:

public XElement GetGeocodingSearchResults(string address)
{
    var url = String.Format(
         "https://maps.google.com/maps/api/geocode/xml?address={0}&sensor=false",
          Uri.EscapeDataString(address)); 

    var results = XElement.Load(url); 

    // Check the status
    var status = results.Element("status").Value;

    if(status == "OVER_QUERY_LIMIT")
    {
        Thread.Sleep(200);
        GetGeocodingSearchResults(address);
    }else if(status != "OK" && status != "ZERO_RESULTS")
    {
        // Whoops, something else was wrong with the request...     
    }

    return results;
}
like image 77
Bryan Weaver Avatar answered Oct 13 '22 18:10

Bryan Weaver


We had this problem as well and the solution was to ditch google's API. If all you need is geocoding there are numerous alternatives that are equally as effective without the limitations. We chose the mapquest API. It has been faster and more reliable with no cap on geocoding calls plus I really like their API for batching together geocoding requests into a single call.

If there are other features you require, obviously you have to take those into consideration, but in the case of a single feature, using the biggest API on the block is not necessarily the best choice.

developer.mapquest.com

like image 23
NSProgrammer Avatar answered Oct 13 '22 18:10

NSProgrammer


Google, Bing, MapQuest, and Yahoo! Maps (is this API still around?) are extremely powerful tools. They have a lot of horsepower that they put behind interpreting the address you provide and doing everything possible to make it into a properly formatted address for geocoding. To a certain degree they are free. They have volume limits and pretty strict Terms Of Service (TOS) that might be a factor if you start using their service commercially and especially if you integrate it into another product.

Keep in mind that all of them do "address approximation" NOT address verification. They will be able to tell you approximately where an address would lie on a certain street IF the address exists. They cannot tell you that the address you are looking for exists. One way to verify this is to look at your own address in Google Maps. Zoom all the way in to street view and you'll see that they state "address is approximate" even though they may have the location pinpointed exactly. They just don't have the master list of addresses to compare and know which addresses are real. For that, you will need some sort of address verification.

Address verification standardizes and cleans a given address in much the same way as the free mapping services but it also compares the addresses to the USPS database of deliverable addresses to confirm if the address really exists. The confirmed address can then be geocoded with improved accuracy.

There are a lot of good address verification services out there. In the interest of full disclosure, I'm the founder of one--SmartyStreets.

like image 22
Jonathan Oliver Avatar answered Oct 13 '22 17:10

Jonathan Oliver