Overview

Route calculation between two locations with possible multiple waypoints (stop-overs) and calculation of alternative routes. Configurable combination of real-time traffic conditions, planned closures, incidents and traffic flow prediction used in route planning. Returning distance, driving time to destination, estimated time of arrival and routing directions.
Routing API can work with traffic prediction data as well as with real time traffic data. Including these parameters will influence the ETA calculation resulting in much more precise ETA.

Default output format is JSON and there is no need to specify it anywhere in the URL request.

Route is returned in JSON as Google Encrypted Polyline with additional information.

Live Example

This example demonstrates the use of the Routing service. Click on icons to see code on Github or play with it in JSFiddle:

  • Request

    API Reference

    https://routing.api.sygic.com/v0/api/directions?key=yourAPIkey

    Request authentication is done via parameter key, which must be included in the request URL.

    Methods

    Method Description
    GET Both methods provide the same functionality.
    POST Both methods provide the same functionality.

    Parameters

    Required parameters

    Parameter Data type Value Description
    origin string {latitude},{longitude} GPS coordinates defining the start location of the route.
    destination string {latitude},{longitude} GPS coordinates defining the end location of the route.
    key string The API key.

    To create a valid request all above parameters must be included in the URL request.

    Optional parameters

    Parameter Data type Default Value Description
    waypoints string {latitude},{longitude} Array of waypoints defined in GPS coordinates. Optionally stop time in seconds can be specified for each waypoint. If you'd like to influence the route using waypoints without adding a stopover, prefix the waypoint with "via:". Waypoints prefixed with "via:" will not add an entry to the legs array, but will instead route the journey through the provided waypoint. The stopover is not taken into account in computing when "via:" prefix is used. More waypoints must be delimited with pipe character.

    Example: 48.40975,20.86831|49.30975,20.86831
    Example: 48.40975,20.86831,300|49.30975,20.86831,600
    Example: via:48.40975,20.86831|49.30975,20.86831
    avoid string tolls
    highways
    ferries
    unpaved
    congestioncharges
    country
    If routing should avoid specific types of roads or areas. More values must be delimited with pipe character. Avoids can be applied in two manners: global and country specific with a country prefix. congestioncharges avoid type can be used only globally, country only with country prefix.

    Example: tolls|highways|ferries|unpaved
    Example - avoid tolls in Czech Republic and completely avoid Germany: cze:tolls|unpaved|deu:country

    * If any of the specified avoids cannot be excluded from the calculated route, the response contains property "ignored_avoids" specifying which avoids are ignored.
    avoid_rectangles string [{rect1};{rect2}; ... {rectX}]
    where
    {rect} = [{latLngPair1}|{latLngPair2}| ... {latLngPairX}]
    where
    {latLngPair} = {latitude},{longitude}
    Array of rectangles defined by GPS coordinates. Each rectangle is defined by array of coordinates. From that array, the top-most left and bottom-most right coordinate is taken to calculate bounding box. All roads within calculated bounding box are to be avoided.

    Example (line crossing the road): 48.135150,17.138237|48.133854,17.140780
    Example (multiple roads crossed by a line): 48.135150,17.138237|48.133854,17.140780;48.137136,17.126996|48.137136,17.128841
    Example (explicit rectangle): 48.134221,17.139685|48.134221,17.140685|48.135221,17.140685|48.135221,17.139685
    vehicle_heading integer Angle in degrees in which vehicle travels (0 for north, 90 for east, 180 for south, 270 for west etc.). Used for vehicles on the move - the angle is used to reduce possibility of u-turns in resulting polyline.
    speed_profiles boolean true true
    false
    Speed profiles are representing the typical traffic situation on a given road at a given time and day. When calculating route ahead speed profiles serve as traffic prediction service.
    traffic boolean false true
    false
    Real time traffic will be included in route calculation. This option is only available with appropriate licensing model and data provider.

    Traffic returns:
    - the severity of the traffic jam
    - delay in seconds for each segment
    - polyline for representing the traffic visually
    vehicle_type string car car
    camper
    van
    truck
    Defines type of vehicle and adjusts the routing accordingly.
    route_computing string fastest fastest
    shortest
    economic
    Type of route computing. Only one type of computation can be set at a time. More values must be delimited by pipe character.

    Example: fastest|shortest|economic
    compute_alternatives boolean false true
    false
    If compute_alternatives is true response will return up to 3 alternatives (incl. original result) if there are any available.
    units string metric metric
    imperial
    Units’ format.
    max_speed integer 255 1 - 255 Maximum vehicle speed (in units as defined in parameter above) Range: 1 - 255 km/h.
    departure_time integer current UTC time Number of seconds since midnight, January 1, 1970 UTC.
    prefer_right_turn boolean false true
    false
    Preference of right turns (left in left-hand traffic countries) in route calculation.
    dest_in_driving_side boolean false true
    false
    Reach destination in driving direction.

    Vehicle types

    Depending on the vehicle type special constraints, speed attributes and weights are taken into account during route calculation.

    Vehicle type Description
    car Route calculation for personal car.
    truck Route calculation for trucks. This mode considers logistic attributes (dimensions, weight, limitations on hazardous materials) for route calculation. Truck can enter delivery zones.
    camper Route calculation for camper. This mode considers limitations on dimensions. Camper cannot entry delivery zones.
    van Route calculation for van. Van can enter delivery zones. Scenic routes are avoided.
    pedestrian Route calculation optimized for a walking persons. It does not take into account one-way roads, driving bans, prohibited maneuvers, traffic informations.

    Route calculation for truck and camper takes into account default values described below.

    Truck

    Parameter Default Value
    Max speed 90 km/h
    Total weight 10 000 kg
    Axle weight 5 000 kg
    Total vehicle length 10 000 mm (10 m)
    Total width 2500 mm (2.5 m)
    Maximum height 3000 mm (3 m)
    Number of trailers 0
    Number of vehicle axles 2
    Number of trailer axles 0
    Camper

    Parameter Default Value
    Max speed 90 km/h
    Total weight 10 000 kg
    Total vehicle length 10 000 mm (10 m)
    Total width 2500 mm (2.5 m)
    Maximum height 3000 mm (3 m)

    If defined, the vehicle parameters will influence the route calculation results based on the vehicle's attributes. Length, width and height is defined in "mm", weight is defined in "kg". Complete list of supported attributes:

    Vehicle parameter Data type Value
    total_weight integer
    axle_weight integer
    total_length integer
    width integer
    height integer
    trailers integer
    vehicle_axles integer
    trailer_axles integer
    general_hazard boolean true, false
    water_hazard boolean true, false
    tunnel string b, c, d, e

    Response

    GET

    GET https://routing.api.sygic.com/v0/api/directions?origin=54.321697,10.121991&destination=54.307322,9.661965&key=yourAPIkey

    POST

    POST https://routing.api.sygic.com/v0/api/directions?key=yourAPIkey
    
    Content-Type: application/json

    Request Body

    { 
        "origin": "54.321697,10.121991", 
        "destination": "54.307322,9.661965", 
        "vehicle_type": "truck",
        "height_at_first_axle": 300,
        "total_weight": 8000, 
        "trailers": 1, 
        "vehicle_axles": 2, 
        "trailer_axles": 1,
        "emission_class": "euro4" 
    }

    Response

    Both GET and POST method produce the same response body:

    {
        "routes": [
            {
                "route": "oupjIa}w|@^ErCUPELEf@@`A[nAjGlBnFfBtERl@~DdNdA~DdBjG|BhKfArELbAd@`EJdFKxF?rBVfKF~BFjH@jEChJC`DMtLCzEApB@bIRdOZlGdAtLr@tErAxGnIj\\fBnIrBxMr@|Gh@fHf@jJPvFDvAHxBBf@X|EA`Br@zLd@|Dz@hF`AzElBhIvClMnA|Ib@dGd@bKb@rYBbBJ|CDxGFjEx@tm@N`ID|CF`PStMI|B[`Hi@vIcA`KkC|PcBtIoBlIaF`RgN~c@oGpTqGrWaFtWyEd\\mAlKcBpQkBbX{@~PcAlYG`CClAEdBAj@KdEe@z`@AlBCjDC|XJ~WTrTh@rWZ`Pf@tUTfK`@fQ|@d]v@|O|BpYhBpOrE`\\bC`RDZf@fEvBlULtBZfFJhBNxCBZn@xQ\\~TZb`@JxQ@jNO~PeAfa@mDzdAo@jOsArSmDx_@eAnK}AlRs@zNg@rRChUB|ENzKZnR~B~tAvBthAv@nUtAdWbCl\\p[zbDrFhh@nDvZdB`Mb@~C|@xGrJ~n@fIzb@pBlJv@lDzAxGrDtOzEnQ|Rdr@|FzU|ArH|DfU~ArLx@xG^dDtBbQb@nDhAtIFf@\\`CZvBDXbAbHDXbBvKv@`E|BfJd@~BVlAJh@tA~Gb@tB\\~AtDbPrB~IxB~IzB`JvCdLzAdGjAvELb@Nn@|@xDR~@r@jDzAjI`@hCT~AhDbVF\\fAjIlBbOrAlKjAtIr@lFz@nG@JJv@v@`G`@|Cd@jDDhAJp@D^TzB@ZBpCStEYfB_@pAeAlCINo@~@oBbBoCrAaFfB_H`BsGhA}Ch@gMrB}Bd@oAR_APyOlCwAV}EdASF]JcErA_BXe@G]w@EsBNu@l@yBZe@j@]f@GjBTx@JXF@kApAc]ImEO_AWq@uAkAgAe@eCyA_CoDm@s@cA[eCM?mIYiBsAcEy@uBcA}A]MeAGu@?e@VsEVw@Ho@JiBHwAEa@SaAKy@Cs@PuAlAc@r@sChE{CjFkA`D}AbGIj@y@bEW`Ai@rAw@tA",
                "eta": 1531834797,
                "duration": {
                    "value": 1713,
                    "text": "28 minutes 33 seconds"
                },
                "distance": {
                    "value": 36430,
                    "text": "36.43 km"
                },
                "legs": [
                    {
                        "distance": {
                            "value": 36430,
                            "text": "36.43 km"
                        },
                        "duration": {
                            "value": 1713,
                            "text": "28 minutes 33 seconds"
                        },
                        "start_location": {
                            "latitude": 54.32168,
                            "longitude": 10.12193
                        },
                        "end_location": {
                            "latitude": 54.30731,
                            "longitude": 9.66195
                        },
                        "route": "oupjIa}w|@^ErCUPELEf@@`A[nAjGlBnFfBtERl@~DdNdA~DdBjG|BhKfArELbAd@`EJdFKxF?rBVfKF~BFjH@jEChJC`DMtLCzEApB@bIRdOZlGdAtLr@tErAxGnIj\\fBnIrBxMr@|Gh@fHf@jJPvFDvAHxBBf@X|EA`Br@zLd@|Dz@hF`AzElBhIvClMnA|Ib@dGd@bKb@rYBbBJ|CDxGFjEx@tm@N`ID|CF`PStMI|B[`Hi@vIcA`KkC|PcBtIoBlIaF`RgN~c@oGpTqGrWaFtWyEd\\mAlKcBpQkBbX{@~PcAlYG`CClAEdBAj@KdEe@z`@AlBCjDC|XJ~WTrTh@rWZ`Pf@tUTfK`@fQ|@d]v@|O|BpYhBpOrE`\\bC`RDZf@fEvBlULtBZfFJhBNxCBZn@xQ\\~TZb`@JxQ@jNO~PeAfa@mDzdAo@jOsArSmDx_@eAnK}AlRs@zNg@rRChUB|ENzKZnR~B~tAvBthAv@nUtAdWbCl\\p[zbDrFhh@nDvZdB`Mb@~C|@xGrJ~n@fIzb@pBlJv@lDzAxGrDtOzEnQ|Rdr@|FzU|ArH|DfU~ArLx@xG^dDtBbQb@nDhAtIFf@\\`CZvBDXbAbHDXbBvKv@`E|BfJd@~BVlAJh@tA~Gb@tB\\~AtDbPrB~IxB~IzB`JvCdLzAdGjAvELb@Nn@|@xDR~@r@jDzAjI`@hCT~AhDbVF\\fAjIlBbOrAlKjAtIr@lFz@nG@JJv@v@`G`@|Cd@jDDhAJp@D^TzB@ZBpCStEYfB_@pAeAlCINo@~@oBbBoCrAaFfB_H`BsGhA}Ch@gMrB}Bd@oAR_APyOlCwAV}EdASF]JcErA_BXe@G]w@EsBNu@l@yBZe@j@]f@GjBTx@JXF@kApAc]ImEO_AWq@uAkAgAe@eCyA_CoDm@s@cA[eCM?mIYiBsAcEy@uBcA}A]MeAGu@?e@VsEVw@Ho@JiBHwAEa@SaAKy@Cs@PuAlAc@r@sChE{CjFkA`D}AbGIj@y@bEW`Ai@rAw@tA",
                        "eta": 1531834797
                    }
                ]
            }
        ],
        "status": "OK",
        "copyright": "© 2018 Sygic a.s."
    }
    Response with avoids
    GET https://routing.api.sygic.com/v0/api/directions?origin=51.51168,-0.11819&destination=51.49368,-0.09390&avoid=congestioncharges&key=yourAPIkey
    {
        "routes": [{
                "route": "wzkyHpaVv@|CPNN@XSJK`EcDPMLKjBaBvBiBNMhFoEXUbA}@vDeDb@_@dBwA\\_@LSN}@Na@ZOX@V?NLHT@r@ALEZBXJn@LXDJb@r@DFNNVZb@`@^\\JJx@v@bC`Cn@j@bAx@jAn@VBJKf@oCHe@Vq@VGT@PFRVBLBJNd@N\\^lACXUIXOJBJ?LBh@FPBj@H\\DPsBHK~A^z@aEZaBd@iAzAmFz@nAv@jAnAvApAv@ZN~@Lt@@QkAIk@[sBc@sCfA}@TSRMRq@^AN\\^LZIP[n@E~@xAfEaKVAdADfAsDRe@JWlA}CmCoEa@mA[mBKgANu@hBcAnAm@~DgBGe@i@cFIs@O{@WeAq@{@W]CEGEmA}BSYUe@i@aAEIY_@q@_@k@U[GEs@@Wj@wB@M@c@VqADOHOHQNOvA{@lAs@^WkAmIyAqKK{ASKa@Au@Rc@HUD",
                "eta": 1531818531,
                "duration": {
                    "value": 1092,
                    "text": "18 minutes 12 seconds"
                },
                "distance": {
                    "value": 4715,
                    "text": "4.72 km"
                },
                "legs": [{
                        "distance": {
                            "value": 4715,
                            "text": "4.72 km"
                        },
                        "duration": {
                            "value": 1092,
                            "text": "18 minutes 12 seconds"
                        },
                        "start_location": {
                            "latitude": 51.51164,
                            "longitude": -0.11817
                        },
                        "end_location": {
                            "latitude": 51.49363,
                            "longitude": -0.09402
                        },
                        "route": "wzkyHpaVv@|CPNN@XSJK`EcDPMLKjBaBvBiBNMhFoEXUbA}@vDeDb@_@dBwA\\_@LSN}@Na@ZOX@V?NLHT@r@ALEZBXJn@LXDJb@r@DFNNVZb@`@^\\JJx@v@bC`Cn@j@bAx@jAn@VBJKf@oCHe@Vq@VGT@PFRVBLBJNd@N\\^lACXUIXOJBJ?LBh@FPBj@H\\DPsBHK~A^z@aEZaBd@iAzAmFz@nAv@jAnAvApAv@ZN~@Lt@@QkAIk@[sBc@sCfA}@TSRMRq@^AN\\^LZIP[n@E~@xAfEaKVAdADfAsDRe@JWlA}CmCoEa@mA[mBKgANu@hBcAnAm@~DgBGe@i@cFIs@O{@WeAq@{@W]CEGEmA}BSYUe@i@aAEIY_@q@_@k@U[GEs@@Wj@wB@M@c@VqADOHOHQNOvA{@lAs@^WkAmIyAqKK{ASKa@Au@Rc@HUD",
                        "eta": 1531818531
                    }
                ],
                "ignored_avoids": {
                    "congestioncharges": [
                        "wzkyHpaVv@|CPNN@XSJK`EcDPM",
                        "}_kyHbrUbA}@vDeDb@_@dBwA\\_@LSN}@Na@ZOX@V?NLHT@r@ALEZBXJn@LXDJb@r@DFNNVZb@`@^\\JJx@v@bC`Cn@j@bAx@jAn@VBJKf@oCHe@Vq@VGT@PFRVBLBJNd@N\\^lACXUIXOJBJ?LBh@FPBj@H\\D",
                        "qvhyHdnUQkAIk@[sBc@sC",
                        "qghyHhtTVAdAD"
                    ]
                }
            }
        ],
        "status": "OK",
        "copyright": "© 2018 Sygic a.s."
    }

    Response Code

    Response codes follow HTTP response standard.

    Route format

    Sygic Routing API is using Google Encoded Polyline that stores a series of coordinates into a single string. More information about Encoded Polyline can be found on this link.

    Encoded polyline string from the response is escaped.
    Polyline below is encoded from two coordinates "41.6076,-88.21549","41.60745,-88.21537":

    on}|FxqlyO\W

    it contains characters ['o', 'n', '}', '|', 'F', 'x', 'q', 'l', 'y', 'O', '\', 'W'], therefore if used as string literal in code, it has to be declared as:

    var polyline = "on}|FxqlyO\\W";

    Dispatch itinerary

    For seamless support of route dispatching from Sygic Maps server side into the Sygic Professional Navigation SDK we provide possiblity to request the Routing response in SIF format.

    Request body and parameters remains the same as in standard Routing API calculation.

    To receive Routing response in SIF format you need to change the following key:value in request Header:

    Key Value
    accept application/vnd.sygic-sif+json

    Response example:

    {
        "name": "db9cad92-36c3-41c4-9416-2532b1cfbc4c",
        "routeParts": [
            {
                "waypointFrom": {
                    "lat": 4815027,
                    "lon": 1712561,
                    "type": "start"
                },
                "waypointTo": {
                    "lat": 4797874,
                    "lon": 1761001,
                    "type": "finish"
                }
            }
        ],
        "status": "OK",
        "copyright": "© 2017 Sygic a.s."
    }