2

what is the maximal number of origins and destinations I may give to this function? Or better: What is the maximal number of origin-destination-combinations I may ask for?

Right now I have 33 origins and 3 destinations - and it is working. As far as I enter one more destination - an error occurs. It says something like

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 223, in _get
    result = self._get_body(resp)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 242, in _get_body
    raise googlemaps.exceptions._RetriableRequest()
googlemaps.exceptions._RetriableRequest

During handling of the above exception, another exception occurred:

I have these lines like 12 times and at the end

Traceback (most recent call last):
  File "C:\Python34\Lib\site-packages\googlemaps\distance_matrix_test.py", line 41, in <module>
    '28821 Coslada','10179 Berlin'], mode='driving')
  File "C:\Python34\Lib\site-packages\googlemaps\distance_matrix.py", line 130, in distance_matrix
    return client._get("/maps/api/distancematrix/json", params)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 229, in _get
    base_url, accepts_clientid, extract_body)
  File "C:\Python34\lib\site-packages\googlemaps\client.py", line 184, in _get
    raise googlemaps.exceptions.Timeout()
googlemaps.exceptions.Timeout

It would be great to get some help of you! And by the way: I checked the additional address - this is not causing the problem. It MUST be the number of addresses. But I would like to get a professional opinion on that...

Thank you!!!

N. Eb
  • 29
  • 3

1 Answers1

3

From the documentation for the Google Maps Distance Matrix API Usage Limits:

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.

The Google Maps Distance Matrix API has the following limits in place:

Standard Usage Limits
Users of the standard API:

  • 2,500 free elements per day
  • 100 elements per query
  • 100 elements per 10 seconds

When you were submitting a matrix of dimensions 33 x 3 you only had 99 elements, which was within the limit for the free tier of service. But when you added one more destination (giving you a matrix with dimensions either of 34 x 3 or 33 x 4), you exceeded 100, hence the error.

Your options include opting for the premium service, which gives you up to 625 elements per query, or somehow cutting down on the size of your input matrices.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360