What API endpoint best captures daily odometer values?

Question:
I want to capture the end of day odometer reading for my vehicles via the API. Which endpoint should I use and why?

The answer depends on your objective. You can get results from either of these endpoints:
hierarchyNode/beginEndDay or vehicleGroup/location.

hierarchyNode/beginEndDay

Example Request:

https://api.gpsinsight.com/v2/vehicle/beginendday?session_token=xxxx&vehicle=Truck%20240&start=08/01/2015+12:00:00&end=08/02/2015


Example Response:

{
head: { …. },
data: [
{
    id: “CA453100XXXX”,
    vin: “5FNRL38437B40XXXX”,
    label: “Truck 240”,
    serial_number: 4531009052,
    odometer: 174903.5,
    driver_id: 1009582,
    first_name: “Tom”,
    last_name: “Marks”,
    trips: 10,
    date: “08/01/2015”,
    start_time: “11:15:13”,
    end_time: “22:44:09”,
    duration: 41336,
    trip_duration: 6929,
    distance: 46.2,
    max_speed: 56,
    avg_speed: 20,
    start_latitude: 33.3469039,
    start_longitude: -111.7825039,
    end_latitude: 33.3468030,
    end_longitude: -111.7825038
}, { … }
]
}

In this use case, you can select the specific day or day range that you want and can use the readings that you want (i.e., odometer) from the data set you retrieve. However, if odometer is the only thing you’re after, beginEndDay may be a little much. It returns one record per day, per vehicle (like the report from the web interface). A more direct route to odometer might be the vehicleGroup/location endpoint.

vehicleGroup/location

Example Request:

https://api.gpsinsight.com/v2/vehiclegroup/location?session_token=xxxx&vehicle_group=Delivery


Example Response:

{
head: { …. },
data: [
{
    id: “CA4641163XXX”,
    vin: “CA4641163XXX”,
    label: “Truck 201”,
    serial_number: 4641163XXX,
    age_minutes: 45834,
    fix_time: “7/20/15 14:56:56”,
    fix_time_mst: “7/20/15 14:56:56 MST”,
    fix_time_gmt: “2015-07-20T21:56:56+00:00”,
    exec_time: “2015-08-21T17:51:23+00:00”,
    latitude: 33.65942,
    longitude: -111.92482,
    landmark_id: 910482,
    landmark: “Headquarters”,
    heading: 331,
    ignition: “off”,
    max_speed: 0,
    avg_speed: 0,
    inst_speed: 0,
    speed_label: “Stopped 31 days”,
    speed_icon: “red_dot”,
    odometer: 1682.6
}, { … }
]
}

The odometer you get from vehicle/location can be correlated to the timestamp you get from the same function. Even if a vehicle is moving currently, you should get the up-to-the-minute odometer and the associated timestamp in the fix_time or fix_time_gmt value. Moreover, if you run this import at night, you should get similar values to the beginEndDay report values.

The simplest way for you to get all your vehicles is to run vehicle/location with no parameters (except your session token). This request returns an unfiltered list of vehicles. There isn’t an equivalent unfiltered view for vehicle/beginEndDay because the query is much heavier. You have to specify a vehicle there.