Request parameters exceeded - Route distance too long

I am trying to request routes from 100 coordinates of client addresses (held in a csv file) to a single coordinate (a foodbank site)

import csv
import openrouteservice
client = openrouteservice.Client(key='myAPIkey')

with open ('ClientCoordinates.csv' , 'r') as csv_coords:
    csv_reader = csv.reader(csv_coords) 
    EXTRA_COORD = (53.464774, 2.23179)
    new_csv_coords = []
    routelist = []
    for line in csv_reader:
         new_csv_coords.append(((float(line[0]), float(line[1])), EXTRA_COORD))
        
         coords = (new_csv_coords)
         print(coords[0]) 
         routes = client.directions(coords[0])

         print(routes)

This returns the error - Request parameters exceed the server configuration limits. The approximated route distance must not be greater than 6000000.0 meters.

My API token says I can perform 2000 requests, and I am only requesting 100 so I’m not sure what is going on. Thanks in advance for any help.

The error says that your requested route will be at least 6000km long and that exceeds the configuration limit (for a single request). Are your coordinates this far apart?

No, they are all within Manchester. What I think could be happening is that my code sends a request for a whole batch of 100 routes at once, rather than one by one - therefore exceeding the limit.

I am therefore trying to pass one coordinate pair at a time through the request, but I’m not sure how to change my code to do so.

No, you’re always sending the same request as far as I can see.

This should work better:

import csv
import openrouteservice
client = openrouteservice.Client(key='myAPIkey')

with open ('ClientCoordinates.csv' , 'r') as csv_coords:
    csv_reader = csv.reader(csv_coords) 
    EXTRA_COORD = [53.464774, 2.23179]
    for line in csv_reader:
         coords = [float(line[0]), float(line[1]]
         coords.extend(EXTRA_COORD)
         routes = client.directions(coords)

         print(routes)

Also, you’re using [lat, lon], ORS expects [lon, lat]. That’s def a bigger issue, even though it shouldn’t give you that error.

I changed the data to lon,lat format, thanks. For this example I get a few syntax errors - I should have mentioned I am writing in python3/ spyder.

Forgot to mention: that’s of course not tested. There’s at least one syntax error in there. IDE and Py version are not so relevant actually.