Overview

You will learn: how to get directions and calculate an optimal route between two or more places using the ArcGIS World Directions Service.

The ArcGIS World Directions Service is a network analyst service that can find routes, get driving directions, calculate drive times, and solve complicated multi-vehicle routing problems. If you would like to create an application that can find driving directions and create an optimized route, you can use the ArcGIS REST API and the solve operation. All you need to do is pass in the "stop" locations, and the service will return a route with directions. Once you have the results you can add the route to a map, display the turn-by-turn directions, or integrate them further into your application. To learn more about the capabilities of the directions and routing service, please visit the documentation.

In this lab you will use the ArcGIS REST API to access the ArcGIS World Directions Service to get directions and calculate an optimized route.

Before you begin

Install Postman to execute HTTP requests. Go to this lab if you need an access token.

Steps

Create a request to access the directions service

  1. Open Postman and click [+] in the tab bar to create a new request.

  2. In the new tab, set the following:

    • HTTP Method: POST
    • Request URL: https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve

Add parameters to define the route stops

  1. Click on Body and add the following Key/Value pairs:

    • f: json
    • token: Go to this lab if you need an access token.
    • stops:
      {
        "type":"features",
        "features":  [
            {
            "geometry": {
              "x": -118.243529,
              "y": 34.053879,
              "spatialReference": {
                "wkid": "4326"
              }
            },
            "attributes": {
              "Name": "Los Angeles City Hall"
            }
          },
          {
            "geometry": {
              "x": -118.273939,
              "y": 34.123480,
              "spatialReference": {
                "wkid": "4326"
              }
            },
            "attributes": {
              "Name": "Griffith Park"
            }
          }
        ]
      }
      

Execute the request to get directions

  1. Click Send to run the request.

  2. In the response window, change the view to JSON and it should look something like this:

    {
      "messages": [],
      "checksum": "qORaANHgWwA.",
      "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": "Los Angeles City Hall - Griffith Park",
                      "FirstStopID": 1,
                      "LastStopID": 2,
                      "StopCount": 2,
                      "Total_TravelTime": 14.453931795068019,
                      "Total_Kilometers": 12.232961986161575,
                      "Total_Miles": 7.601210173935204,
                      "Shape_Length": 0.12021891937783059
                  },
                  "geometry": {
                      "paths": [
                          [
                              [
                                  -118.24354935899999,
                                  34.053897939000024
                              ],
                              [
                                  -118.24377999999996,
                                  34.053650000000061
                              ],
                              [
                                  -118.24387999999999,
                                  34.05355000000003
                              ],
                              [
                                  -118.24412999999998,
                                  34.053290000000061
                              ],
                              [
                                  -118.24446999999998,
                                  34.052940000000035
                              ],
                              [
                                  -118.24508999999995,
                                  34.053340000000048
                              ],
                              [
                                  -118.24554999999998,
                                  34.05364000000003
                              ],
                              [
                                  -118.24518999999998,
                                  34.054030000000068
                              ],
                              [
                                  -118.24488999999994,
                                  34.054340000000025
                              ],
                              [
                                  -118.24411999999995,
                                  34.055180000000064
                              ],
                              [
                                  -118.24358999999998,
                                  34.055760000000078
                              ],
                              [
                                  -118.24298999999996,
                                  34.056370000000072
                              ],
                              [
                                  -118.24258999999995,
                                  34.05678000000006
                              ],
                              [
                                  -118.24251999999996,
                                  34.056850000000054
                              ],
                              [
                                  -118.24234999999999,
                                  34.057030000000054
                              ],
                              [
                                  -118.24225999999999,
                                  34.057130000000029
                              ],
                              [
                                  -118.24187999999998,
                                  34.057480000000055
                              ],
                              [
                                  -118.24137999999999,
                                  34.05776000000003
                              ],
                              [
                                  -118.24123999999995,
                                  34.057450000000074
                              ],
                              [
                                  -118.24132999999995,
                                  34.057220000000029
                              ],
                              [
                                  -118.24162999999999,
                                  34.057090000000073
                              ],
                              [
                                  -118.24202999999994,
                                  34.057170000000042
                              ],
                              [
                                  -118.24227999999999,
                                  34.057260000000042
                              ],
                              [
                                  -118.24307999999996,
                                  34.057640000000049
                              ],
                              [
                                  -118.24423999999999,
                                  34.05827000000005
                              ],
                              [
                                  -118.24434999999994,
                                  34.058350000000075
                              ],
                              [
                                  -118.24447999999995,
                                  34.05845000000005
                              ],
                              [
                                  -118.24519999999995,
                                  34.05914000000007
                              ],
                              [
                                  -118.24532999999997,
                                  34.059260000000052
                              ],
                              [
                                  -118.24544999999995,
                                  34.059380000000033
                              ],
                              [
                                  -118.24641999999994,
                                  34.060410000000047
                              ],
                              [
                                  -118.24709999999999,
                                  34.061210000000074
                              ],
                              [
                                  -118.24740999999995,
                                  34.061600000000055
                              ],
                              [
                                  -118.24772999999999,
                                  34.062080000000037
                              ],
                              [
                                  -118.24790999999999,
                                  34.062410000000057
                              ],
                              [
                                  -118.24786999999998,
                                  34.062870000000032
                              ],
                              [
                                  -118.24761999999998,
                                  34.063260000000071
                              ],
                              [
                                  -118.24745999999999,
                                  34.063470000000052
                              ],
                              [
                                  -118.24737999999996,
                                  34.063560000000052
                              ],
                              [
                                  -118.24725999999998,
                                  34.063690000000065
                              ],
                              [
                                  -118.24690999999996,
                                  34.064020000000028
                              ],
                              [
                                  -118.24640999999997,
                                  34.064330000000041
                              ],
                              [
                                  -118.24556999999999,
                                  34.064690000000041
                              ],
                              [
                                  -118.24487999999997,
                                  34.064850000000035
                              ],
                              [
                                  -118.24421999999998,
                                  34.065000000000055
                              ],
                              [
                                  -118.24330999999995,
                                  34.065260000000023
                              ],
                              [
                                  -118.24261999999999,
                                  34.065570000000037
                              ],
                              [
                                  -118.24236999999999,
                                  34.065700000000049
                              ],
                              [
                                  -118.24219999999997,
                                  34.065780000000075
                              ],
                              [
                                  -118.24170999999996,
                                  34.066030000000069
                              ],
                              [
                                  -118.24129999999997,
                                  34.06624000000005
                              ],
                              [
                                  -118.24102999999997,
                                  34.066380000000038
                              ],
                              [
                                  -118.24012999999997,
                                  34.066820000000064
                              ],
                              [
                                  -118.23923999999994,
                                  34.067270000000065
                              ],
                              [
                                  -118.23707999999999,
                                  34.068460000000073
                              ],
                              [
                                  -118.23684999999995,
                                  34.068590000000029
                              ],
                              [
                                  -118.23651999999998,
                                  34.068800000000067
                              ],
                              [
                                  -118.23596999999995,
                                  34.069200000000023
                              ],
                              [
                                  -118.23576999999995,
                                  34.069410000000062
                              ],
                              [
                                  -118.23523999999998,
                                  34.070530000000076
                              ],
                              [
                                  -118.23507999999998,
                                  34.071210000000065
                              ],
                              [
                                  -118.23475999999999,
                                  34.072080000000028
                              ],
                              [
                                  -118.23461999999995,
                                  34.07236000000006
                              ],
                              [
                                  -118.23405999999994,
                                  34.073060000000055
                              ],
                              [
                                  -118.23241999999999,
                                  34.07472000000007
                              ],
                              [
                                  -118.23137999999994,
                                  34.075720000000047
                              ],
                              [
                                  -118.23086999999998,
                                  34.076170000000047
                              ],
                              [
                                  -118.23036999999999,
                                  34.076610000000073
                              ],
                              [
                                  -118.22969999999998,
                                  34.077160000000049
                              ],
                              [
                                  -118.22939999999994,
                                  34.077410000000043
                              ],
                              [
                                  -118.22884999999997,
                                  34.077860000000044
                              ],
                              [
                                  -118.22852999999998,
                                  34.078140000000076
                              ],
                              [
                                  -118.22751999999997,
                                  34.078930000000071
                              ],
                              [
                                  -118.22726999999998,
                                  34.079210000000046
                              ],
                              [
                                  -118.22714999999999,
                                  34.079500000000053
                              ],
                              [
                                  -118.22737999999998,
                                  34.080280000000073
                              ],
                              [
                                  -118.22802999999999,
                                  34.081390000000056
                              ],
                              [
                                  -118.22817999999995,
                                  34.082210000000032
                              ],
                              [
                                  -118.22831999999994,
                                  34.083030000000065
                              ],
                              [
                                  -118.22835999999995,
                                  34.08322000000004
                              ],
                              [
                                  -118.22843999999998,
                                  34.083480000000066
                              ],
                              [
                                  -118.22911999999997,
                                  34.084190000000035
                              ],
                              [
                                  -118.23206999999996,
                                  34.086110000000076
                              ],
                              [
                                  -118.23274999999995,
                                  34.086510000000033
                              ],
                              [
                                  -118.23423999999994,
                                  34.087280000000078
                              ],
                              [
                                  -118.23580999999996,
                                  34.088230000000067
                              ],
                              [
                                  -118.23634999999996,
                                  34.08856000000003
                              ],
                              [
                                  -118.23679999999996,
                                  34.088880000000074
                              ],
                              [
                                  -118.23717999999997,
                                  34.089140000000043
                              ],
                              [
                                  -118.23852999999997,
                                  34.090250000000026
                              ],
                              [
                                  -118.23938999999996,
                                  34.09110000000004
                              ],
                              [
                                  -118.24138999999997,
                                  34.093150000000037
                              ],
                              [
                                  -118.24173999999999,
                                  34.093500000000063
                              ],
                              [
                                  -118.24376999999998,
                                  34.095580000000041
                              ],
                              [
                                  -118.24532999999997,
                                  34.097200000000043
                              ],
                              [
                                  -118.24638999999996,
                                  34.098300000000052
                              ],
                              [
                                  -118.24725999999998,
                                  34.099200000000053
                              ],
                              [
                                  -118.24749999999995,
                                  34.099550000000079
                              ],
                              [
                                  -118.24836999999997,
                                  34.100870000000043
                              ],
                              [
                                  -118.24977999999999,
                                  34.102540000000033
                              ],
                              [
                                  -118.25054999999998,
                                  34.103150000000028
                              ],
                              [
                                  -118.25421999999998,
                                  34.105780000000038
                              ],
                              [
                                  -118.25482999999997,
                                  34.106190000000026
                              ],
                              [
                                  -118.25524999999999,
                                  34.106470000000058
                              ],
                              [
                                  -118.25563999999997,
                                  34.106730000000027
                              ],
                              [
                                  -118.26028999999994,
                                  34.109070000000031
                              ],
                              [
                                  -118.26265999999998,
                                  34.110340000000065
                              ],
                              [
                                  -118.26299999999998,
                                  34.110550000000046
                              ],
                              [
                                  -118.26547999999997,
                                  34.112220000000036
                              ],
                              [
                                  -118.26565999999997,
                                  34.112340000000074
                              ],
                              [
                                  -118.26582999999999,
                                  34.112460000000056
                              ],
                              [
                                  -118.26621999999998,
                                  34.112730000000056
                              ],
                              [
                                  -118.26627999999999,
                                  34.112770000000069
                              ],
                              [
                                  -118.26737999999995,
                                  34.113810000000058
                              ],
                              [
                                  -118.26826999999997,
                                  34.115330000000029
                              ],
                              [
                                  -118.26840999999996,
                                  34.115590000000054
                              ],
                              [
                                  -118.26850999999999,
                                  34.115780000000029
                              ],
                              [
                                  -118.26862999999997,
                                  34.116020000000049
                              ],
                              [
                                  -118.27021999999999,
                                  34.11901000000006
                              ],
                              [
                                  -118.27105999999998,
                                  34.120580000000075
                              ],
                              [
                                  -118.27140999999995,
                                  34.12128000000007
                              ],
                              [
                                  -118.27203999999995,
                                  34.123620000000074
                              ],
                              [
                                  -118.27250999999995,
                                  34.124260000000049
                              ],
                              [
                                  -118.27284999999995,
                                  34.124450000000024
                              ],
                              [
                                  -118.27313999999996,
                                  34.124570000000062
                              ],
                              [
                                  -118.27384999999998,
                                  34.124830000000031
                              ],
                              [
                                  -118.27413999999999,
                                  34.124940000000038
                              ],
                              [
                                  -118.27426999999994,
                                  34.124950000000069
                              ],
                              [
                                  -118.27425999999997,
                                  34.12489000000005
                              ],
                              [
                                  -118.27414999999996,
                                  34.124080000000049
                              ],
                              [
                                  -118.27429999999998,
                                  34.123360000000048
                              ],
                              [
                                  -118.27471999999995,
                                  34.122160000000065
                              ],
                              [
                                  -118.27465999999998,
                                  34.121570000000077
                              ],
                              [
                                  -118.27459999999996,
                                  34.121270000000038
                              ],
                              [
                                  -118.27421999999996,
                                  34.121150000000057
                              ],
                              [
                                  -118.27399999999994,
                                  34.121340000000032
                              ],
                              [
                                  -118.27420999999998,
                                  34.122590000000059
                              ],
                              [
                                  -118.27396999999996,
                                  34.123390000000029
                              ],
                              [
                                  -118.27396999999996,
                                  34.123480000000029
                              ]
                          ]
                      ]
                  }
              }
          ]
      },
      "directions": [
          {
              "routeId": 1,
              "routeName": "Los Angeles City Hall - Griffith Park",
              "summary": {
                  "totalLength": 7.6012762989328326,
                  "totalTime": 14.45393179776147,
                  "totalDriveTime": 14.453931795068019,
                  "envelope": {
                      "xmin": -118.27471999999995,
                      "ymin": 34.052940000000035,
                      "xmax": -118.22714999999999,
                      "ymax": 34.124950000000069,
                      "spatialReference": {
                          "wkid": 4326,
                          "latestWkid": 4326
                      }
                  }
              },
              "features": [
                  {
                      "attributes": {
                          "length": 0,
                          "time": 0,
                          "text": "Start at Los Angeles City Hall",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTDepart"
                      },
                      "compressedGeometry": "+ha7ro-1vvvvsc+idq7d5+0+0"
                  },
                  {
                      "attributes": {
                          "length": 0.084738703987784866,
                          "time": 0.39199901900695389,
                          "text": "Go southwest on N Spring St",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTStraight"
                      },
                      "compressedGeometry": "+ha7nb-1vvvfjb+idq2n3-42t-4cn-1oo-1oo-4ds-4ji-60v-66k"
                  },
                  {
                      "attributes": {
                          "length": 0.078600101717991935,
                          "time": 0.41284665332331044,
                          "text": "Turn right on W 1st St",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTTurnRight"
                      },
                      "compressedGeometry": "+ha7i5-1vvvcof+idpc6p-avs+731-852+5a8"
                  },
                  {
                      "attributes": {
                          "length": 0.37317368439661219,
                          "time": 1.5895460000000001,
                          "text": "Turn right on N Broadway",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTTurnRight"
                      },
                      "compressedGeometry": "+ha7i5-1vvvvtd+idpok2+6ca+6tb+5a9+5fu+dl0+esn+9cp+a96+akh+aq6+730+78m+17o+17n+30f+365+1j3+1op+6nl+66k+8ro+4ut"
                  },
                  {
                      "attributes": {
                          "length": 0.2505430250426256,
                          "time": 0.60938347338503485,
                          "text": "Turn right onto ramp and go on US-101 N / Pasadena Fwy toward Hollywood Fwy / Harbor Fwy",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTTurnRight"
                      },
                      "compressedGeometry": "+ha7na-1vvu90e+ids75u+2fe-5fu-1j2-42h-5a9-29p-730+1dc-4dt+1j3-e61+6nl-kib+b5i-1ue+1dd-29p+1oo"
                  },
                  {
                      "attributes": {
                          "length": 0.084893114035033301,
                          "time": 0.20611500000000024,
                          "text": "At exit 3 take ramp on the right to I-110 S / Pasadena toward San Pedro (CA-110 N)",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTRampRight"
                      },
                      "compressedGeometry": "+ha7il-1vvvep8+idseeu-cok+c7k-29p+243-244+243"
                  },
                  {
                      "attributes": {
                          "length": 0.19003290617213364,
                          "time": 0.36505899999999986,
                          "text": "At fork keep left on I-10 / CA-110 / Pasadena toward San Pedro",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTForkLeft"
                      },
                      "compressedGeometry": "+ha798-1vvut7h+idskuc-h6g+i8i-c1t+e61-5fu+6tb"
                  },
                  {
                      "attributes": {
                          "length": 1.7636628858769026,
                          "time": 3.1222716304675484,
                          "text": "At fork keep right on CA-110 toward Pasadena",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTForkRight"
                      },
                      "compressedGeometry": "+ha76r-1vvvn3b+idtpob-5lk+8gd-365+5r9+mn+852+4ds+6tb+2qq+3n6+1dd+1j2+243+29p+66k+5r9+8rp+5fu+esn+6ca+c7j+2qq+bmi+2l4+g4e+4ji+c7j+5fu+4dt+29o+30f+1dd+8m3+4dt+78m+3n5+4p7+2ff+fup+7pn+fp3+7vc+169s+l3b+42h+29p+5r9+3n6+9o4+730+3hg+3n6+9cq+jrk+2qp+c1u+5lk+fdo+2fe+4ut+9tq+cd8+t2o+te3+ie7+hnh+91e+7vd+8rp+7pm+bs8+9o5+5a8+4ds+9o4+7vc+5lk+4uu+ht6+e0b"
                  },
                  {
                      "attributes": {
                          "length": 0.33227177320996937,
                          "time": 0.70792499999999925,
                          "text": "At exit 26A take ramp on the left to Golden State Fwy / I-5 toward Sacramento",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTRampLeft"
                      },
                      "compressedGeometry": "+haa49-1vvvfi4+ieagjr+4dt+4ut+244+54k-42i+dqo-bgu+jm2-2l5+ehe-2ff+ehe-mn+3bs-1dd+4ji"
                  },
                  {
                      "attributes": {
                          "length": 3.6585065283882727,
                          "time": 5.139497780136236,
                          "text": "At fork keep left",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTForkLeft"
                      },
                      "compressedGeometry": "+ha3m2-1vv85vd+ie65lr-c1r+cis-1k9s+121e-c1r+72v-qde+dkt-rqr+gr1-9id+5r8-7vb+5li-6nk+4jh-nu0+jlr-f7v+f29-13er+14b7-66j+66j-13vr+14s7-rl5+sn7-ipf+jg5-fdl+ful-485+66j-fdl+nd0-p02+tji-dkt+aq4-212d+1eka-aq4+78k-7ea+4us-6t9+4jh-2ieg+19fo-1a0o+mgk-60u+3n5-1bv6+tjj-364+242-30f+243-6t9+4p7-122+mm-jg5+ie4-fov+quf-2fe+4jh-1oo+3bp-243+486-s66+1l0i-esk+rqr-66j+cd6"
                  },
                  {
                      "attributes": {
                          "length": 0.33009671023345177,
                          "time": 0.5565389999999979,
                          "text": "At exit 141B take ramp on the right toward Griffith Park Drive",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTRampRight"
                      },
                      "compressedGeometry": "+ha38b-1vvud6l+ieqla0-b5f+19fn-8am+bb4-60t+3bq-54h+243-cis+4jh-54h+1ud-29p+5m"
                  },
                  {
                      "attributes": {
                          "length": 0.25849003444784557,
                          "time": 0.64023545445144425,
                          "text": "Make sharp left on Griffith Park Dr",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTSharpLeft"
                      },
                      "compressedGeometry": "+ha366-1vvvnud+iesk2p+5m-121+1ud-ebj-2l3-coh-7ea-l8s+121-aep+122-5a7"
                  },
                  {
                      "attributes": {
                          "length": 0.19626683142420909,
                          "time": 0.71251378429749368,
                          "text": "Make sharp right on Crystal Springs Dr",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTSharpRight"
                      },
                      "compressedGeometry": "+ha36p-1vvvvvs+ieqjf0+6nk-242+3sq+3bp-3n4+m58+485+e5u+0+1j2"
                  },
                  {
                      "attributes": {
                          "length": 0,
                          "time": 0,
                          "text": "Finish at Griffith Park, on the right",
                          "ETA": -2209161600000,
                          "arriveTimeUTC": -2209161600000,
                          "maneuverType": "esriDMTStop"
                      },
                      "compressedGeometry": "+ha39p-1vvvvt7+iertrb+0+0"
                  }
              ]
          }
      ]
    }
    
  3. Go to the top of the response and find the main properties returned:

    • routes: Contains the geometry (as a line) of the route.
    • directions: An array (usually containing a single object) that represents the directions for the corresponding route.
  4. Find the routes property. This response has the following properties:

    • geometryType: Usually esriGeometryPolyline, this indicates the type of geometry of the route.
    • spatialReference: Indicates the coordinate system geometries currently being returned
    • features: An array (usually with a single item) that contains the line representing the route
  5. Find the directions property. This is an array (usually containing a single item). Each set of directions has the following properties:

    • summary: A summary of the entire route, will have the total duration of the route and the estimated length of it.
    • features: An array of objects representing each step of the directions.

Add additional stops to make a loop

  1. In the Body, change the stops parameter to the JSON below. This adds two new stops and returns to LA City Hall at the end.

    {
      "type":"features",
      "features":  [
          {
          "geometry": {
            "x": -118.243529,
            "y": 34.053879,
            "spatialReference": {
              "wkid": "4326"
            }
          },
          "attributes": {
            "Name": "Los Angeles City Hall"
          }
        },
        {
          "geometry": {
            "x": -118.253309,
            "y": 34.124759,
            "spatialReference": {
              "wkid": "4326"
            }
          },
          "attributes": {
            "Name": "Forest Lawn Memorial Park"
          }
        },
        {
          "geometry": {
            "x": -118.233200,
            "y": 34.082500,
            "spatialReference": {
              "wkid": "4326"
            }
          },
          "attributes": {
            "Name": "Elysian Park"
          }
        },
        {
          "geometry": {
            "x": -118.273939,
            "y": 34.123480,
            "spatialReference": {
              "wkid": "4326"
            }
          },
          "attributes": {
            "Name": "Griffith Park"
          }
        },
        {
          "geometry": {
            "x": -118.243529,
            "y": 34.053879,
            "spatialReference": {
              "wkid": "4326"
            }
          },
          "attributes": {
            "Name": "Los Angeles City Hall"
          }
        }
      ]
    }
    
  2. Click Send to run the request.

  3. In the request window, search for totalTime. Notice that response.directions[0].totalTime is ~56 minutes.

Add parameters to optimize the route order

  1. In the Body, add the findBestSequence parameter to the request with a value of true. This will reorder the stops and calculate the shortest travel time.

  2. Click Send to run the request.

  3. In the request window, search for totalTime. Notice that response.directions[0].totalTime is now ~43 minutes.

  1. In Postman click Code below the Send button. Select a programming language and use Postman to generate sample code for your application to run this request.

Congratulations, you're done!

You have determined the most optimal route between locations and you have retrieved a set of written directions for the corresponding route.

Challenge

Add a barrier to your route

You can add barriers to routes to restrict or impact which roads the underlying route can use. Look at the barriers, polylineBarriers and polygonBarriers parameters in the routing service documentation.

Get walking directions

You can customize how your route is determined with the travelMode parameter. For example you can get routes optimized for best walking time or shortest driving distance as opposed to driving time. See the travelMode routing service documentation or the GetTravelModes API.