Route service with synchronous execution

The route service can be used to find the best way to get from one location to another or to visit several locations. The best route can be the quickest route for a given time of day considering the traffic conditions applicable during that time, or it can be the shortest route that minimizes the travel distance. The route service can also find the best route that visits each stop during permitted time windows you specify. If you have more than two stops to visit, the best route can be determined for the fixed order of locations you specify. Such a route is called a simple route. Alternatively, the route service can determine the best sequence in which to visit the locations (the traveling salesman problem). Such a route is called an optimized route.

Request URL

You can make a request to the synchronous route service using the following form:

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?<PARAMETERS>

The Route service supports synchronous and asynchronous execution modes. Asynchronous and synchronous modes define how the application interacts with the service and gets the result. When using the synchronous execution mode, the application must wait for the request to finish and get the results. This execution mode is well-suited for requests that complete quickly (under 10 seconds). When using the asynchronous execution mode, the client must periodically check whether the service has finished execution and, once completed, get the result. While the service is executing, the application is available to do other things. This execution mode is well-suited for requests that take a long time to complete because it allows users to continue to interact with the application while the results are generated.

While the service supports the same functionality irrespective of execution mode, the choice of the execution mode depends on the type of request your application has to make as well as the size of problem you need to solve using the service. In synchronous mode, the service limits the maximum number of stops to 150. In asynchronous mode, the maximum number of stops is 10,000 and the maximum number of stops per route is 150. So, if you are finding several routes and have fewer than 150 total stops, you can use the synchronous execution mode. However, if your application needs to support more than 150 total stops in a request, you need to use the asynchronous execution mode.

The request URL and the parameter names supported by the service when using asynchronous execution are different and described in the Route service with asynchronous execution page.

CautionCaution:

The maximum time an application can use the Route service when using the synchronous execution mode is 5 minutes (300 seconds). If your request does not complete within this time limit, it will time out and return a failure.

Dive-inDive-in:

The service works in all of the supported countries as listed in the data coverage page. One or more countries are grouped together to form a region. When you pass in your stops, the service determines the region containing all of the input stops based on the location of the first stop. The service does not support requests that span more than one region. Consequently, a route will be found only between those stops that are in the same region as the first stop.

Request parameters

The route request takes the following parameters. The only required parameters are stops, token and f. The optional parameters have default values which will be used if the parameter is not specified in the request.

Required parameters

stops

Use this parameter to specify two or more locations between which the route is to be found.

CautionCaution:

The service imposes a limit of 150 points that can be passed as stops. If the value is exceeded, the response returns an error message.

You can use a simple comma- and semicolon-based syntax if you need to specify only stop point geometries in the default spatial reference WGS84 such as the longitude and latitude values.

Simple syntax for stops
stops=x1,y1; x2, y2; ...; xn, yn
Example using simple syntax
stops=-117.1957,34.0564; -117.184,34.0546

You can specify stop geometries as well as attributes using a more comprehensive JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url property must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or the url property must be specified.

Each feature in the features array represents a stop and contains the following properties:

  • geometry: Specifies the stop geometry as a point containing x and y properties along with a spatialReference property. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for stops

When specifying the stops using JSON structure, you can specify additional properties for stops, such as their names, using attributes. The stops parameter can be specified with the following attributes:

  • Name: The name of the stop. This name is used when generating driving directions. It is common to pass the name of a business, person, or street address at the stop. If a value is not specified, an autogenerated name such as Location 1 or Location 2 is automatically assigned to each stop.

  • TimeWindowStart: The earliest time the stop can be visited. Specify this attribute if you want to limit when a route can arrive at a stop; for instance, you may want to make deliveries to a restaurant between busy lunch and dinner hours (for example, sometime between 2:00 and 4:30 p.m.) to facilitate the work for you and the restaurant staff.

    The value is specified as an integer that represents the number of milliseconds since epoch (January 1, 1970).

    This value can either be specified in UTC or local time, depending on the value given for the timeWindowsAreUTC parameter.

    If you specify this attribute, you also need to specify the TimeWindowEnd attribute.

  • TimeWindowEnd: The latest time the stop can be visited. Together, the TimeWindowStart and TimeWindowEnd attributes make up the time window within which a route can visit the stop. Like TimeWindowStart, the TimeWindowEnd value is specified as an integer that represents the number of milliseconds since epoch (January 1, 1970) and is interpreted as UTC or local time, depending on the value specified for the timeWindowsAreUTC parameter.

    The time window specified using TimeWindowStart and TimeWindowEnd attributes is not considered a hard constraint by the service. That is, the service doesn't fail if the stop cannot be visited during the time window; instead, the service tries to find a route that visits the stop during its time window, but if time window violations are inevitable, the service tries to find a solution that minimizes the time-window violation time for all stops in the problem.

    If a route has to arrive early at the stop, a wait time is added to the total travel time of the route. Similarly, if the route arrives late at the stop, a violation time is added to the total travel time of the route. For example, If the time window on the stop is set as 10:00 AM to 11:00 AM and the earliest a route can reach the stop is 11:25 AM, a violation of 25 minutes is added to the total travel time.

  • RouteName: The name of the route to which the stop belongs. Use this attribute to group stops into different routes and, therefore, solve multiple routes in a single request. For example, if you want to find two distinct routes—a route with 4 stops and another with 6 stops—set RouteName to Route1 for each of the four stops and Route2 for each of the 6 stops. The service will produce two distinct routes and driving directions for each group of stops in a single request.

    If RouteName is not specified for any stops, then all stops belong to the same route. If RouteName is not specified for some stops, those stops are treated as unassigned and are not included in any route.

    NoteNote:

    The grouping is entirely based on the provided input, and no attempt is made by the service to group stops in any optimal manner. If you wish to figure out the optimal grouping of stops into routes, you should use the vehicle routing problem service instead.

  • Sequence: Given the findBestSequence parameter is set to false (its default value), the output routes will visit the stops in the order you specify with this attribute. Within a group of stops that have the same RouteName value, the sequence number should be greater than 0 but not greater than the total number of stops. Also, the sequence number should not be duplicated.

  • CurbApproach: Specifies the direction a vehicle may arrive at and depart from the stop. One of the integers listed in Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you might have come across when using ArcGIS Network Analyst extension extension software.

    Setting

    Coded value

    Description

    Either side of vehicle

    0

    The vehicle can approach and depart the stop in either direction, so a U-turn is allowed at the stop. This is the default value. This setting can be chosen if it is possible and desirable for your vehicle to turn around at the stop. This decision may depend on the width of the road and the amount of traffic or whether the stop has a parking lot where vehicles can pull in and turn around.

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    Right side of vehicle

    1

    When the vehicle approaches and departs the stop, the stop must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the right hand side.

    Right side of vehicle
    The allowed arrival and departure combination for the Right side of vehicle curb approach.

    Left side of vehicle

    2

    When the vehicle approaches and departs the stop, the stop must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the left hand side.

    Left side of vehicle
    The allowed arrival and departure combination for the Left side of vehicle curb approach.

    No U-Turn

    3

    When the vehicle approaches the stop, the stop can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived in. A U-turn is prohibited.

    No U-turns
    The allowed arrival and departure combinations for the No U-Turn curb approach.

    The CurbApproach property was designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider a stop on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach from the right or left side. For example, if you want to arrive at a stop and not have a lane of traffic between the vehicle and the stop, you would choose Right side of vehicle in the United States but Left side of vehicle in the United Kingdom.

    Right side of vehicle with right-hand traffic.
    With right-hand traffic, the curb approach that leaves the vehicle closest to the stop is Right side of vehicle.
    Left side of vehicle with left-hand traffic
    With left-hand traffic, the curb approach that leaves the vehicle closest to the stop is Left side of vehicle.

  • Attr_TravelTime: Specifies the amount of time for cars, in minutes, that will be spent at the stop when the route visits it. This attribute can be used to model the time required to provide some kind of service while you are at the stop. It can also be used to specify some additional time required to reach the actual location on the street from where the route starts or time required to reach the actual destination location from the location on the street where the route ends. The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the stop requires no service time.

    For example, suppose you are finding the best route through three stops. Suppose it requires 2 minutes to walk to the street location from where the route starts, you need to spend 10 minutes at Stop 2, and it takes 5 minutes to walk from the street location to the destination. The Attr_TravelTime attribute should be given values of 2, 10, and 5 for Stop 1, Stop2, and Stop 3, respectively. If it takes 10 minutes to travel from Stop 1 to Stop 2 and 10 minutes to travel from Stop 2 to Stop 3, the total travel time to reach Stop 3 is displayed as 37 minutes (2 + 10 + 10 + 10 + 5), even though there is only 20 minutes of traveling to reach Stop 3.

  • Attr_TruckTravelTime: Specifies the amount of time for trucks, in minutes, that will be added to the total travel time of the route at the stop. The attribute value can be used to model the time spent at the stop.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the incident requires no service time. The default value is 0.

  • Attr_WalkTime: Specifies the amount of time for pedestrians, in minutes, that will be added to the total travel time of the route at the stop. The attribute value can be used to model the time spent at the incident.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the incident requires no service time. The default value is 0.

  • Attr_Miles: Specifies the distance in miles that will be added when calculating total distance of the route. Generally the locations of the stops are not exactly on the streets but are set back somewhat from the road. The Attr_Miles attribute can be used to model the distance between the actual stop location and its location on the street if it is important to include that distance in the total travel distance.
  • Attr_Kilometers: Specifies the distance in kilometers that will be added when calculating total distance of the route. Generally the locations of the stops are not exactly on the streets but are set back somewhat from the road. The Attr_Kilometers attribute can be used to model the distance between the actual stop location and its location on the street if it is important to include that distance in the total travel distance.
  • LocationType: Describes the stop type.

    Setting

    Coded Value

    Description

    Stop

    0

    A location that the route should visit. This is the default.

    Waypoint

    1

    A location that the route should travel through without making a stop. Waypoints can be used to force the route to take a specific path (to go through the waypoint) without being considered an actual stop. Waypoints do not appear in driving directions.

    Break

    2

    A location where the route stops for the driver to take a break.

  • Bearing: Specifies the direction the vehicle or person is moving in. Bearing is measured clockwise from true north and must be in degrees. Typically, values are between 0 and 360; however, negative values are interpreted by subtracting them from 360 degrees.

  • BearingTol: Short for bearing tolerance, this field specifies the maximum acceptable difference between the heading of a vehicle and a tangent line from the point on a street where Network Analyst attempts to locate the vehicle. The bearing tolerance is used to determine whether the direction in which a vehicle is moving generally aligns with the underlying road. If they align within the given tolerance, the vehicle is located on that edge; if not, the next nearest eligible edge is evaluated.

Syntax for specifying stops using JSON structure for features
{
    "features": [
        {
            "geometry": {
                "x": <x>,
                "y": <y>,
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "x": <x>,
                "y": <y>,
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying stops using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying stop geometries and attributes using JSON structure

The geometries for stops are in the default spatial reference, WGS84, and hence the spatialReference property is not required within the geometry property. The example also shows how to specify the Name attribute for each stop and group four stops into two routes, Route A and Route B, using the RouteName attribute.

{
    "features": [
        {
            "geometry": {
                "x": -122.4079,
                "y": 37.78356
            },
            "attributes": {
                "Name": "From",
                "RouteName": "Route A"
            }
        },
        {
            "geometry": {
                "x": -122.404,
                "y": 37.782
            },
            "attributes": {
                "Name": "To",
                "RouteName": "Route A"
            }
        },
        {
            "geometry": {
                "x": -122.4095,
                "y": 37.78379
            },
            "attributes": {
                "Name": "From",
                "RouteName": "Route B"
            }
        },
        {
            "geometry": {
                "x": -122.480,
                "y": 37.734
            },
            "attributes": {
                "Name": "To",
                "RouteName": "Route B"
            }
        }
    ]
}
Example 2: Specifying stop geometries in Web Mercator spatial reference using JSON structure.

The stops geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence the spatialReference property is required within the geometry property.

{
    "features": [
        {
            "geometry": {
                "x": -13635398.9398,
                "y": 4544699.034400001,
                "spatialReference": {
                    "wkid": 102100
                }
            },
            "attributes": {
                "Name": "Home",
            }
        },
        {
            "geometry": {
                "x": -13632733.3441,
                "y": 4547651.028300002,
                "spatialReference": {
                    "wkid": 102100
                }
            },
            "attributes": {
                "Name": "Office",
            }
        }
    ]
}
Example 3: Specifying stops using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&f=json"
}

token

Use this parameter to specify a token that provides the identity of a user that has the permissions to access the service. Accessing services provided by Esri provides more information on how such an access token can be obtained.

f

Use this parameter to specify the response format. Choose either json or pjson, for example, f=json. The pjson value is used for printing the JSON response in a pretty format.

Optional Parameters

travelMode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Online and can be configured by the administrator of your organization to better reflect your organization's workflows. You need to specify the JSON object containing the settings for a travel mode supported by your organization. To get a list of supported travel modes, execute the GetTravelModes tool from the Utilities service.

The value for the travelMode parameter should be a JSON object representing travel mode settings. When you use the GetTravelModes tool from the Utlities service, You get a string representing the travel mode JSON. You need to convert this string to a valid JSON object using your API and then pass the JSON object as the value for the travelMode parameter.

For example, below is a string representating the Walking Time travel mode as returned by the GetTravelModes tool.

"{\"attributeParameterValues\": [{\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Walking\", \"value\": \"PROHIBITED\"}, {\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Preferred for Pedestrians\", \"value\": \"PREFER_LOW\"}, {\"parameterName\": \"Walking Speed (km/h)\", \"attributeName\": \"WalkTime\", \"value\": 5}], \"description\": \"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.\", \"impedanceAttributeName\": \"WalkTime\", \"simplificationToleranceUnits\": \"esriMeters\", \"uturnAtJunctions\": \"esriNFSBAllowBacktrack\", \"restrictionAttributeNames\": [\"Preferred for Pedestrians\", \"Walking\"], \"useHierarchy\": false, \"simplificationTolerance\": 2, \"timeAttributeName\": \"WalkTime\", \"distanceAttributeName\": \"Miles\", \"type\": \"WALK\", \"id\": \"caFAgoThrvUpkFBW\", \"name\": \"Walking Time\"}"

The above value should be converted to a valid JSON object and passed as the value for the travelMode parameter

travelMode={"attributeParameterValues":[{"parameterName":"Restriction Usage","attributeName":"Walking","value":"PROHIBITED"},{"parameterName":"Restriction Usage","attributeName":"Preferred for Pedestrians","value":"PREFER_LOW"},{"parameterName":"Walking Speed (km/h)","attributeName":"WalkTime","value":5}],"description":"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.","impedanceAttributeName":"WalkTime","simplificationToleranceUnits":"esriMeters","uturnAtJunctions":"esriNFSBAllowBacktrack","restrictionAttributeNames":["Preferred for Pedestrians","Walking"],"useHierarchy":false,"simplificationTolerance":2,"timeAttributeName":"WalkTime","distanceAttributeName":"Miles","type":"WALK","id":"caFAgoThrvUpkFBW","name":"Walking Time"}

CautionCaution:

When the travelMode parameter is set, you are choosing a travel mode configured in your organization, and the service automatically overrides the values of other parameters with values that model the chosen travel mode. The following parameters are overridden: impedanceAttributeName, attributeParameterValues, restrictUturns, useHierarchy, restrictionAttributeNames, outputGeometryPrecision, outputGeometryPrecisionUnits, and directionsTimeAttributeName.

If you don't set travelMode, the service honors the default or user-defined values for the parameters that would otherwise be overridden, so you can create your own travel mode.

startTime

Specify whether the route should be calculated using traffic conditions. To use traffic in the analysis, set impedanceAttributeName to TravelTime, and assign a value to startTime. The startTime value represents the time at which travel begins from the input stops.

The time is specified as Unix time (milliseconds since midnight, January 1 1970).

If a start time is not passed in, but impedanceAttributeName is set to TravelTime, the service uses static road speeds based on average historical speeds or posted speed limits. It uses posted speeds in areas where historical traffic information isn't available.

NoteNote:

Traffic is supported only with the driving time impedance or travel mode. It's not supported with trucking.

The service supports two kinds of traffic: typical and live. Typical traffic references travel speeds that are made up of historical averages for each five-minute interval spanning a week. Live traffic retrieves speeds from a traffic feed that processes phone probe records, sensors, and other data sources to record actual travel speeds and predict speeds for the near future.

The Data Coverage page shows the countries Esri currently provides traffic data for.

Typical Traffic:

To ensure the service uses typical traffic in locations where it is available, choose a time and day of the week, and then convert the day of the week to one of the following dates from 1990:

  • Monday—1/1/1990
  • Tuesday—1/2/1990
  • Wednesday—1/3/1990
  • Thursday—1/4/1990
  • Friday—1/5/1990
  • Saturday—1/6/1990
  • Sunday—1/7/1990

Set the time and date as Unix time in milliseconds.

For example, to solve for 1:03 p.m. on Thursdays, set the time and date to 1:03 p.m., 4 January 1990; and convert to milliseconds (631458180000).

NoteNote:

Although the dates representing days of the week are from 1990, typical traffic is calculated from recent traffic trends—usually over the last several months.

Live Traffic:

To use live traffic when and where it is available, choose a time and date and convert to Unix time.

Esri saves live traffic data for 12 hours and references predictive data extending 12 hours into the future. If the time and date you specify for this parameter is outside the 24-hour time window, or the travel time in the analysis continues past the predictive data window, the task falls back to typical traffic speeds.

NoteNote:

  • If the parameter is not specified, the start time isn't assigned. Consequently, the route will always be based on the posted speed limits.
  • When solving a route analysis that spans across multiple time zones and setting a start time, preserveFirstStop must be true.
  • This parameter is ignored when impedanceAttributeName is set to distance units.
  • The time zone for startTime can be UTC or the time zone of the first stop. Specify time zones with the startTimeIsUTC parameter.

Examples:

  • "startTime": 631458180000 // 13:03, 4 January 1990. Typical traffic on Thursdays at 1:03 p.m.
  • "startTime": 631731600000 // 17:00, 7 January 1990. Typical traffic on Sundays at 5:00 p.m.
  • "startTime": 1413964800000 // 8:00, 22 October 2014. If the current time is between 8:00 p.m., 21 Oct. 2014 and 8:00 p.m., 22 Oct. 2014, live traffic speeds are referenced in the analysis; otherwise, typical traffic speeds are referenced.
  • "startTime": 1426674000000 // 10:20, 18 March 2015. If the current time is between 10:20 p.m., 17 Mar. 2015 and 10:20 p.m., 18 Mar. 2015, live traffic speeds are referenced in the analysis; otherwise, typical traffic speeds are referenced.

startTimeIsUTC

Specify the time zone or zones of the startTime parameter. There are two options: false (default) and true.

false (use geographically local time zones):

The startTime value refers to the time zone in which the first stop of each route is located. The start time uses the time zone that is geographically local to the first stop.

Illustration of setting the value to false (geographically local): Setting startTime to 9:00 a.m., 4 January 1990 (631443600000 milliseconds); startTimeIsUTC to false; and submitting a valid request causes the drive times for points in the Eastern Time Zone to start at 9:00 a.m. (2:00 p.m. UTC).

Input: startTime is 9:00 a.m., 4 Jan. 1990 (631443600000 milliseconds), and startTimeIsUTC is et to false

true (use UTC):

The startTime value refers to Coordinated Universal Time (UTC). The start times for all points are simultaneous, regardless of time zones.

Illustration of setting the value to true (UTC): Setting startTime to 9:00 a.m., 4 January 1990 (631443600000 milliseconds) and startTimeIsUTC to true, the start time for points in the Eastern Time Zone is 4:00 a.m. Eastern Time and 3:00 a.m. Central Time for those in the Central Time Zone.

Input: startTime is 9:00 a.m., 4 Jan. 1990 (631443600000 milliseconds), and startTimeIsUTC is set to true

NoteNote:
  • This parameter is ignored when impedanceAttributeName is set to distance units.
  • When solving a route analysis that spans across multiple time zones and setting a start time, preserveFirstStop must be true.

timeWindowsAreUTC

Specify whether the TimeWindowStart and TimeWindowEnd attribute values on stops are specified in UTC or geographically local time. There are two options: false (default) and true.

NoteNote:
  • See startTimeIsUTC for an explanation of UTC vs. local time.
  • The service does not allow the combination of timeWindowsAreUTC=true and startTimeIsUTC=false. An error will be produced if this combination is given.

findBestSequence

Use this parameter to specify if the service should reorder stops to find the optimized route. If the parameter value is false, the service returns a route that visits stops in the order you define. If the parameter value is true, the service finds the best order to visit the stops. The service will account for a variety of variables so that the total travel distance or travel time for the route is minimized. You can elect to preserve the origin and/or the destination stops while allowing the service to reorder intermediary stops by setting preserveFirstStop and preserveLastStop parameters. The default value for this parameter is false.

CautionCaution:

A true parameter value causes the service to switch from solving a shortest-path problem to a traveling salesperson problem (TSP). Solving a TSP is computer-intensive operation and incurs additional service credits per route.

preserveFirstStop

Use this parameter to indicate whether the service should keep the first stop fixed when reordering the stops. The possible parameter values are true, or false. The default value is true. This parameter is applicable only if findBestSequence parameter value is true.

preserveLastStop

Use this parameter to indicate whether the service should keep the last stop fixed when reordering the stops. The possible parameter values are true, or false. The default value is true. This parameter is applicable only if findBestSequence parameter value is true.

useTimeWindows

Use this parameter to indicate if the service should consider time windows specified on the stops when finding the best route. The possible parameter values are true, or false. The time windows are specified on stops using the TimeWindowStart and TimeWindowEnd attributes.

restrictUTurns

Use this parameter to restrict or permit the route from making U-turns at junctions.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

In order to understand the available parameter values, consider for a moment that a junction is a point where only two streets intersect each other. If three or more streets intersect at a point, it is called as an intersection. A cul-de-sac is a dead-end. The parameter can have the following values:

Parameter Value

Description

esriNFSBAllowBacktrack (default)

U-turns are permitted everywhere. Allowing U-turns implies that the vehicle can turn around at a junction and double back on the same street.

U-turns are allowed
U-turns are permitted at junctions with any number of adjacent streets.

esriNFSBAtDeadEndsAndIntersections

U-turns are prohibited at junctions where exactly two adjacent streets meet.

U-turns allowed only at intersections and dead-ends
U-turns are permitted only at intersections or dead ends.

esriNFSBAtDeadEndsOnly

U-turns are prohibited at all junctions and interesections and are permitted only at dead ends.

U-turns allowed only at dead-ends
U-turns are permitted only at dead ends.

esriNFSBNoBacktrack

U-turns are prohibited at all junctions, intersections, and dead-ends. Note that even when this parameter value is chosen, a route can still make U-turns at stops. If you wish to prohibit U-turns at a stop, you can set its CurbApproach property to the appropriate value (3).

useHierarchy

Specify whether hierarchy should be used when finding the shortest paths.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

  • true (default)—Use hierarchy when measuring between points. When hierarchy is used, the tool prefers higher-order streets (such as freeways) to lower-order streets (such as local roads), and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes to faraway locations, because drivers on long-distance trips tend to prefer traveling on freeways where stops, intersections, and turns can be avoided. Using hierarchy is computationally faster, especially for long-distance routes, since the tool can determine the best route from a relatively smaller subset of streets.

  • false—Do not use hierarchy when measuring between stops. If hierarchy is not used, the tool considers all the streets and doesn't prefer higher-order streets when finding the route. This is often used when finding short-distance routes within a city.

CautionCaution:

The service automatically reverts to using hierarchy if the straight-line distance between the stops is greater than 50 miles (80.46 kilometers), even if you have specified to find the route without using hierarchy.

impedanceAttributeName

Specify the impedance.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

Impedance is a value that quantifies travel along the transportation network. Travel distance is an example of impedance; it quantifies the length of walkways and road segments. Similarly, drive time—the typical time it takes to drive a car along a road segment—is an example of impedance. Drive times may vary by type of vehicle—for instance, the time it takes for a truck to travel along a path tends to be longer than a car—so there can be many impedance values representing travel times for different vehicle types. Impedance values may also vary with time; live and historical traffic reference dynamic impedance values. Each walkway and road segment stores at least one impedance value. When performing a network analysis, the impedance values are used to calculate the best results, such as finding the shortest route—the route that minimizes impedance—between two points.

The impedance parameter can be specified using the following values:

  • TravelTime (default)—Models travel times for a car. These travel times can be dynamic, fluctuating according to traffic flows, in areas where traffic data is available.
  • TruckTravelTime—Models travel times for a truck. These travel times are static for each road and don't fluctuate with traffic.
  • WalkTime—Models travel times for a pedestrian. The default walking speed is 5 kilometers per hour (3.1 miles per hour), but you can change that speed through the attributeParameterValues parameter by setting Walking Speed (km/h) to a different value.
  • Miles—Specifies that the travel distance between the stops should be minimized. The total distance between the stops is calculated in miles.
  • Kilometers—Specifies that the travel distance between the stops should be minimized. The total distance between the stops is calculated in kilometers.

accumulateAttributeNames

Use this parameter to specify whether the service should accumulate values other than the value specified for impedanceAttributeName. For example, if your impedanceAttributeName is set to TravelTime, the total travel time for the route will be calculated by the service. However, if you also want to calculate the total distance of the route in miles, you can specify Miles as the value for the accumulateAttributeNames parameter.

The parameter value should be specified as a comma-separated list of names. The parameter values are the same as the impedanceAttributeName parameter. For example, accumulateAttributeNames=Miles,Kilometers indicates that the total cost of the route should also be calculated in miles and kilometers. This is also the default value for this parameter.

NoteNote:

The values specified for the accumulateAttributeNames parameter are purely for reference. The service always uses impedanceAttributeName to find the best routes.

restrictionAttributeNames

Use this parameter to specify which restrictions should be honored by the service. A restriction represents a driving preference or requirement. In most cases, restrictions cause roads or pathways to be prohibited, but they can also cause them to be avoided or preferred. For instance, using an Avoid Toll Roads restriction will result in a route that will include toll roads only when it is absolutely required to travel on toll roads in order to visit a stop. Height Restriction makes it possible to route around any clearances that are lower than the height of your vehicle. If you are carrying corrosive materials on your vehicle, using the Any Hazmat Prohibited restriction prevents hauling the materials along roads where it is marked as illegal to do so.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value is specified as a comma-separated list of restriction names. For example, the default value for this parameter is restritionAttributeNames=Avoid Carpool Roads, Avoid Express Lanes, Avoid Gates, Avoid Private Roads, Avoid Unpaved Roads, Driving an Automobile, Roads Under Construction Prohibited, Through Traffic Prohibited. A value of none indicates that no restrictions should be used when finding shortest paths.

The service supports the restriction names listed in the following table:

NoteNote:

Some restrictions are supported only in certain countries as indicated by the Availability column in the table. A restriction is supported in a country if the Logistics Attribute column has a value of Yes in the list of supported countries. If you specify restriction names that are not available in the country where your input points are located, the service ignores the invalid restrictions and returns warning messages indicating the names for the restrictions that were not considered when making measurements.

NoteNote:

Sometimes you need to specify an additional value, the restriction attribute parameter, on a restriction to get the intended results. This value needs to be associated with the restriction name and a restriction parameter using attributeParameterValues.

Restriction Name

Description

Availability

Any Hazmat Prohibited

The route will not include roads where transporting any kind of hazardous material is prohibited.

Select countries in North America and Europe

Avoid Carpool Roads

The route will avoid roads that are designated exclusively for carpool (high-occupancy) vehicles.

All countries

Avoid Express Lanes

The route will avoid roads designated as express lanes.

All countries

Avoid Ferries

The route will avoid ferries.

All countries

Avoid Gates

The route will avoid roads where there are gates such as keyed access or guard controlled entryways.

All countries

Avoid Limited Access Roads

The route will avoid roads that are limited access highways.

All countries

Avoid Private Roads

The route will avoid roads that are not publicly owned and maintained.

All countries

Avoid Toll Roads

The route will avoid toll roads.

All countries

Avoid Truck Restricted Roads

The route will avoid roads where trucks are not allowed except when making deliveries.

All countries

Avoid Unpaved Roads

The route will avoid roads that are not paved (for example, dirt, gravel, etc.).

All countries

Axle Count Restriction

The route will not include roads where trucks with the specified number of axles are prohibited. The number of axles can be specified using the Number of Axles restriction parameter.

Select countries in North America and Europe

Driving a Bus

The route will not include roads where buses are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Driving a Delivery Vehicle

The route will not include roads where delivery vehicle are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Driving a Taxi

The route will not include roads where taxis are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Driving a Truck

The route will not include roads where trucks are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Driving an Automobile

The route will not include roads where automobiles are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Driving an Emergency Vehicle

The route will not include roads where emergency vehicles are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Height Restriction

The route will not include roads where the vehicle height exceeds the maximum allowed height for the road. The vehicle height can be specified using the Vehicle Height (meters) restriction parameter.

Select countries in North America and Europe

Kingpin to Rear Axle Length Restriction

The route will not include roads where the vehicle length exceeds the maximum allowed kingpin to rear axle for all trucks on the road. The length between the vehicle kingpin and the rear axle can be specified using the Vehicle Kingpin to Rear Axle Length (meters) restriction parameter.

Select countries in North America and Europe

Length Restriction

The route will not include roads where the vehicle length exceeds the maximum allowed length for the road. The vehicle length can be specified using the Vehicle Length (meters) restriction parameter.

Select countries in North America and Europe

Preferred for Pedestrians

The route prefers paths designated for pedestrians.

All countries

Riding a Motorcycle

The route will not include roads where motorcycles are prohibited. Using this restriction will also ensure that the route will honor one-way streets.

All countries

Roads Under Construction Prohibited

The route will not include roads that are under construction.

All countries

Semi or Tractor with One or More Trailers Prohibited

The route will not include roads where semis or tractors with one or more trailers are prohibited.

Select countries in North America and Europe

Single Axle Vehicles Prohibited

The route will not include roads where vehicles with single axles are prohibited.

Select countries in North America and Europe

Tandem Axle Vehicles Prohibited

The route will not include roads where vehicles with tandem axles are prohibited.

Select countries in North America and Europe

Through Traffic Prohibited

The route will not include roads where through traffic (non-local) is prohibited.

All countries

Truck with Trailers Restriction

The route will not include roads where trucks with the specified number of trailers on the truck are prohibited. The number of trailers on the truck can be specified using the Number of Trailers on Truck restriction parameter.

Select countries in North America and Europe

Use Preferred Hazmat Routes

The route will prefer roads that are designated for transporting any kind of hazardous materials.

Select countries in North America and Europe

Use Preferred Truck Routes

The route will prefer roads that are designated as trucks routes such as the roads that are part of the national network as specified by the National Surface Transportation Assistance Act in the United States, or roads that are designated as truck routes by the state or province, or roads that are preferred by the trucks when driving in an area.

Select countries in North America and Europe

Walking

The route will not include roads where pedestrians are prohibited.

All countries

Weight Restriction

The route will not include roads where the vehicle weight exceeds the maximum allowed weight for the road. The vehicle weight can be specified using the Vehicle Weight (kilograms) restriction parameter.

Select countries in North America and Europe

Weight per Axle Restriction

The route will not include roads where the vehicle weight per axle exceeds the maximum allowed weight per axle for the road. The vehicle weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

Select countries in North America and Europe

Width Restriction

The route will not include roads where the vehicle width exceeds the maximum allowed width for the road. The vehicle width can be specified using the Vehicle Width(meters) restriction parameter.

Select countries in North America and Europe

LegacyLegacy:

Driving a Delivery Vehicle restriction attribute is deprecated and will be unavailable in future releases. To achieve similar results, use Driving a Truck restriction attribute along with Avoid Truck Restricted Roads restriction attribute.

Example: restrictionAttributeNames=Driving an Emergency Vehicle,Height Restriction,Length Restriction

attributeParameterValues

Use this parameter to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. If the restriction is meant to avoid or prefer roads, you can further specify the degree to which they are avoided or preferred using this parameter.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value is specified as an array of objects each having the following properties:

  • attributeName— The name of the restriction

  • parameterName—The name of the parameter associated with the restriction. A restriction can have one or more parameterName properties.

  • value—The value for parameterName.

Most attribute parameters are related to the restriction attributes in restrictionAttributeNames. Each restriction has at least one attribute parameter named Restriction Usage, which specifies whether the restriction prohibits, avoids, or prefers travel on the roads associated with the restriction and the degree to which the roads are avoided or preferred. The Restriction Usage parameter can be assigned any of the following string values, or their equivalent numeric values listed within the parentheses:

  • Prohibited (-1)—Travel on the roads that have the restriction is completely prohibited.
  • Avoid_High (5)—It is very unlikely for the service to include in the route the roads that are associated with the restriction.
  • Avoid_Medium (2)—It is unlikely for the service to include in the route the roads that are associated with the restriction.
  • Avoid_Low (1.3)—It is somewhat unlikely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_Low (0.8)—It is somewhat likely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_Medium(0.5)—It is likely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_High (0.2)—It is very likely for the service to include in the route the roads that are associated with the restriction.

NoteNote:

The restrictionAttributeNames parameter is associated with attributeParameterValues. The restriction attribute's parameter value is specified as part of attributeParameterValues. Each restriction has at least one parameter named Restriction Usage, which specifies whether travel on roads that have the restriction is prohibitied, should be avoided, or should be preferred. For the latter two options, it also specifies the degree to which the roads are avoided or preferred.

In most cases, you can use the default value, Prohibit, for the Restriction Usage if the restriction is dependent on a physical vehicle-characteristic such as vehicle height. However, in some cases, the value for Restriction Usage depends on your routing preferences. For example, the Avoid Toll Roads restriction has the default value of Avoid_Medium for the Restriction Usage parameter. This means that when the restriction is used, the service will try to route around toll roads when it can. Avoid_Medium also indicates how important it is to avoid toll roads when finding the best route; it has a medium priority. Choosing Avoid_Low would put lower importance on avoiding tolls; choosing Avoid_High instead would give it a higher importance and thus make it more acceptable for the service to generate longer routes to avoid tolls. Choosing Prohibited would entirely disallow travel on toll roads, making it impossible for a route to travel on any portion of a toll road. Keep in mind that avoiding or prohibiting toll roads, and thus avoiding toll payments, is the objective for some; in contrast, others prefer to drive on toll roads because avoiding traffic is more valuable to them than the money spent on tolls. In the latter case, you would choose Prefer_Low, Prefer_Medium, or Prefer_High as the value for Restriction Usage. The higher the preference, the farther the service will go out of its way to travel on the roads associated with the restriction.

The following table lists the attribute parameter names and the default parameter values.

TipTip:

If you wish to use the default value for a restriction parameter, the restriction name, restriction parameter name, and restriction parameter value do not have to be specified as part of the attributeParameterValues.

Restriction Name

Restriction Parameter Name

Restriction Parameter Default Value

Any Hazmat Prohibited

Restriction Usage

Prohibited

Avoid Carpool Roads

Restriction Usage

Avoid_High

Avoid Express Lanes

Restriction Usage

Avoid_High

Avoid Ferries

Restriction Usage

Avoid_Medium

Avoid Gates

Restriction Usage

Avoid_Medium

Avoid Limited Access Roads

Restriction Usage

Avoid_Medium

Avoid Private Roads

Restriction Usage

Avoid_Medium

Avoid Toll Roads

Restriction Usage

Avoid_Medium

Avoid Truck Restricted Roads

Restriction Usage

Avoid High

Axle Count Restriction

Number of Axles

0

Restriction Usage

Prohibited

Driving a Bus

Restriction Usage

Prohibited

Driving a Delivery Vehicle

Restriction Usage

Prohibited

Driving a Taxi

Restriction Usage

Prohibited

Driving a Truck

Restriction Usage

Prohibited

Driving an Automobile

Restriction Usage

Prohibited

Driving an Emergency Vehicle

Restriction Usage

Prohibited

Height Restriction

Restriction Usage

Prohibited

Vehicle Height (meters)

0

Kingpin to Rear Axle Length Restriction

Restriction Usage

Prohibited

Vehicle Kingpin to Rear Axle Length (meters)

0

Length Restriction

Restriction Usage

Prohibited

Vehicle Length (meters)

0

Riding a Motorcycle

Restriction Usage

Prohibited

Roads Under Construction Prohibited

Restriction Usage

Prohibited

Semi or Tractor with One or More Trailers Prohibited

Restriction Usage

Prohibited

Single Axle Vehicles Prohibited

Restriction Usage

Prohibited

Tandem Axle Vehicles Prohibited

Restriction Usage

Prohibited

Through Traffic Prohibited

Restriction Usage

Avoid_High

Truck with Trailers Restriction

Restriction Usage

Prohibited

Number of Trailers on Truck

0

Use Preferred Hazmat Routes

Restriction Usage

Prefer_Medium

Use Preferred Truck Routes

Restriction Usage

Prefer_Medium

Walking

Restriction Usage

Prohibited

WalkTime

Walking Speed (km/h)

5

Weight Restriction

Restriction Usage

Prohibited

Vehicle Weight (kilograms)

0

Weight per Axle Restriction

Restriction Usage

Prohibited

Vehicle Weight per Axle (kilograms)

0

Width Restriction

Restriction Usage

Prohibited

Vehicle Width (meters)

0

Syntax for specifying attributeParameterValues
[
    {
        "attributeName": "<attribute1>",
        "parameterName": "<parameter1>",
        "value": "<value1>"
    },
    {
        "attributeName": "<attribute2>",
        "parameterName": "<parameter2>",
        "value": "<value2>"
    }
]
Example: Specifying the vehicle height and weight and a high preference to use designated truck routes

This example shows how to specify the height and weight of the vehicle for use with the height and weight restrictions respectively along with a high preference to include the designated truck routes. This results in a route that does not include any roads where the clearance under overpasses or through tunnels is less than the vehicle height. The route will also not include any roads with load limited bridges or local roads that prohibit heavy vehicles if the vehicle weight exceeds the maximum permissible weight. However, the route will include as many roads as possible that are designated as preferred truck routes.

Note that the Restriction Usage parameter for the Height Restriction and the Weight Restriction are not specified as we want to use the default value of Prohibit for these restriction parameters.

attributeParameterValues=
[
    {
        "attributeName": "Height Restriction",
        "parameterName": "Vehicle Height (meters)",
        "value": 4.12
    },
    {
        "attributeName": "Weight Restriction",
        "parameterName": "Vehicle Weight (kilograms)",
        "value": 36287
    },
    {
        "attributeName": "Use Preferred Truck Routes",
        "parameterName": "Restriction Usage",
        "value": "Prefer_High"
    }
]

barriers

Use this parameter to specify one or more points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. For example, a point barrier can be used to represent a fallen tree along a street or time delay spent at a railroad crossing.

CautionCaution:

The service imposes a maximum limit of 250 point barriers. If the value is exceeded, the response returns an error message.

The barriers parameter can be specified using a simple comma- and semicolon-based syntax if you need to specify only point barrier geometries as longitude and latitude values in the default spatial reference (WGS84).

Simple syntax for barriers
barriers=x1,y1; x2, y2; ...; xn, yn
Example using simple syntax
barriers=-117.1957,34.0564; -117.184,34.0546

You can specify barrier geometries as well as attributes using a more comprehensive JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features: Specify an array of features. This property is optional. However, either the features or the url property must be specified.
  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However either the features or the url property must be specified.

Each feature in this array represents a point barrier and contains the following fields:

  • geometry: Specifies the barrier geometry as a point containing x and y properties along with a spatialReference property. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for barriers

When specifying the barriers parameter using JSON structure, you can specify additional information about barriers, such as the barrier type, using attributes. The barriers parameter can be specified with the following attributes:

  • Name: The name of the barrier.
  • BarrierType: Specifies whether the point barrier restricts travel completely or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers.
    • 0 - Prohibits traversing through the barrier. The barrier is referred to as restriction point barrier since it acts as a restriction. This is the default value.
      Two maps demonstrate how a restriction point barrier affects a route analysis.
      The map on the left shows the shortest path between two stops without any restriction point barriers. The map on the right has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.
    • 2 - Traveling through the barrier increases the travel time or distance by the amount specified as the value for Attr_TravelTime, Attr_Miles, or Attr_Kilometers attributes. This barrier type is referred to as an added cost point barrier.
      Two maps demonstrate how added cost barriers affect a route analysis.
      The map on the left shows the shortest path between two stops without any added cost point barrier. For the map on the right, the travel time from stop one to stop two would be the same whether going around the north end of the block or the south end; however, since crossing railroad tracks incurs a time penalty (modeled with added cost point barriers), the route with only one railroad crossing is chosen. The cost of crossing the barrier is added to the accumulated travel time of the resulting route.
      NoteNote:

      There is no point barrier type with a value of 1 for the BarrierType attribute.

  • FullEdge: This attribute is applicable only for restriction point barriers. The value for this attribute is specified as one of the following integers.
    • 0 - Permits travel on the edge up to the barrier, but not through it. This is the default value.
    • 1 - Restricts travel anywhere on the underlying street.
  • Attr_TravelTime: Indicates how much travel time in minutes is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero.
  • Attr_Miles: Indicates how much distance in miles is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero.
  • Attr_Kilometers: Indicates how much distance in kilometers is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero.

Syntax for specifying barriers using JSON structure for features
{
    "features": [
        {
            "geometry": {
                "x": <x>,
                "y": <y>,
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "x": <x>,
                "y": <y>,
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying barriers using URL to a JSON response
{
    "url": "<url>"
}
Example 1: Specifying added cost point barrier using JSON structure.

This example shows how to use an added cost point barrier to model a 5 minute delay at a rail road crossing. The BarrierType attribute is used to specify that the point barrier is of type added cost and the Attr_TravelTime attribute is used to specify the delay in minutes. The barrier geometry is in the default spatial reference, WGS84, and hence the spatialReference property is not required within the geometry property.

{
    "features": [
        {
            "geometry": {
                "x": 37.541479,
                "y": -122.053461
            },
            "attributes": {
                "Name": "Haley St rail road crossing",
                "BarrrierType": 2,
                "Attr_TravelTime": 5
            }
        }
    ]
}
Example 2: Specifying restriction point barrier using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/0/query?where=1%3D1&returnGeometry=true&f=json"
}

polylineBarriers

Use this parameter to specify one or more lines that prohibit travel anywhere the lines intersect the streets. For example, a parade or protest that blocks traffic across several street segments can be modeled with a line barrier. A line barrier can also quickly fence off several roads from being traversed, thereby channeling possible routes away from undesirable parts of the street network.

Two maps demonstrate how a line barrier affects finding a route between two stops.
The map on the left displays the shortest path between two stops. The map on the right shows the shortest path when several streets are blocked by a polyline barrier.

CautionCaution:

The service imposes a limit on the number of streets you can restrict using polylineBarriers parameter. While there is no limit on number of lines you can specify as polyline barriers, the combined number of streets intersected by all the lines should not exceed 500. If the value is exceeded, the response returns an error message.

You can specify polyline barrier geometries as well as attributes using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features: Specify an array of features. This property is optional. However, either the features or the url property must be specified.
  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However either the features or the url property must be specified.

Each feature in this array represents a polyline barrier and contains the following fields:

  • geometry: Specifies the barrier geometry. The structure is based on ArcGIS REST polyline object. A polyline contains an array of paths and a spatialReference. Each path is represented as an array of points, and each point in the path is represented as an array of numbers containing X and Y coordinate values at index 0 and 1 respectively. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for polylineBarriers

When specifying the polylineBarriers parameter using JSON structure, the parameter can be specified with the following attributes:

  • Name: The name of the polyline barrier.

Syntax for specifying polyline barriers using JSON structure for features
{
    "features": [
        {
            "geometry": {
                "paths": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>
                }
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "paths": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>
                }
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ]
}
Syntax for specifying polyline barriers using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying polyline barriers using JSON structure.

The example shows how to add two lines as polyline barriers to restrict travel on the streets intersected by the lines. Barrier 1 is a single-part line feature made up of two points. Barrier 2 is a two-part line feature. The first part is made up of three points, and the second part is made up of two points. The barrier geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence, the spatialReference property is required within the geometry property.

{
    "features": [
        {
            "geometry": {
                "paths": [
                    [
                        [
                            -10804823.397,
                            3873688.372
                        ],
                        [
                            -10804811.152,
                            3873025.945
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": 102100
                }
            },
            "attributes": {
                "Name": "Barrier 1"
            }
        },
        {
            "geometry": {
                "paths": [
                    [
                        [
                            -10804823.397,
                            3873688.372
                        ],
                        [
                            -10804807.813,
                            3873290.911
                        ],
                        [
                            -10804811.152,
                            3873025.945
                        ]
                    ],
                    [
                        [
                            -10805032.678,
                            3863358.76
                        ],
                        [
                            -10805001.508,
                            3862829.281
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": 102100
                }
            },
            "attributes": {
                "Name": "Barrier 2"
            }
        }
    ]
}
Example 2: Specifying polyline barrier using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

polygonBarriers

Use this parameter to specify polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

CautionCaution:

The service imposes a limit on the number of streets you can restrict using the polygonBarriers parameter. While there is no limit on number of polygons you can specify as the polygon barriers, the combined number of streets intersected by all the polygons should not exceed 2,000. If the value is exceeded, the response returns an error message.

You can specify polygon barrier geometries as well as attributes using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features: Specify an array of features. This property is optional. However, either the features or the url property must be specified.
  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or the url property must be specified.

Each feature in this array represents a polygon barrier and contains the following fields:

  • geometry: Specifies the barrier geometry. The structure is based on ArcGIS REST polygon object. A polygon contains an array of rings and a spatialReference. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers containing X and Y coordinate values at index 0 and 1 respectively. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for polygonBarriers

When specifying the polygonBarriers parameter using JSON structure, you can specify additional information about barriers, such as the barrier type, using attributes. The polygonBarriers parameter can be specified with the following attributes:

  • Name: The name of the barrier.
  • BarrierType: Specifies whether the barrier restricts travel completely or scales the time or distance for traveling through it. The value for this attribute is specified as one of the following integers:
    • 0 - Prohibits traveling through any part of the barrier. The barrier is referred to as restriction polygon barrier since it prohibits traveling on streets intersected by the barrier. One use of this type of barrier is to model floods covering areas of the street that make traveling on those streets impossible. This is the default value.
      Two maps demonstrate how a restriction polygon barrier affects finding a route between two stops.
      The left side depicts the shortest path between two stops. On the right, a polygon barrier blocks flooded streets, so the shortest path between the same two stops is different.
    • 1 - Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_TravelTime, Attr_Miles, or Attr_Kilometers attributes. If the streets are partially covered by the barrier, the travel time or distance is apportioned and then scaled. For example, a factor 0.25 would mean that travel on underlying streets is expected to be four times faster than normal. A factor of 3.0 would mean it is expected to take three times longer than normal to travel on underlying streets. This barrier type is referred to as scaled cost polygon barrier. It might be used to model storms that reduce travel speeds in specific regions.
      Two maps demonstrate how a scaled cost polygon barrier affects finding a route between two stops.
      The map on the left shows a route that goes through inclement weather without regard for the effect poor road conditions have on travel time. On the right, a scaled polygon barrier doubles the travel time of the roads covered by the storm. Notice the route still passes through the southern tip of the storm since it is quicker to spend more time driving slowly through a small part of the storm rather than driving completely around it. The service uses the modified travel time in calculating the best route; furthermore, the modified travel time is reported as the total travel time in the response.
  • Attr_TravelTime: This is the factor by which the travel time of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify this attribute if the impedanceAttributeName request parameter has the value TravelTime. The attribute value must be greater than zero.
  • Attr_Miles: This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify a value for this attribute if the impedanceAttributeName request parameter has the value Miles. The attribute value must be greater than zero.
  • Attr_Kilometers: This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify a value for this attribute if the impedanceAttributeName request parameter has the value Kilometers. The attribute value must be greater than zero.

Syntax for specifying polygon barriers using JSON structure for features
{
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ],
                "spatialReference": {
                    "wkid": <wkid>,
                    "latestWkid": <wkid>,
                    
                }
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ]
}
Syntax for specifying polygon barriers using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying polygon barriers using JSON structure.

The example shows how to add two polygons as barriers. The first polygon named Flood zone is a restriction polygon barrier that prohibits travel on the underlying streets. The polygon is a single-part polygon feature made up of four points. The second polygon named Severe weather zone is a scaled-cost polygon barrier that reduces the travel time on underlying streets to one third of the original value. The polygon is a two-part polygon feature. Both parts are made up of four points.

The barrier geometries are in the default spatial reference, WGS84. Hence, the spatialReference property is not required within geometry property.

{
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0634,
                            32.8442
                        ],
                        [
                            -97.0554,
                            32.84
                        ],
                        [
                            -97.0558,
                            32.8327
                        ],
                        [
                            -97.0638,
                            32.83
                        ],
                        [
                            -97.0634,
                            32.8442
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Flood zone",
                "BarrierType": 0
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0803,
                            32.8235
                        ],
                        [
                            -97.0776,
                            32.8277
                        ],
                        [
                            -97.074,
                            32.8254
                        ],
                        [
                            -97.0767,
                            32.8227
                        ],
                        [
                            -97.0803,
                            32.8235
                        ]
                    ],
                    [
                        [
                            -97.0871,
                            32.8311
                        ],
                        [
                            -97.0831,
                            32.8292
                        ],
                        [
                            -97.0853,
                            32.8259
                        ],
                        [
                            -97.0892,
                            32.8279
                        ],
                        [
                            -97.0871,
                            32.8311
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Severe weather zone",
                "BarrierType": 1,
                "Attr_TravelTime": 3
            }
        }
    ]
}
Example 2: Specifying polygon barrier using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

returnDirections

Specify whether the service should generate driving directions for each route.

The default value is true.

  • true—Generate directions. The directions are configued based on the values for the directionsLanguage, directionsOutputType, directionsStyleName, and directionsLengthUnits parameters. The directions are available in the directions property of the JSON response.

  • false—Don't generate directions.

directionsLanguage

Specify the language that should be used when generating driving directions. This parameter applies only when the returnDirections parameter is set to true. The service supports generating directions in the following languages:

  • ar - Generate directions in Arabic
  • cs - Generate directions in Czech
  • de - Generate directions in German
  • el - Generate directions in Greek
  • en (default) - Generate directions in English
  • es - Generate directions in Spanish
  • et - Generate directions in Estonian
  • fr - Generate directions in French
  • he - Generate directions in Hebrew
  • it - Generate directions in Italian
  • ja - Generate directions in Japanese
  • ko - Generate directions in Korean
  • lt - Generate directions in Lithuanian
  • lv - Generate directions in Latvian
  • nl - Generate directions in Dutch
  • pl - Generate directions in Polish
  • pt-BR - Generate directions in Brazilian Portuguese
  • pt-PT - Generate directions in Portuguese (Portugal)
  • ru - Generate directions in Russian
  • sv - Generate directions in Swedish
  • tr - Generate directions in Turkish
  • zh-CN - Simplified Chinese

The value for the parameter is specified using the language code. For example, directionsLanguage=zh-CN will result in driving directions to be generated in simplified Chinese.

NoteNote:

If an unsupported language code is specified, the service returns the directions using the default language, English.

directionsOutputType

Define the content and verbosity of the driving directions. This parameter applies only when the returnDirections parameter is set to true. The parameter can be specified using the following values:

  • esriDOTComplete—Directions output that includes all directions properties.
  • esriDOTCompleteNoEvents—Directions output that includes all directions properties except events.
  • esriDOTInstructionsOnly—Directions output that includes text instructions, time, length and ETA. Does not include geometry.
  • esriDOTStandard (default)—Standard directions output direction text instructions, geometry, time, length, ETA. Does not include events, new types of strings (street names, signposts info), Maneuver type, Bearings and Turn angle.
  • esriDOTSummaryOnly—Directions output that contains only summary (time and length). Detailed text instructions and geometry are not provided.

directionsStyleName

Specify the name of the formatting style for the directions. This parameter applies only when the returnDirections parameter is set to true. The parameter can be specified using the following values:

  • NA Desktop (default)—Generates turn-by-turn directions suitable for printing.
  • NA Navigation—Generates turn-by-turn directions designed for an in-vehicle navigation device.

directionsLengthUnits

Specify the units for displaying travel distance in the driving directions. This parameter applies only when the returnDirections parameter is set to true. The parameter can be specified using one of the values:

  • esriNAUCentimeters
  • esriNAUDecimalDegrees
  • esriNAUDecimeters
  • esriNAUFeet
  • esriNAUInches
  • esriNAUKilometers
  • esriNAUMeters
  • esriNAUMiles (default)
  • esriNAUMillimeters
  • esriNAUNauticalMiles
  • esriNAUPoints
  • esriNAUYards

returnRoutes

Use this parameter to specify if the service should return routes.

The default value is true.

  • true—Routes are generated. The routes are available in the routes property of the JSON response. The shape of the routes depends on the value for the outputLines parameter.
  • false—Routes are not generated.

TipTip:

You may not want to return routes if your application has to display only the driving directions between the stops. It is sufficient in this case to set the returnDirections parameter to true; returning routes will not provide any additional information and will increase the overall response size.

directionsTimeAttributeName

Set the time-based impedance attribute to display the duration of a maneuver, such as "Go northwest on Alvorado St. for 5 minutes." The units for all the time attributes is minutes.

  • TravelTime (default)—Travel times for a car
  • TruckTravelTime—Travel times for a truck
  • WalkTime—Travel times for a pedestrian

outputLines

Use this parameter to specify the type of route features that are output by the service. This parameter is applicable only if the returnCFRoutes parameter is set to true. The outputLines parameter can have one of the following values:

  • esriNAOutputLineTrueShape—Return the exact shape of the resulting route that is based on the underlying streets. This is the default value.

  • esriNAOutputLineTrueShapeWithMeasure—Return the exact shape of the resulting route that is based on the underlying streets and include route measurements that keep track of the cumulative travel time or travel distance along the route relative to the first stop. When this value is chosen for the outputLines parameter, each point that make up the route shape will include an M value along with X and Y values. The M value, also known as the measure value, indicates the accumulated travel time or travel distance at that point along the route. The M values can be used to determine how far you have traveled from the start of the route or the remaining distance or time left to reach the destination. The M values store travel time if the impedanceAttributeName is set to TravelTime and store the travel distance if the impedanceAttributeName is set to Kilometers or Miles.

  • esriNAOutputLineStraight—Return a straight line between the incident and the closest facility.

  • esriNAOutputLineNone—Do not return any shapes for the routes. This value can be useful in cases where you are only interested in determing the total travel time or travel distance of the route. For example, if your application has already calculated the route and after some time your application needs to only calculate the expected time of arrival (ETA) to the destination, you can set the returnRoutes parameter to true and the outputLines parameter to esriNAOutputLineNone. The routes property of the JSON response will only contain the total travel time that can be used to determine the ETA. Since the route shape is not returned when using the esriNAOutputLineNone value, the response size will be considerably smaller.

TipTip:

When the outputLines parameter is set to esriNAOutputLineTrueShape or esriNAOutputLineTrueShapeWith Measure, the generalization of the route shape can be further controlled using the appropriate values for the outputGeometryPrecision and the outputGeometryPrecisionUnits parameters.

NoteNote:

No matter which value you choose for the outputLines parameter, the best route is always determined by minimizing the travel time or the travel distance, never using the Euclidean distance (or as the crow flies distance) between the stops. This means that only the route shapes are different, not the underlying streets that are searched when finding the route.

returnStops

Use this parameter to specify if stops will be returned by the service. The possible values for this parameter are true, or false. A true value indicates that the stops used as input will be returned as part of the stops property in the JSON response. The default value for this parameter is false.

When finding optimized routes, the returnStops property can be set to true to determine the optimal sequence in which the route visits a particular stop by checking the Sequence property in the JSON response. If you have specified the stops parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning stops can allow you to draw the stop locations in your application. You may also want to set the returnStops property to true in order to determine if the stops were successfully located on the street network or had some other errors by checking the Status property in the JSON response.

returnBarriers

Specify whether barriers will be returned by the service.

  • true—The input point barriers are returned as part of the barriers property in the JSON response.
  • false (default)—Point barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the barriers parameter.

If you have specified the barriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning barriers can allow you to draw the point barrier locations in your application. You may also want to set the returnBarriers property to true to see where the barriers were located on the street network or, if they weren't located at all, understand what the problem was by checking the Status property in the JSON response.

returnPolylineBarriers

Specify whether polyline barriers will be returned by the service.

  • true—The input polyline barriers are returned as part of the polylineBarriers property in the JSON response.
  • false (default)—Polyline barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polylineBarriers parameter.

If you have specified the polylineBarriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, the returnPolylineBarriers parameter can be set to true so that you can draw the polyline barrier locations in your application.

returnPolygonBarriers

Specify whether polygon barriers will be returned by the service.

  • true—The input polygon barriers are returned as part of the polygonBarriers property in the JSON response.
  • false (default)—Polygon barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polygonBarriers parameter.

If you have specified the polygonBarriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, the returnPolygonBarriers parameter can be set to true so that you can draw the polygon barrier locations in your application.

ignoreInvalidLocations

Specify whether invalid input locations should be ignored when finding the best solution. An input point is deemed invalid by the service if there are no streets within 12.42 miles (20 kilometers) of the stop location.

  • true (default)—Any invalid point in your request will cause the service to return a failure.
  • false—Invalid point are ignored.

outSR

Use this parameter to specify the spatial reference of the geometries, such as line or point features, returned by the service.

The parameter value can be specified as a well-known ID (WKID) for the spatial reference. If env:outSR is not specified, the geometries are returned in the default spatial reference, WGS84. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.

Many of the basemaps provided by ArcGIS Online are in the Web Mercator spatial reference (WKID 102100). Specifying env:outSR=102100 returns the geometries in the Web Mercator spatial reference, which can be drawn on top of the basemaps.

outputGeometryPrecision

Use this parameter to specify by how much you want to simplify the route geometry returned by the service.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The simplification distance you specify is the maximum allowable offset that the simplified line can deviate from the original line. Simplifying a line reduces the number of vertices that are part of the route geometry. This reduces the overall response size and also improves the performance for drawing the route shapes in the applications.

The default value for this parameter is 10. The units are specified with the outputGeometryPrecisionUnits parameter.

outputGeometryPrecisionUnits

Use this parameter to specify the units for the value specified for the outputGeometryPrecision parameter.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value should be specified as one of the following values:

  • esriCentimeters
  • esriDecimalDegrees
  • esriDecimeters
  • esriFeet
  • esriInches
  • esriKilometers
  • esriMeters (default)
  • esriMiles
  • esriMillimeters
  • esriNauticalMiles
  • esriPoints
  • esriYards

overrides

Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

The value for this parameter needs to be specified in JavaScript Object Notation (JSON). The values can be either a number, Boolean, or a string.

{
"overrideSetting1" : "value1", 
"overrideSetting2" : "value2"
}

The default value for this parameter is no value, which indicates not to override any solver settings.

Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting Esri Technical Support.

JSON response

The JSON response from the route service is based on the following syntax. The actual properties returned in the response depend upon the request parameters. For example, the stops property is returned only if the returnStops parameter is set to true. If a request fails, the JSON response only contains the error property. The examples in the subsequent section illustrate the response returned with specific request parameters.

JSON response syntax for successful request
{
    "directions": [
        {
            "routeId": <routeId>,
            "routeName": "<routeName>",
            "summary": {
                "totalLength": <totalLength>,
                "totalTime": <totalTime>,
                "totalDriveTime": <totalDriveTime>,
                "envelope": {
                    <envelope>
                }
            },
            "hasZ": <true|false>,
            "hasM": <true|false>,
            "features": [
                {
                    "attributes": {
                        "length": <length1>,
                        "time": <time1>,
                        "text": "<text1>",
                        "ETA": <ETA>,
                        "maneuverType": "<maneuverType1>"
                    },
                    "compressedGeometry": "<compressedGeometry1>"
                },
                {
                    "attributes": {
                        "length": <length2>,
                        "time": <time2>,
                        "text": "<text2>",
                        "maneuverType": "<maneuverType2>"
                    },
                    "compressedGeometry": "<compressedGeometry2>"
                }
            ]
        }
    ],
    "routes": {
        "spatialReference": {
            <spatialReference>
        },
        "hasZ": <true|false>,
        "hasM": <true|false>,
        "features": [
            {
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                },
                "geometry": {
                    <polyline1>
                }
            },
            {
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                },
                "geometry": {
                    <polyline2>
                }
            }
        ]
    },
    "stops": {
        "spatialReference": {
            <spatialReference>
        },
        "hasZ": <true|false>,
        "features": [
            {
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                },
                "geometry": {
                    <point1>
                }
            },
            {
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                },
                "geometry": {
                    <point2>
                }
            }
        ]
    },
    "barriers": {
        "spatialReference": {
            <spatialReference>
        },
        "hasZ": <true|false>,
        "features": [
            {
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                },
                "geometry": {
                    <point1>
                }
            },
            {
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                },
                "geometry": {
                    <point2>
                }
            }
        ]
    },
    "messages": [
        {
            "type": <type1>,
            "description": "<description1>"
        },
        {
            "type": <type2>,
            "description": "<description2>"
        }
    ]
}
JSON response syntax for failed request.
{
    "error": {
        "code": <code>,
        "message": "<message>",
        "details": [
            "<details>"
        ]
    }
}

Usage limits

The table below lists the limits that apply to this service.

Limit Description

Limit Value

Maximum number of stops:

150

Maximum number of (point) barriers:

250

Maximum number of street features intersected by polyline barriers:

500

Maximum number of street features intersected by polygon barriers:

2,000

Maximum straight-line distance for the walking travel mode:

(If the straight-line distance between any two stops is greater than the limit shown here, the analysis will fail when travelMode is set to Walking Time or Walking Distance or when impedanceAttributeName is set to WalkTime)

50 miles (80.46 kilometers)

Force hierarchy beyond a straight-line distance of:

(If the straight-line distance between any two stops is greater than the limit shown here, the analysis uses hierarchy, even if useHierarchy is set to false.)

50 miles (80.46 kilometers)

Maximum snap tolerance:

(If the distance between an input point and its nearest traversable street is greater than the distance specified here, the point is excluded from the analysis.)

12.42 miles (20 kilometers)

Maximum time a client can use this route service:

5 minutes (300 seconds)

Examples

NoteNote:

If you copy and paste the request URL from the examples into a web browser, you will get an invalid token error message. You need to replace <yourToken> with a valid token. See Accessing services provided by Esri to see how to generate one.

Finding the best route and driving directions between two locations

In order to find the best route between two stops, you can pass their locations, such as the longitude and latitude values, as the value for the stops parameter to the solve operation on the service. The solve operation will use default values for all other parameters and return a best route between the two stops.

Request URL

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?token=<yourToken>&stops=-122.4079,37.78356;-122.404,37.782&f=json

JSON Response

{
    "directions": [
        {
            "routeId": 1,
            "routeName": "Location 1 - Location 2",
            "summary": {
                "totalLength": 0.547181119992593,
                "totalTime": 0.916666666666667,
                "totalDriveTime": 0.932502535171807,
                "envelope": {
                    "xmin": -122.408067,
                    "ymin": 37.7820000000001,
                    "xmax": -122.402715,
                    "ymax": 37.785718,
                    "spatialReference": {
                        "wkid": 4326
                    }
                }
            },
            "features": [
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Start at Location 1",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTDepart"
                    },
                    "compressedGeometry": "+1m91-6fki2+202vh+0+0"
                },
                {
                    "attributes": {
                        "length": 0.0250344870524692,
                        "time": 0.0426480025053024,
                        "text": "Go northwest on 5Th St toward Market St/Cyril Magnin St",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTStraight"
                    },
                    "compressedGeometry": "+1m91-6fki2+202vh-h+f"
                },
                {
                    "attributes": {
                        "length": 0.168514039307211,
                        "time": 0.287470433861017,
                        "text": "Turn right on Market St",
                        "ETA": -2209161597441,
                        "maneuverType": "esriDMTTurnRight"
                    },
                    "compressedGeometry": "+1m91-6fkij+20300+3p+2v"
                },
                {
                    "attributes": {
                        "length": 0.24456036107712,
                        "time": 0.415655565448105,
                        "text": "Bear right on 4th St",
                        "ETA": -2209161580193,
                        "maneuverType": "esriDMTBearRight"
                    },
                    "compressedGeometry": "+1m91-6fkeq+2032v+7-1+7-4+2q-2b+28-1o"
                },
                {
                    "attributes": {
                        "length": 0.109072232555793,
                        "time": 0.186728533357382,
                        "text": "Turn right on Howard St",
                        "ETA": -2209161555254,
                        "maneuverType": "esriDMTTurnRight"
                    },
                    "compressedGeometry": "+1m91-6fk9a+202un-2e-1u"
                },
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Finish at Location 2, on the left",
                        "ETA": -2209161544050,
                        "maneuverType": "esriDMTStop"
                    },
                    "compressedGeometry": "+1m91-6fkbo+202sp+0+0"
                }
            ]
        }
    ],
    "routes": {
        "spatialReference": {
            "wkid": 4326
        },
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Location 1 - Location 2",
                    "FirstStopID": 1,
                    "LastStopID": 2,
                    "StopCount": 2,
                    "Total_Time": 0.932502535171807,
                    "TotalWait_Time": 0,
                    "TotalViolation_Time": 0,
                    "StartTime": -2209161600000,
                    "EndTime": -2209161544050,
                    "Shape_Length": 0.00900541548002667
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.407752312,
                                37.7837382120001
                            ],
                            [
                                -122.408067,
                                37.7839990000001
                            ],
                            [
                                -122.407574,
                                37.784392
                            ],
                            [
                                -122.407333,
                                37.7845800000001
                            ],
                            [
                                -122.406309,
                                37.785401
                            ],
                            [
                                -122.405982003,
                                37.785652998
                            ],
                            [
                                -122.405982,
                                37.785653
                            ],
                            [
                                -122.405883,
                                37.785718
                            ],
                            [
                                -122.405821,
                                37.7857070000001
                            ],
                            [
                                -122.405764,
                                37.785693
                            ],
                            [
                                -122.405705,
                                37.785668
                            ],
                            [
                                -122.405626,
                                37.7856180000001
                            ],
                            [
                                -122.40523,
                                37.7853030000001
                            ],
                            [
                                -122.405085,
                                37.7851810000001
                            ],
                            [
                                -122.405084995,
                                37.7851809960001
                            ],
                            [
                                -122.405085,
                                37.7851810000001
                            ],
                            [
                                -122.404784,
                                37.7849380000001
                            ],
                            [
                                -122.404271,
                                37.784501
                            ],
                            [
                                -122.404239,
                                37.784477
                            ],
                            [
                                -122.4042,
                                37.7844470000001
                            ],
                            [
                                -122.404006,
                                37.7842830000001
                            ],
                            [
                                -122.403736,
                                37.7840660000001
                            ],
                            [
                                -122.403736,
                                37.7840660000001
                            ],
                            [
                                -122.403736,
                                37.7840660000001
                            ],
                            [
                                -122.403184,
                                37.7836300000001
                            ],
                            [
                                -122.402715,
                                37.783265
                            ],
                            [
                                -122.403146,
                                37.782924
                            ],
                            [
                                -122.404116347,
                                37.7821449080001
                            ]
                        ]
                    ]
                }
            }
        ]
    },
    "messages": []
}

Finding the optimized route and driving directions to visit a set of locations

In some cases, you know the start and end location for your route but wish to visit the intermediate stops in an optimal sequence such that the overall travel time or distance of the route is minimized. Such a route, called an optimized route, can be found by specifying a value of true for the findBestSequence parameter. In this example, since we also want to maintain the sequence of first and last stop, we also need to set a value of true for the preserveFirstStop and preserveLastStop parameters.

In this example, we need to find an optimized route that minimizes travel time. We would like the route to start and end at the same location and visit the intermediate five stops in the sequence that minimizes the overall travel time. We want to specify a name for each of our stops and an approximate time in minutes we expect to spend at each stop. Consequently, instead of using only the longitude and latitude values for the stops parameter, we use the JSON structure for features. The driving directions as well as the total travel time for the route will include the time we expect to spend at each location. The JSON structure for stops specifies the x and y properties for the geometry property as well as the Name and Attr_TravelTime properties for each stop. The returnStops parameter is also set to true to return the optimized sequence of the stops.

Request URL

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?token=<yourToken>&stops={"features":[{"geometry":{"x":-122.473948,"y":37.7436},"attributes":{"Name":"Office","Attr_TravelTime":0}},{"geometry":{"x":-122.439613,"y":37.746144},"attributes":{"Name":"Store 1","Attr_TravelTime":25}},{"geometry":{"x":-122.488254,"y":37.754092},"attributes":{"Name":"Store 2","Attr_TravelTime":20}},{"geometry":{"x":-122.44915,"y":37.731837},"attributes":{"Name":"Store 3","Attr_TravelTime":30}},{"geometry":{"x":-122.46441,"y":37.774756},"attributes":{"Name":"Store 4","Attr_TravelTime":25}},{"geometry":{"x":-122.426896,"y":37.769352},"attributes":{"Name":"Store 5","Attr_TravelTime":20}},{"geometry":{"x":-122.473948,"y":37.7436},"attributes":{"Name":"Office","Attr_TravelTime":0}}]}&findBestSequence=true&preserverFirstStop=true&preserveLastStop=true&returnStops=true&returnDirections=true&returnRoutes=true&f=json

JSON response

The response includes the routes, stops and directions properties because the returnRoutes, returnDirections and returnStops parameters are set to true in the request. For each stop, the Sequence property indicates the optimal position of the stop in the entire route. The totalTime and totalDriveTime in directionssummary are different because the totalTime also accumulates the time spent at each stop. The time spent at the stop is also indicated as the time property in the directions message when the route arrives at the stop.

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "messages": [],
    "routes": {
        "fieldAliases": {
            "ObjectID": "ObjectID",
            "Name": "Name",
            "FirstStopID": "FirstStopID",
            "LastStopID": "LastStopID",
            "StopCount": "StopCount",
            "Total_TravelTime": "Total_TravelTime",
            "Total_Kilometers": "Total_Kilometers",
            "Total_Miles": "Total_Miles",
            "Shape_Length": "Shape_Length"
        },
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
        },
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Office - Office",
                    "FirstStopID": 1,
                    "LastStopID": 7,
                    "StopCount": 7,
                    "Total_TravelTime": 166.7642667101709,
                    "Total_Kilometers": 21.571809695124163,
                    "Total_Miles": 13.404101108976198,
                    "Shape_Length": 0.22159550698709607
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.42682704453244,
                                37.76926852812011
                            ],
                            [
                                -122.42690999979664,
                                37.7691999997802
                            ],
                            [
                                -122.42893999988104,
                                37.76761000020139
                            ],
                            [
                                -122.43101000001144,
                                37.76597999967731
                            ],
....
.... additional points that make up the route
....
                        ]
                    ]
                }
            }
        ]
    },
    "stops": {
        "fieldAliases": {
            "ObjectID": "ObjectID",
            "Name": "Name",
            "RouteName": "RouteName",
            "Sequence": "Sequence",
            "TimeWindowStart": "TimeWindowStart",
            "TimeWindowEnd": "TimeWindowEnd",
            "ArriveCurbApproach": "ArriveCurbApproach",
            "DepartCurbApproach": "DepartCurbApproach",
            "SourceID": "SourceID",
            "SourceOID": "SourceOID",
            "PosAlong": "PosAlong",
            "SideOfEdge": "SideOfEdge",
            "CurbApproach": "CurbApproach",
            "Status": "Status",
            "Attr_Minutes": "Attr_Minutes",
            "Attr_Kilometers": "Attr_Kilometers",
            "Attr_Miles": "Attr_Miles",
            "Attr_TravelTime": "Attr_TravelTime",
            "Cumul_TravelTime": "Cumul_TravelTime",
            "Cumul_Kilometers": "Cumul_Kilometers",
            "Cumul_Miles": "Cumul_Miles"
        },
        "geometryType": "esriGeometryPoint",
        "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
        },
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Office",
                    "RouteName": null,
                    "Sequence": 1,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": null,
                    "DepartCurbApproach": 2,
                    "SourceID": 1,
                    "SourceOID": 6057289,
                    "PosAlong": 0.7479231000293187,
                    "SideOfEdge": 1,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 0,
                    "Cumul_TravelTime": 0,
                    "Cumul_Kilometers": 0,
                    "Cumul_Miles": 0
                },
                "geometry": {
                    "x": -122.47394799980032,
                    "y": 37.74360000004003
                }
            },
            {
                "attributes": {
                    "ObjectID": 2,
                    "Name": "Store 1",
                    "RouteName": null,
                    "Sequence": 5,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 2,
                    "DepartCurbApproach": 1,
                    "SourceID": 1,
                    "SourceOID": 6058993,
                    "PosAlong": 0,
                    "SideOfEdge": 1,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 25,
                    "Cumul_TravelTime": 122.1073557516816,
                    "Cumul_Kilometers": 14.855087613527838,
                    "Cumul_Miles": 9.230523501207848
                },
                "geometry": {
                    "x": -122.43961300013979,
                    "y": 37.74614400044533
                }
            },
            {
                "attributes": {
                    "ObjectID": 3,
                    "Name": "Store 2",
                    "RouteName": null,
                    "Sequence": 2,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 1,
                    "DepartCurbApproach": 1,
                    "SourceID": 1,
                    "SourceOID": 6056930,
                    "PosAlong": 0.3870876537475072,
                    "SideOfEdge": 2,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 20,
                    "Cumul_TravelTime": 25.46532328028302,
                    "Cumul_Kilometers": 2.4554877802810324,
                    "Cumul_Miles": 1.52576936955743
                },
                "geometry": {
                    "x": -122.48825400032183,
                    "y": 37.75409200004583
                }
            },
            {
                "attributes": {
                    "ObjectID": 4,
                    "Name": "Store 3",
                    "RouteName": null,
                    "Sequence": 6,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 2,
                    "DepartCurbApproach": 1,
                    "SourceID": 1,
                    "SourceOID": 6058654,
                    "PosAlong": 0.8931750056079824,
                    "SideOfEdge": 1,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 30,
                    "Cumul_TravelTime": 159.1825995596363,
                    "Cumul_Kilometers": 18.14720876135387,
                    "Cumul_Miles": 11.276152743822255
                },
                "geometry": {
                    "x": -122.44915000017232,
                    "y": 37.731836999877714
                }
            },
            {
                "attributes": {
                    "ObjectID": 5,
                    "Name": "Store 4",
                    "RouteName": null,
                    "Sequence": 3,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 1,
                    "DepartCurbApproach": 2,
                    "SourceID": 1,
                    "SourceOID": 6060672,
                    "PosAlong": 0.9164482334734284,
                    "SideOfEdge": 2,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 25,
                    "Cumul_TravelTime": 58.847849986326096,
                    "Cumul_Kilometers": 6.972770720865237,
                    "Cumul_Miles": 4.332678856021607
                },
                "geometry": {
                    "x": -122.46440999972168,
                    "y": 37.77475599968966
                }
            },
            {
                "attributes": {
                    "ObjectID": 6,
                    "Name": "Store 5",
                    "RouteName": null,
                    "Sequence": 4,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 1,
                    "DepartCurbApproach": 1,
                    "SourceID": 1,
                    "SourceOID": 6060280,
                    "PosAlong": 0.17236409016281176,
                    "SideOfEdge": 1,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 20,
                    "Cumul_TravelTime": 88.95703248414763,
                    "Cumul_Kilometers": 11.590492481272001,
                    "Cumul_Miles": 7.20199813170584
                },
                "geometry": {
                    "x": -122.4268960000503,
                    "y": 37.76935199959513
                }
            },
            {
                "attributes": {
                    "ObjectID": 7,
                    "Name": "Office",
                    "RouteName": null,
                    "Sequence": 7,
                    "TimeWindowStart": null,
                    "TimeWindowEnd": null,
                    "ArriveCurbApproach": 2,
                    "DepartCurbApproach": null,
                    "SourceID": 1,
                    "SourceOID": 6057289,
                    "PosAlong": 0.7479231000293187,
                    "SideOfEdge": 1,
                    "CurbApproach": 0,
                    "Status": 0,
                    "Attr_Minutes": 0,
                    "Attr_Kilometers": 0,
                    "Attr_Miles": 0,
                    "Attr_TravelTime": 0,
                    "Cumul_TravelTime": 166.7642667101709,
                    "Cumul_Kilometers": 21.571809695124163,
                    "Cumul_Miles": 13.404101108976198
                },
                "geometry": {
                    "x": -122.47394799980032,
                    "y": 37.74360000004003
                }
            }
        ]
    },
    "directions": [
        {
            "routeId": 1,
            "routeName": "Office - Office",
            "summary": {
                "totalLength": 21.57180969512416,
                "totalTime": 166.76426670514047,
                "totalDriveTime": 46.76426671017089,
                "envelope": {
                    "xmin": -122.48903999969622,
                    "ymin": 37.730019999723254,
                    "xmax": -122.4248599996892,
                    "ymax": 37.77475599968966,
                    "spatialReference": {
                        "wkid": 4326,
                        "latestWkid": 4326
                    }
                }
            },
            "features": [
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Start at Office",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTDepart"
                    },
                    "compressedGeometry": "+1m91-6fo4e+200pr+0+0"
                },
                {
                    "attributes": {
                        "length": 0.9799885036711242,
                        "time": 2.077699263283507,
                        "text": "Go north on 17TH AVE toward SANTIAGO ST",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTStraight"
                    },
                    "compressedGeometry": "+1m91-6fo4e+200pr-d+5k-l+9m"
                },
                {
                    "attributes": {
                        "length": 1.22776430511923,
                        "time": 2.830765986178278,
                        "text": "Turn left on ORTEGA ST",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTTurnLeft"
                    },
                    "compressedGeometry": "+1m91-6fo5g+20195-7e-a-7e-8-5i-9-3n-5"
                },
                {
                    "attributes": {
                        "length": 0.24773497149067822,
                        "time": 0.5568580308212338,
                        "text": "Turn right on 30TH AVE",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTTurnRight"
                    },
                    "compressedGeometry": "+1m91-6fotl+20185-9+3s"
                },
                {
                    "attributes": {
                        "length": 0,
                        "time": 20,
                        "text": "Arrive at Store 2, on the right",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTStop"
                    },
                    "compressedGeometry": "+1m91-6fotu+201c1+0+0"
                },
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Depart Store 2",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTDepart"
                    },
                    "compressedGeometry": "+1m91-6fotu+201c1+0+0"
                },
....
.... additional direction messages
....
            ]
        }
    ]
}

Finding the best route that avoids an area with flooding

Some areas may be temporarily inaccessible due to flooding or other events. If you want to find a route that avoids these areas, you can pass in the areas as polygonBarriers. The service will determine the streets that intersect the specified area and restrict travel on those streets when finding the best route.

In this example, the stops are specified using their longitude and latitude values. The geometry of the flooded area is in the default spatial reference, WGS84. Hence, the spatialReference property is not required within geometry property. We want to completely avoid travel on any streets that are within the flooded area, we use a restriction polygon barrier to represent the flooded area by specifying the BarrierType as 0. We want to draw the resulting route on a basemap that uses Web Mercator (WKID 102100) spatial reference. So we request the output route geometries in Web Mercator spatial reference by specifying outSR parameter.

Request URL

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?token=<yourToken>&stops=-96.436378,42.499344;-96.364166,42.459969&polygonBarriers={"features":[{"geometry":{"rings":[[[-96.382,42.49],[-96.391,42.471],[-96.414,42.475],[-96.421,42.491],[-96.401,42.505],[-96.382,42.49]]]},"attributes":{"Name":"Flood zone","BarrierType":0}}]}&outSR=102100&directionsOutputType=esriDOTInstructionsOnly&f=json

JSON response

The geometries, such as the route shapes, returned from the service are in Web Mercator spatial reference and not in default WGS84 spatial reference as the outSR parameter was set in the request. Since we have used the esriDOTInstructionsOnly value for the directionsOutputType parameter, the directions property in the response does not contain any values for the compressedGeometry property. Instead, each intermediate directions feature contains the strings property which can be used to display additional information about the streets included in the route such as the cross street from a given street.

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "messages": [],
    "routes": {
        "fieldAliases": {
            "ObjectID": "ObjectID",
            "Name": "Name",
            "FirstStopID": "FirstStopID",
            "LastStopID": "LastStopID",
            "StopCount": "StopCount",
            "Total_TravelTime": "Total_TravelTime",
            "Total_Kilometers": "Total_Kilometers",
            "Total_Miles": "Total_Miles",
            "Shape_Length": "Shape_Length"
        },
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": 102100,
            "latestWkid": 3857
        },
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Location 1 - Location 2",
                    "FirstStopID": 1,
                    "LastStopID": 2,
                    "StopCount": 2,
                    "Total_TravelTime": 17.860030858898373,
                    "Total_Kilometers": 11.422011513266458,
                    "Total_Miles": 7.0973089117469295,
                    "Shape_Length": 15436.978718485752
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -10735247.1458,
                                5236029.971900001
                            ],
                            [
                                -10735158.5467,
                                5236034.876699999
                            ],
....
.... additional points that make up the route
....
                        ]
                    ]
                }
            }
        ]
    },
    "directions": [
        {
            "routeId": 1,
            "routeName": "Location 1 - Location 2",
            "summary": {
                "totalLength": 11.422011513266458,
                "totalTime": 17.860030856681988,
                "totalDriveTime": 17.860030858898373,
                "envelope": {
                    "xmin": "NaN",
                    "ymin": "NaN",
                    "xmax": "NaN",
                    "ymax": "NaN"
                }
            },
            "features": [
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Start at Location 1",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTDepart"
                    },
                    "compressedGeometry": ""
                },
                {
                    "attributes": {
                        "length": 0.06713916712957156,
                        "time": 0.1325782621714933,
                        "text": "Go east on W 3RD ST toward JOHN ST",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTStraight"
                    },
                    "compressedGeometry": "",
                    "strings": [
                        {
                            "string": "W 3RD ST",
                            "stringType": "esriDSTStreetName"
                        },
                        {
                            "string": "JOHN ST",
                            "stringType": "esriDSTCrossStreet"
                        }
                    ]
                },
....
.... additional direction messages
....
                {
                    "attributes": {
                        "length": 0,
                        "time": 0,
                        "text": "Finish at Location 2, on the left",
                        "ETA": -2209161600000,
                        "maneuverType": "esriDMTStop"
                    },
                    "compressedGeometry": ""
                }
            ]
        }
    ]
}

Finding route in countries not covered by the service

If the first stop is in a country not supported by the service, the request fails with an error message.

Request URL

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?token=<yourToken>&stops=116.39722919900055%2C39.90749657700047%3B121.45805638600052%2C31.22221723400048&f=json

JSON response

{
    "error": {
        "code": 400,
        "message": "Unable to complete operation.",
        "details": [
            "The input points are not within the data coverage area."
        ]
    }
}
10/6/2017