1

I'm receiving OVER_QUERY_LIMIT error intermittently when calling Google's Distance Matrix API.

After enabling billing it should not show this error since I could make 100,000 requests/day as per API documentation. Though, I'm making on 2500-2600 requests/day currently.

Also, API statistics report in Google Console project doesn't show any data for Distance Matrix API in the dashboard, however, it shows data for other APIs. See attachedenter image description here screenshot.

Error Message:

{
    "destination_addresses": [],
    "error_message": "You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_",
    "origin_addresses": [],
    "rows": [],
    "status": "OVER_QUERY_LIMIT"
}
vishal savsani
  • 399
  • 6
  • 17
  • please include the exact error message you are receiving and the exact request you are making that is resulting in the error. http://stackoverflow.com/help/mcve – Linda Lawton - DaImTo Jan 09 '17 at 14:06
  • http://stackoverflow.com/q/11792916/1841839 – Linda Lawton - DaImTo Jan 09 '17 at 14:08
  • If you have a premium account then you will have the 100k pool free everyday for the distance matrix API. This limit doesn't apply to the `Enable Billing` option. That being said there is a 100 element limit for both per call and per second on the distance matrix API for the account you have. These limits vary for premium account. – Coder Jan 09 '17 at 16:20
  • @DaImTo Thanks, I'm getting following error even after enabling billing. It should allow me upto 100K requests but I'm start receiving error after 2500 requests. Added exact error in description. – vishal savsani Jan 11 '17 at 14:48
  • @DaImTo I tried calling API from another machine with same argument and API key. It working there, so I just want to figure out possible issues. Does it has something to do with domain/machine? – vishal savsani Jan 13 '17 at 08:55
  • Most quotas are user based (user is denoted by IP address in most cases but not all this depends upon the API). If you don't send a quotauser parameter which is an optional parameter supported by all(I don't know of any that don't support it) of the google APIs then IP is used to denote a different user. You can try sending a random value to quotauser this works "sometimes" but not always I think google has a way of figuring out what you are up to. – Linda Lawton - DaImTo Jan 13 '17 at 10:04

2 Answers2

4

Thanks, @DaImTo & @Prisoner for looking into this.

It seems an issue is in Google's internal system. I resolved an issue with a tricky way. Here are my findings I would like to share so people can save time I wasted in debugging an issue.

  • The error that Google provides("OVER_QUERY_LIMIT") is something that misguides people. I just made few changes in API URL and it's working on.
  • Changed "HTTP" to "HTTPS"
  • Previously I was using "Key" and changed it to "key"

Incorrect : http://maps.googleapis.com/maps/api/distancematrix/json?&origins={origin}&destinations={destination}&sensor=false&Key={api_key}

Correct: https://maps.googleapis.com/maps/api/distancematrix/json?&origins={origin}&destinations={destination}&key={api_key}

Though, I'm still not sure why incorrect URL is working when I make a call from local machine but not on production server.

  1. Regarding usage statistics, it started showing API in dashboards as soon as I updated API URL.
vishal savsani
  • 399
  • 6
  • 17
0

With billing enabled (and not with the premium service), you still have other limits in place. That you're getting this error intermittently suggests that you might be exceeding the 100 elements/second limit (which is averaged over 100 seconds, it looks like). See https://developers.google.com/maps/documentation/distance-matrix/usage-limits for the limits that are in place on each level.

Not all statistics are shown in the dashboard. You can go to the specific services page to see additional information and how it reflects the quotas.

enter image description here

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks, but I'm requesting only one source/dest element in all the requests so I'm not reaching that limit. Also not making more than 5 requests per seconds. I could not even see anything in specific API level dashboard. – vishal savsani Jan 11 '17 at 14:58