Matrix API returning None for all

Hi, I’m using the matrix API to get driving time between many origins and destinations however when I run the request it seems that all of the durations fetched are returned as None. I’ve redacted the actual lat and long co-ordinates for privacy however it is just the lat and long tuples that are contained within eac of the coordinates, destination and source lists. See code below:

import openrouteservice as ors

client = ors.Client(key = ORSAPIKEY)

#lat and long for both origins and destination
coordinates = [(Lat1, Long1)... (LatX, LongY]

#  destinations lat and long
destination = [(Lat1, Long1)... (LatX, LongY]
destinations = [i for i in range(len(destination))]

#sources lat and long
source = [(Lat1, Long1)... (LatX, LongY]

sources=[i for i in range(len(destination),len(source))]

coordinates = coordinates
sources = sources
destinations = destinations

matrix = client.distance_matrix(
    locations= coordinates,
    sources = sources,
    destinations= destinations,
    units = 'm',
    validate = True)

print("Duration in secs:{}\n".format(matrix['durations']))

The output of the print statement returns None for all of the origin and destination pairs. I’ve looked at the documentation on GitHub but can’t see any errors when comparing to that code, so any help regarding errors leading to the output of None being returned would be appreciated.


I’m a bit confused by your code.
First, note that the ors uses [Lon, Lat] format. Your code heavily suggests you use [Lat, Lon], which mya be the source of your errors.
Second, make sure that your indices for your sources and destinations are valid for the locations array you’re passing and contain useful information. Given that coordinates == destination == source if I read your code correctly, sources should be empty since len(destination) == len(source).

Best regards