Routing service

The routing service allows you to perform several types of spatial analysis on transportation networks, such as finding the best route across a city, finding the closest emergency vehicle or hospital, identifying a service area around a location, or servicing a set of orders with a fleet of vehicles.

Turn-by-turn directions and a route obtained using the routing service

Key features

  • High quality street data with global coverage
  • Find routes that account for predictive, live, or historical traffic patterns
  • Use travel modes (driving, walking, and trucks)
  • Define additional restrictions when finding routes such as avoiding toll roads or using preferred truck routes
  • Add dynamic barriers that can either restrict or slow down travel
  • Generate driving or walking directions in many languages

How the routing service works

The routing service performs a number of operations. To learn more about the service URL, parameters, and responses for each operation, visit the links below.

  • Routing: get a route and turn-by-turn directions between two or more locations.
  • Fleet routing: get optimal routes for a number of vehicles between a number of locations.
  • Closest facility routing: find one or more nearby facilities from incidents based on travel time or distance.
  • Service areas: get the area that can be reached by driving or walking from a location in a given time.

    You can also calculate the area based on travel to a location, and can consider distance traveled rather than time taken.

  • Travel cost matrix: get a matrix of travel times or distances between multiple origins and destinations.
  • Location-allocation: find a set of facilities that will best serve demand from surrounding areas.

How to use the routing service

You can use the routing service by either making a Direct request or a Job request to the service endpoint. Both Direct and Job request types support all of the capabilities of the service, however, Direct is better suited for shorter requests, and Job is better suited for longer, more complex requests. The request type you choose depends on the complexity of the problem you are trying solve and limits of the request.

Examples

The example below shows how to use the routing service. Other service types can be accessed using a similar pattern.

Direct requestJob request

A Direct request type allows you to make a request and get back all the results in the response.

cURLHTTP
       
1
2
3
4
5
6
7
curl https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve? \
-d "f=json"
-d "token=<ACCESS_TOKEN>"
-d "stops=-122.68782,45.51238;-122.690176,45.522054;-122.614995,45.526201"
-d "startTime=now"
-d "returnDirections=true"
-d "directionsLanguage=es"

When working with a Job request type, you need to follow a three step workflow:

  1. Make the submitJob request with the appropriate request parameters to get a job id.
  2. Using the job id, check the job status to see if the job completed successfully.
  3. Use the job id to get one or more results.

Submit Job

cURLHTTP
       
1
2
3
4
5
6
7
curl https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/submitJob? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "stops={'features':[{'geometry':{'x':-118.268579,'y':34.052291},'attributes':{'Name':'Los Angeles, CA','RouteName':'Route A'}},{'geometry':{'x':-74.009023,'y':40.709975},'attributes':{'Name':'New York, NY','RouteName':'Route A'}},{'geometry':{'x':-87.648549,'y':41.758688},'attributes':{'Name':'Chicago, IL','RouteName':'Route B'}},{'geometry':{'x':-122.320028,'y':47.591046},'attributes':{'Name':'Seattle, WA','RouteName':'Route B'}},{'geometry':{'x':-71.057477,'y':42.359483},'attributes':{'Name':'Boston, MA','RouteName':'Route C'}},{'geometry':{'x':-95.368848,'y':29.759222},'attributes':{'Name':'Houston, TX','RouteName':'Route C'}},{'geometry':{'x':-80.220762,'y':25.761156},'attributes':{'Name':'Miami, FL','RouteName':'Route D'}},{'geometry':{'x':-122.651334,'y':45.51567},'attributes':{'Name':'Portland, OR','RouteName':'Route D'}},{'geometry':{'x':-112.074247,'y':33.446554},'attributes':{'Name':'Phoenix, AZ','RouteName':'Route E'}},{'geometry':{'x':-75.161557,'y':39.952057},'attributes':{'Name':'Philadelphia, PA','RouteName':'Route E'}}]}" \
-d "travel_mode={'attributeParameterValues':[{'attributeName':'Use Preferred Truck Routes','parameterName':'Restriction Usage','value':'PREFER_HIGH'},{'attributeName':'Avoid Unpaved Roads','parameterName':'Restriction Usage','value':'AVOID_HIGH'},{'attributeName':'Avoid Private Roads','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Driving a Truck','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Roads Under Construction Prohibited','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Gates','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Avoid Express Lanes','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Carpool Roads','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Avoid Truck Restricted Roads','parameterName':'Restriction Usage','value':'AVOID_HIGH'},{'attributeName':'TruckTravelTime','parameterName':'Vehicle Maximum Speed (km/h)','value':0}],'description':'Models basic truck travel by preferring designated truck routes, and finds solutions that optimize travel time. Routes must obey one-way roads, avoid illegal turns, and so on. When you specify a start time, dynamic travel speeds based on traffic are used where it is available, up to the legal truck speed limit.','distanceAttributeName':'Kilometers','id':'ZzzRtYcPLjXFBKwr','impedanceAttributeName':'TruckTravelTime','name':'Trucking Time','restrictionAttributeNames':['Avoid Carpool Roads','Avoid Express Lanes','Avoid Gates','Avoid Private Roads','Avoid Truck Restricted Roads','Avoid Unpaved Roads','Driving a Truck','Roads Under Construction Prohibited','Use Preferred Truck Routes'],'simplificationTolerance':10,'simplificationToleranceUnits':'esriMeters','timeAttributeName':'TruckTravelTime','type':'TRUCK','useHierarchy':true,'uturnAtJunctions':'esriNFSBNoBacktrack'}" \
-d "populate_directions=false" \
-d "route_shape=None" \

Get job status

cURLHTTP
   
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/jobs/j2b41de060e5d42d082b888d3be029253? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"

Get results

cURLHTTP
   
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/jobs/j2b41de060e5d42d082b888d3be029253/results/Output_Routes? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"

Authentication

To make authenticated requests you need to use one of the following:

  • API key: A permanent token that grants your application access to ready-to-use services and, with an ArcGIS Developer account, private content (currently in beta).
  • ArcGIS Identity (formerly named user): Grants a short-lived token, generated via OAuth 2.0, giving your application permission to access the content and services authorized to an existing ArcGIS user's account.

Learn more about getting access tokens in Security and authentication.

API support

RoutingFleet routingClosest facility routingService areasLocation-allocationTravel cost matrix
ArcGIS API for JavaScriptFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for AndroidFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for iOSFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for JavaFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for .NETFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS Runtime API for QtFully supportedAccess with geoprocessing taskFully supportedFully supportedAccess with geoprocessing taskAccess with geoprocessing task
ArcGIS API for PythonFully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Esri LeafletAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
MapBox GL JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
OpenLayersAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JSAccess via ArcGIS REST JS
ArcGIS REST JSFully supportedFully supportedFully supportedFully supportedFully supportedFully supported
Full supportPartial support (see notes)Not supported

Service data

The routing service uses industry-leading reference street data that is frequently updated. The main sources for data is HERE. Additional sources may be used for different countries.

The accuracy and quality of routing will vary by geographic region. Street data may include not only major interstates, highways, and roads, but also local and rural roads. This map shows the street data coverage for the world. Click on a country to determine the quality of data available in a geographic region.


Coverage typeColorDescriptionService functionality
Predictive TrafficHistorical, live, and predictive traffic informationCan take into account changing traffic conditions based on current, future, and past observations
Live TrafficHistorical and live traffic informationCan take into account changing traffic conditions based on current and past observations
Historical TrafficHistorical traffic informationCan take into account changing traffic conditions, but travel speeds are only based on past observations
Posted Speed LimitsStatic travel times derived from historical average speeds for automobilesCan not take into accout the time of day
LimitedMajor roads, but no secondary or local roadsTravel times are static and derived from speed limits
MinimalSome major roads, but no secondary or local roadsNot recommended for critical operations

See the complete list of street data coverage by country or visit the Streets data coverage web map.

Tutorials

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.