GuidesAPI Reference
Guides

How to optimize a sequence for time constraints

Time constraints are defined using two parameters:

  • acc, which defines the time windows when the destination can be visited.
  • st, which defines "service time" - time spent at the given waypoint.

The following constraint allows visits on Mondays to Fridays between 12 PM and 6 PM. The service time is 15 minutes.

acc:mo12:00:00+02:00|fr18:00:00+02:00;st:900

To learn more about defining time constraints, see the API reference.

Example

The car journey starts in Duisburg-Ruhrort and the destination is the nearby Duisburg-Haefen. The route must pass through Zeche Zollverein, Kokerei Zollverein, and Muehlheim. The driver needs the fastest possible route.

Request

curl -H "Authorization: Bearer BEARER_TOKEN" "https://wps.hereapi.com/v8/findsequence2?departure=2015-05-04T8:00:00%2b01:00&mode=fastest;car;traffic:disabled&start=DuisburgRuhrort;51.4541,6.7406&destination1=ZecheZollverein;51.486,7.0459;acc:mo09:00:00%2b01:00%7cmo10:00:00%2b01:00;st:60&destination2=KokereiZollverein;51.4879,7.0337;acc:mo10:30:00%2b01:00%7cmo12:00:00%2b01:00;st:600&destination3=MuehlheimRuhrHbf;51.432,6.886;acc:mo08:00:00%2b01:00%7cmo09:00:00%2b01:00;st:60&end=DuisburgHafen;51.4576,6.7717&improveFor=TIME"

Response

{
  "results": [
    {
      "waypoints": [
        {
          "id": "DuisburgRuhrort",
          "lat": 51.4541,
          "lng": 6.7406,
          "sequence": 0,
          "estimatedArrival": null,
          "estimatedDeparture": "2015-05-04T08:00:00+01:00",
          "fulfilledConstraints": []
        },
        {
          "id": "MuehlheimRuhrHbf",
          "lat": 51.432,
          "lng": 6.886,
          "sequence": 1,
          "estimatedArrival": "2015-05-04T08:15:57+01:00",
          "estimatedDeparture": "2015-05-04T08:16:57+01:00",
          "fulfilledConstraints": [
            "acc:mo08:00:00+01:00|mo09:00:00+01:00;st:60"
          ]
        },
        {
          "id": "ZecheZollverein",
          "lat": 51.486,
          "lng": 7.0459,
          "sequence": 2,
          "estimatedArrival": "2015-05-04T08:37:15+01:00",
          "estimatedDeparture": "2015-05-04T09:01:00+01:00",
          "fulfilledConstraints": [
            "acc:mo09:00:00+01:00|mo10:00:00+01:00;st:60"
          ]
        },
        {
          "id": "KokereiZollverein",
          "lat": 51.4879,
          "lng": 7.0337,
          "sequence": 3,
          "estimatedArrival": "2015-05-04T09:05:10+01:00",
          "estimatedDeparture": "2015-05-04T10:40:00+01:00",
          "fulfilledConstraints": [
            "acc:mo10:30:00+01:00|mo12:00:00+01:00;st:600"
          ]
        },
        {
          "id": "DuisburgHafen",
          "lat": 51.4576,
          "lng": 6.7717,
          "sequence": 4,
          "estimatedArrival": "2015-05-04T11:04:36+01:00",
          "estimatedDeparture": null,
          "fulfilledConstraints": []
        }
      ],
      "distance": "60641",
      "time": "11076",
      "interconnections": [
        {
          "fromWaypoint": "DuisburgRuhrort",
          "toWaypoint": "MuehlheimRuhrHbf",
          "distance": 12158,
          "time": 957,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "MuehlheimRuhrHbf",
          "toWaypoint": "ZecheZollverein",
          "distance": 17595,
          "time": 1218,
          "rest": 0,
          "waiting": 1365
        },
        {
          "fromWaypoint": "ZecheZollverein",
          "toWaypoint": "KokereiZollverein",
          "distance": 2524,
          "time": 250,
          "rest": 0,
          "waiting": 5090
        },
        {
          "fromWaypoint": "KokereiZollverein",
          "toWaypoint": "DuisburgHafen",
          "distance": 28364,
          "time": 1476,
          "rest": 0,
          "waiting": 0
        }
      ],
      "description": "Targeted best time; without traffic",
      "timeBreakdown": {
        "driving": 3901,
        "service": 720,
        "rest": 0,
        "waiting": 6455,
        "break": 0
      }
    }
  ],
  "errors": [],
  "processingTimeDesc": "88ms",
  "responseCode": "200",
  "warnings": null,
  "requestId": "cbe2b195-a8d8-4593-97c6-0355be2530cb"
}