2

I'm really questioning my sanity here and hoping someone can help.

Querying the google maps distance matrix with 2 elements works fine (1 origin, 2 destinations):

$ curl "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=Victoria+BC|San+Francisco&key=$GOOGLE_MAPS_API_KEY"

With 3 or more elements, I always get an OVER_QUERY_LIMIT error:

$ curl "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=Victoria+BC|San+Francisco|New+York&key=$GOOGLE_MAPS_API_KEY"
{
   "destination_addresses" : [],
   "error_message" : "You have exceeded your rate-limit for this API.",
   "origin_addresses" : [],
   "rows" : [],
   "status" : "OVER_QUERY_LIMIT"
}

Based on the standard usage limits (pasted below), I shouldn't see this error with a single request of only 3 elements (1 origin and 3 destinations).

Each query sent to the Google Maps Distance Matrix API is limited by the number of allowed elements, where the number of origins times the number of destinations defines the number of elements.

  • 2,500 free elements per day, calculated as the sum of client-side and server-side queries.
  • Maximum of 25 origins or 25 destinations per request.
  • 100 elements per request.
  • 100 elements per second, calculated as the sum of client-side and server-side queries.

The pattern holds regardless of the order of the 2 queries. The 2-element query always succeeds and the 3-element query always fails. Any ideas?

Edit: Just tried this with 3 origins and 1 destination with the same result, so it definitely seems to be related to the number of elements in a request.

Community
  • 1
  • 1
James Dearman
  • 51
  • 1
  • 7

1 Answers1

3

In case it helps anyone else, it looks like a bug in how this API enforces custom quota limits. If you reset the limits back to the defaults (via the developer console/api dashboard), you should get the expected behavior:

  • Elements per day: 2,500
  • Elements per 100 seconds: 10,000
  • Elements per user: Unlimited
James Dearman
  • 51
  • 1
  • 7
  • 1
    Elements per day: 2,500 => thats for one API key? – Junaid Ali Jun 23 '20 at 14:59
  • Thanks for documenting this. I had success with the following cuts: Elements per day: 10,000; Elements per minute: 1,000; Elements per user per minute: Unlimited. – Mateng Jul 12 '22 at 14:40