Fields

Field Type Description Example
id string Route ID 1Q4L6Vm4ZphDJVkkc2Tgdw
plannedDistance integer Planned distance in meters 3251
actualDistance integer Actual (ie. via GPS) distance in meters 3260
plannedStart datetime Planned start time 2019-02-24T09:30:00Z
actualStart datetime Actual start time 2019-02-24T09:32:54Z
plannedFinish datetime Planned finish time 2019-02-24T13:00:00Z
actualFinish datetime Actual (ie. via GPS) finish time 2019-02-24T13:07:32Z
plannedDuration datetime Planned duration in seconds 12600
actualDuration datetime Actual (ie. via GPS) duration in seconds 12878
services list List of services [{"id": "..."}]
vehicle Vehicle Assigned vehicle {"id": "..."}
driver Driver Assigned driver {"id": "..."}
team Team Assigned team {"id": "..."}
directions json A JSON representing the exact trajectory of the route see the example in List routes
status Status Route status {"id": "..."}

List routes

$ curl -H 'Authorization: Token ...' \
       -X GET \
       https://app.xfleet.io/api/v1/companies/{company}/routes
[
  {
    "name": "2019-03-17 / 03:30 / 249W807D",
    "plannedDistance": 35600,
    "plannedStart": "2019-03-17T03:30:00+00:00",
    "plannedFinish": "2019-03-17T05:44:00+00:00",
    "plannedDuration": 8040,
    "services": [
      {
        "id": "50dTZIeTPjQRhPKo0Z2hpZ"
      }
    ],
    "vehicle": {
      "id": "qh1tgWeBIUMDxJKgvUoYk"
    },
    "directions": {
      "legs": [
        {
          "steps": [
            {
              "distance": "1100",
              "duration": "60",
              "startLocation": {
                "lat": "40.767116",
                "lon": "-73.842535"
              },
              "endLocation": {
                "lat": "40.769726",
                "lon": "-73.834725"
              },
              "polyLine": [
                [
                  -73.842535,
                  40.767116
                ]
              ]
            }
          ],
          "distance": "1100",
          "duration": "60"
        }
      ],
      "distance": 35600,
      "duration": 8040
    },
    "id": "1Q4L6Vm4ZphDJVkkc2Tgdw",
    "createdAt": "2019-03-23T13:41:39+00:00"
  }
]

Create a route

$ curl -H 'Authorization: Token ...' \
       -X POST \
       -d '{
              "plannedDistance": 22400,
              "plannedStart": "2019-02-20T09:00:00+02:00",
              "plannedFinish": "2019-02-20T09:31:00+02:00",
              "plannedDuration": 1860,
              "services": [
                {
                  "name": "Your Depot",
                  "plannedArrival": "2019-02-20T09:00:00+02:00",
                  "plannedDeparture": "2019-02-20T09:00:00+02:00",
                  "serviceTime": 0,
                  "lat": 40.729567809139,
                  "lon": -73.899536132812,
                  "client": null,
                  "depot": {"id": "..."},
                },
                {
                  "name": "John Smith",
                  "plannedArrival": "2019-02-20T09:11:00+02:00",
                  "plannedDeparture": "2019-02-20T09:21:00+02:00",
                  "lat": 40.713549215312,
                  "lon": -74.004024267197,
                  "orders": [
                    {"id": "..."}
                  ],
                  "client": {"id": "..."}
                }
              ],
              "vehicle": {"id": "..."},
              "driver": {"id": "..."},
              "team": {"id": "..."},
              "directions": {
                "legs": [
                  {
                    "steps": [
                      {
                        "distance": 11300,
                        "duration": 660,
                        "startLocation": {"lat": 40.729559, "lon": -73.899246},
                        "endLocation": {"lat": 40.713437, "lon": -74.003804},
                        "polyLine": [
                          [-73.899246, 40.729559]
                        ]
                      }
                    ],
                    "distance": 11100,
                    "duration": 600
                  }
                ],
                "distance": 22400,
                "duration": 1860
              },
              "status": {"id": "..."}
            }'\
       https://app.xfleet.io/api/v1/companies/{company}/routes

Update a route service

$ curl -H 'Authorization: Token ...' \
       -X PATCH \
       -d {"delivered": true} \
       https://app.xfleet.io/api/v1/companies/{company}/routes/{route}/services/{service}
{
    "name": "John Smith",
    "plannedArrival": "2019-03-07T23:43:47+00:00",
    "plannedDeparture": "2019-03-07T23:53:47+00:00",
    "serviceTime": 0,
    "lat": -73.842535,
    "lon": 40.767116,
    "orders": [
        {
            "id": "7WQlehXXemNjYW7EzAR9RY"
        }
    ],
    "client": {
        "id": "4DfX3YmztAvqupfPiqWgFQ"
    },
    "delivered": true,
    "id": "20tHVpNdLEOtRyObHhwhK1",
    "createdAt": "2019-04-07T20:16:27+00:00",
    "modifiedAt": "2019-04-07T20:22:27+00:00"
}