URL parameters to limit output lenghts/number of routing options/get XML output?


#1

Sorry to bother if it is something too simple or evident but i need help to use the directions API :

I would like to use an Excel formula to get the content of the page and extract “distance” and “duration”.

To do this I use =WEBSERVICE(url) function, and i cut the desired part of the raw output with some stxt etc.
It’s kind of artisanal but it’s the only way that i found without messing with macros where 'im lost,… and it works.

It works well with short results, but when they exceed 32k caracters, the result give an error instead of being written, even partially, and there is no way to access the needed information located in the first 400 characters.

So i need some way to shorten the result of the query :

  • Is there any parameter in the URL that i could add to limit number of possible itineraries, etc. ?

or

  • Is there any parameter in the URL that could give a result in an XML format, to isolate these parts directly from the formula ?

or

  • ???

Sorry if there is some documentation giving these informations but i just couldn’t find it, and i did search quite a lot.

Thank you very much in advance for your insights if you can help me !

Regards
GG


#2

Try to use instructions=false and geometry=false. That’ll shorten the response considerably.


#3

Excellent ! Thank you very much !

Regards
GG


#4

Well I have a problem to make these parameters being taken in account, probably with the syntax of the url ? :

I tried :
https://api.openrouteservice.org/v2/directions/driving-car/?api_key=xxxx&start=xx.xxx,x.xxx&end=xx.xxx,x.xxx&instructions=false&geometry=false

And the output is still the complete report with driving instructions, and the same amount of characters than without these parameters.

Am I doing something wrong ?

Thanks in advance for your help !

Regards
GG


#5

Yes, the GET v2 endpoint doesn’t support other querstring than start and end parameters. Either use POST or the old v1 endpoint:

https://openrouteservice.org/dev/#/api-docs/directions/get

(Click V1 in the bottom left corner of Api Version)


#6

It works, i get a nice short output :

https://api.openrouteservice.org/directions?api_key=xxx&coordinates=x.xx,x.xx|x.xx&profile=driving-car&geometry=false&instructions=false

I’ll investigate the POST method when necessary, this seems a bit complex, i hope it won’t be too soon :slight_smile:

Thanks for the quick support !

Regards
GG