POST https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve HTTP/1.1
content-type: application/x-www-form-urlencoded
f=json
&token=<ACCESS_TOKEN>
&stops=-122.68782,45.51238;-122.690176,45.522054;-122.614995,45.526201
&startTime=now
&returnDirections=true
&directionsLanguage=es
The routing service can find routes, directions, and perform advanced analyses on street networks. The service can be used to perform analyses in 247 countries using high quality street data with global coverage.
Key features
- Find a route and turn-by-turn directions for two or more locations.
- Determine the optimal routes and directions for a fleet of vehicles with deliveries.
- Find one or more nearby facilities from incidents based on travel time or distance.
- Find the service area that can be reached by driving or walking from a location in a given time.
- Generate a matrix of travel times or distances between multiple origins and destinations.
- Find a set of facilities that will best serve demand from surrounding areas.
- Access and display live traffic data with traffic speeds and incidents for routes.
- 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.
Tip:
Learn more about the routing service in the Mapping APIs and location services guide.
Access the service
To access the routing service you need the following:
- An ArcGIS Developer account or ArcGIS Online account.
- An access token (API key or OAuth 2.0).
Tip:
To learn how to get an API key or to use OAuth 2.0, see Security and authentication in the Mapping APIs and location services guide.
Example
This example shows how to find a route and directions between a set of stops. It accounts for the current time and returns the route geometry as multi-part line, and the directions in Spanish.
{
"routes": {
"fieldAliases": {
// one or more field aliases
},
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"features": [
{
"attributes": {
"Name": "Location 1 - Location 3",
"Total_TravelTime": 14.758,
"Total_Miles": 5.491,
"Total_Kilometers": 8.837
// more field values
},
"geometry": {
"paths": [
[
[
-122.68838,
45.51262
]
// additional points that make up the path geometry between location 1 and location 2
],
[
[
-122.69019,
45.52206
]
// additional points that make up the path geometry between location 2 and location 3
]
]
}
}
]
},
"directions": [
{
"routeId": 1,
"routeName": "Location 1 - Location 3",
"summary": {
"totalLength": 5.491,
"totalTime": 14.758,
"totalDriveTime": 14.758,
"envelope": {
"xmin": -122.69257,
"ymin": 45.51262,
"xmax": -122.61497,
"ymax": 45.53422,
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
}
}
},
"features": [
{
"attributes": {
"length": 0,
"time": 0,
"text": "Salga desde Location 1",
"ETA": 1607894119000,
"arriveTimeUTC": 1607922919000,
"maneuverType": "esriDMTDepart"
},
"compressedGeometry": "+gm5a9-1vvvvvh+nnn9tf+0+0",
"strings": [
{
"string": "9:15 PM",
"stringType": "esriDSTEstimatedArrivalTime"
},
{
"string": "Location 1",
"stringType": "esriDSTStreetName"
}
]
},
{
"attributes": {
"length": 0.024,
"time": 0.054,
"text": "Vaya hacia el noreste",
"ETA": 1607894119000,
"arriveTimeUTC": 1607922919000,
"maneuverType": "esriDMTStraight"
},
"compressedGeometry": "+gm5a9-1vvvvvh+nnn9tf+8a+j6+1h7+59i",
"strings": [
{
"string": "9:15 PM",
"stringType": "esriDSTEstimatedArrivalTime"
}
]
}
// more direction features
]
}
]
}
To see the live example go to the Mapping APIs and location services guide.
Tip:
Learn how to access the routing service with different ArcGIS and open source APIs in the Mapping APIs and location services guide.