GPS Live View

The GPS packets are the fundamental unit for the GPS system.

Entities

GPS Queue Packet

Endpoint

https://app.xfleet.io/api/v1/companies/{company}/gpsQueuePackets

This is a packet as received from the device (mobile phone or GPS box on the car). It is yet to be processed.

Field Type Description Example
vehicle Vehicle Associated vehicle 1Q4L6Vm4ZphDJVkkc2Tgdw
date datetime Date when the packet was generated 2019-04-02T21:09:32Z
lat decimal(8, 6) Latitude 40.75851758632223
lon decimal(9, 6) Longitude -73.98542266275206
speed int Speed in meters / second 16
heading int Heading (orientation in degrees: 0 ... 360) 170
ignition bool Whether or not the engine is on true
event int The ID of the event that just occured (if any) 4
eventData int Additional information about the event 620
distanceFromPrev int Distance from the previous point (in meters) 150
distanceFromStart int Total distance since the engine was turned on 3120
route Route The route that this packet was assigned to {"id": "..."}

GPS Packet

Endpoint

https://app.xfleet.io/api/v1/companies/{company}/gpsPackets

This is a packet after it was processed by the GPS.

Field Type Description Example
vehicle Vehicle Associated vehicle 1Q4L6Vm4ZphDJVkkc2Tgdw
date datetime Date when the packet was generated 2019-04-02T21:09:32Z
lat decimal(8, 6) Latitude 40.75851758632223
lon decimal(9, 6) Longitude -73.98542266275206
speed int Speed in meters / second 16
heading int Heading (orientation in degrees: 0 ... 360) 170
ignition bool Whether or not the engine is on true
event int The ID of the event that just occured (if any) 4
eventData int Additional information about the event 620
distanceFromPrev int Distance from the previous point (in meters) 150
distanceFromStart int Total distance since the engine was turned on 3120
route Route The route that this packet was assigned to {"id": "..."}

Vehicle Statuses

Please note that this API is experimental, and it's subject to change.

This API returns the GPS Live View information about all vehicles.

curl \
    -H 'Authorization: Token ...' \
   https://api.xfleet.io/api/v1/companies/{id}/vehicleStatuses
[
    {
        "vehicle": {"id":  "..."},
        "gpsStatus": {
            "engineState": true,
            "speed": 57.6,
            "lat": 40.758518,
            "lon": -73.985423,
            "heading": 179,
            "positionUpdatedAt": "2021-11-05T21:09:32+00:00",
            "engineUpdatedAt": "2021-11-05T21:09:32+00:00",
            "updatedAt": "2021-11-05T21:09:32+00:00",
            "gpsSignal": true
        },
        "gpsStats": {
            "date": "2021-11-05T00:00:00+00:00",
            "distance": "32.5",
            "trips": 1,
            "maxSpeed": 16.0,
            "initEngineState": false,
            "engineOnDuration": 0,
            "engineOnStayDuration": 0,
            "engineFirstStartedAt": "2021-11-05T21:09:32+00:00",
            "engineLastStartedAt": "2021-11-05T21:09:32+00:00",
            "lastEngineState": true,
            "engineUpdatedAt": "2021-11-05T21:09:32+00:00",
            "firstLat": 40.758518,
            "firstLon": -73.985423,
            "lastLat": 40.758518,
            "lastLon": -73.985423,
            "lastHeading": 179,
            "lastSpeed": 16.0,
            "lastGpsSignal": true,
            "positionUpdatedAt": "2021-11-05T21:09:32+00:00",
            "updatedAt": "2021-11-05T21:09:32+00:00",
            "firstPacketReceivedAt": "2021-11-05T21:09:32+00:00",
            "lastPacketReceivedAt": "2021-11-05T21:09:32+00:00",
            "id": "2cpi4jBxk6VjBsItRm63bo"
        },
        "lastAddress": "40.758518, -73.985423",
        "statusText": "Driving: 2h 45m 34s",
        "statusColor": "teal",
        "icon": "arrows/teal.png"
    }
]

Send GPS data

This sends GPS data to the GPS processing engine. Please note that the data is processed asynchronously, and it may take up to 60 seconds to process the data (i.e. you will get an instant response but the data may not show on the GPS pages instantly).

curl \
    -X POST \
    -H 'Authorization: Token ...' \
    -H 'Content-Type: application/json' \
    -d '{
            "vehicle": "5iUGSh6f3jnFaCYegp20HD",
            "date": "2021-11-05T21:09:32Z",
            "lat": 40.75851758632223,
            "lon": -73.98542266275206,
            "speed": 16,
            "heading": 179,
            "ignition": 1
        }' \
   https://api.xfleet.io/api/v1/companies/{company}/gpsQueuePackets
{
    "vehicle": {
        "id": "5iUGSh6f3jnFaCYegp20HD"
    },
    "date": "2021-11-05T21:09:32+00:00",
    "lat": 40.758517586322,
    "lon": -73.985422662752,
    "speed": 16.0,
    "heading": 179,
    "ignition": true,
    "id": "4unXLxTh8l7MyuPb3YlY8W"
}