How to configure route preference for directions api?

Hey, probably a simple question but I was wondering if there is a way I can configure the route preference, with that I mean if the shortest or the recommended (or whatever else) route is returned, through the api call (for the driving-car profile)? I know that I can configure that in the ors-config.json but I would like to parametrize it so I can change the response depending on the users input.

I found this functionality (screenshot down below) in the online map and figured that there has to be a way.
screenshot

Thanks for any answers in advance!

Hey,

as seen in the API Documentation, there’s the preference key that can be set to any of fastest, shortest or recommended.

Note, that this’ll only work for the POST request.

Best regards

Hey, thanks this is the answer I was looking for. I managed to refractor my code for the sake of the endpoint-call. But now the geometry-object of the response-object returns a weird-looking string (see picture). Is this the intended behaviour?
screenshot

Thank you.

Hey,

yes it is. As per the API Documentation (response tab, click on the green questionmark), this is an encoded polyline.

Best regards

1 Like

Thanks alot for your help I really appreciate it!

1 Like