Routing Web Service 2.0
Table of contents
Info
Remark: This is a RouteYou+ service. Please contact sales[at-r.] if you want to make use of this service and you don't have yet an agreement with RouteYou.
- Service name: Routing
- Version: 2.0
Technical
The web service is accessible using:
XML-RPC: Info on how to use- JSONP: Info on how to use
- JSON-RPC: Info on how to use
Overview of provided functions
get
Get the information of one or multiple routings. Contains the name, short name and the bounds where the routing is available.
Input
- id(s) (Integer|Array(Integer)): get the routing(s) with the given id(s). Check available routingids
- language (String|Null): language in iso2
- options (Struct|Null): not used yet
Output
- routingInfo (Object|Struct(Object)): if the input is just one id, an object is returned. If the input is an array, an array with the ids as key and the objects as value is returned.
route
Returns the route between at least 2 via points with a specific routing id.
When instructions are needed, use the new instruction format by passing the option newInstructionFormat. The old instruction format is deprecated and soon will no longer be supported.
Input
- via points (Array or List with dict in for python): a via point contains lon and lat. At least 2 via points should be passed
- routing id (Integer): check available routing ids
- options(Struct|null):
Possible options:- type
- id: adds the information of the routetype. Same types
- language: default english
- add:
- instructions: boolean
- elevation: boolean
- newInstructionFormat: boolean (should be true, old format is deprecated)
- type
Output
- route: a route Object is returned. The format of the instructions can be found here
Available routingids
- 15: recreational cycling - nicest
- 28: race cycling - nicest
- 29: recreational cycling - shortest
- 30: race cycling - shortest
- 31: hiking - nicest
- 32: race cycling - shortest (avoid cobblestones)
- 33: race cycling - nicest (avoid cobblestones)
- 34: inline skating - nicest
- 35: inline skating - shortest
- 36: gravel bike - nicest (winter)
- 37: gravel bike - shortest (winter)
- 38: node-to-node cycling
- 39: gravel bike - nicest (summer)
- 40: gravel bike - shortest (summer)
- 47: MTB Sport Vlaanderen - shortest (all directions)
- 48: MTB Sport Vlaanderen - shortest
- 49: motor - nicest
- 50: motor - shortest
- 51: motor - fastest
- 53: mountain bike - nicest
- 54: node-to-node cycling (only paved)
- 55: horse - node network
- 63: hiking - node network
- 76: recreational cycling - nicest (avoid unpaved)
- 80: shortest - OSM (all ways)
- 94: race cycling - nicest (with car)
- 95: race cycling - shortest (with car)
- 96: recreational cycling - shortest (only paved)
- 97: mountain bike - shortest
- 98: hiking - shortest
- 99: node-to-node cycling (avoid slopes)
suggest
Returns a suggested route with a specific routing id of a suggested distance
When instructions are needed, use the new instruction format by passing the option newInstructionFormat. The old instruction format is deprecated and soon will no longer be supported.
Input
- via points (Array or List with dict in for python): a via point contains lon and lat. At least 1 via point should be passed. The maximum for the moment is 2
- routing id (Integer): check available routing ids in the function above
- distance (Integer): the desired distance for the route
- options(Struct|null):
Possible options:- type
- id: adds the information of the routetype. Same types
- language: default english
- add:
- instructions: boolean
- elevation: boolean
- newInstructionFormat: boolean (should be true, old format is deprecated)
- seed: alter te seed the get different results
- heading: force the initial direction of a suggestion
- type
Output
- route: a route Object is returned. The format of the instructions can be found here
Example JSONP
Get the nicest route between Tielt and Ghent for a recreational cyclist.
Include instructions and elevation.
/* * Start session. Acquire the token that is needed for following web service calls */ $params = array( '<key>' ); $url = 'https://api.routeyou.com/2.0/json/Session?id=1&method=start¶ms=' . json_encode($params); $result = file_get_contents($url); $result = json_decode($result, true); $token = $result['result']; /* * Get the route between Tielt and Ghent. Include instructions and elevation. */ $params = array( array( array('lon' => 3.3270227909088135, 'lat' => 51.00021243419066), // Tielt array('lon' => 3.7233835458755493, 'lat' => 51.053666345912184) //Ghent ), 15, //Recreational nicest array( 'add' => array('elevation' => true, 'instructions' => true), 'newInstructionFormat' => true ) ); $url = 'https://api.routeyou.com/2.0/json/Routing/' . $token . '?id=1&method=route¶ms=' . json_encode($params); $content = file_get_contents($url); $result = json_decode($content, true); var_dump($result);
The geometry and the elevation is google encoded.
When the elevation is decoded then is x the distance from start and y the height in meters.
More information about the importance of a certain instruction can be found here