Hello !
I want to generate a matrix between a list of construction sites (Chantiers_List : 33.9k address) and production sites (Postes_List : 31 address), Code bellow :
Since there is a limitation on the size of the computation, I segmented the “Chantier_List” into smaller List of 70 address and tried to call the API 485 times (which is under the 500 daily quota) but i do get an ApiError 500, as shown
Alternatively i added a sleep timer to space a bit the API calls between them, knowing the quota limit is 40 calls per minute, i chose 5 call per minute ! Code bellow :
# adding a delay / Sleep between the successive API calls
api_calls_per_minute = 5
delay_between_calls = 60 / api_calls_per_minute # in seconds
call_count = 0
start_time = time.time()
# Multiple calls over all the sublists of Chantier_List
for sublist in Sublists:
call_count += 1
if call_count % api_calls_per_minute == 0:
elapsed_time = time.time() - start_time
if elapsed_time < 60:
time.sleep(60 - elapsed_time)
start_time = time.time()
matrix = client.distance_matrix(
locations=sublist + Postes_List,
profile='driving-hgv',
destinations=[(len(sublist) + j) for j in range(len(Postes_List))],
metrics=['distance', 'duration'],
units="km",
validate=False,
)
I still get the same error :
ApiError: 500 ({‘timestamp’: ‘2024-07-01T13:07:53.873+00:00’, ‘status’: 500, ‘error’: ‘Internal Server Error’, ‘path’: ‘/ors/v2/matrix/driving-hgv/json’})
Any insights to solve the problem are really appreciated !
Best,
Wassime