Distance matrix api times out when previously working fine(?)

Hi.
I have tried to locate a post for this issue, but can’t see one. I have a section of code in a file that calls the ORS distance matrix API. This has been unchanged and working fine for months. I ran this code this morning and it worked fine as normal (30-50 second run time). I’ve gone to run this exact same code this evening and it has timed out at 2mins 3-4 sections. Are there any known issues with the API that could be causing this?
The code I’m running is pasted below. combined_coords has a length of 494, made up of 491 source coordinates and 3 destination coordinates. I’m comfortably within my allowance on the dashboard too. The API response is 504 Gateway Time-Out. When reading through the traceback I get the error message " JSONDecodeError : Expecting value: line 1 column 1 (char 0)".
Many thanks in advance for confirming if there is a known issue with the API / any advice you can provide to help me resolve this issue as I’m fairly new to using json in python still. Thanks.

---------------------------------------

apiUrl = “https://api.openrouteservice.org/v2/matrix/driving-car

request_headers = {
‘Accept’: ‘application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8’,
‘Authorization’: apiKey,
‘Content-Type’: ‘application/json; charset=utf-8’
}

step = 3500 // clinics_length

distances = []

for window_start in range(0, len(lsoa_coords), step):
window_end = window_start + step

if window_end > len(lsoa_coords):
    window_end = len(lsoa_coords)

request_body = {
    "locations": combined_coords,
    "destinations": list(range (len(combined_coords) - clinics_length, len(combined_coords))),
    "metrics":["distance"],
    "units":"mi",
    "sources": list(range(window_start, window_end))
}

response = requests.post(apiUrl, json=request_body, headers=request_headers)

print(response.status_code, response.reason)

json_object = response.json()
distances += json_object["distances"]
1 Like

Hi @MREves,

probably due to some downtime of the driving-car server (see status).

If you encounter this issue during uptime, it would be good the know the specific request where it hangs on.

Best regards

1 Like

Ah thanks for the quick reply and clarification. I hadn’t seen the status page, thanks for sharing the link. Will retain for future reference.