Odometer API
Check a car’s odometer reading instantly, accurately, and cost-effectively with Smartcar’s APIs.
Retrieve the total mileage traveled by a vehicle.
const smartcar = require('smartcar');
// Get all vehicles associated with this access token
const {vehicles} = await smartcar.getVehicleIds("<access-token>");
// Construct a new vehicle instance using the first vehicle's id
const vehicle = new smartcar.Vehicle(vehicles[0], "<access-token>");
// Fetch the vehicle's odometer
const odometer = await vehicle.odometer();
console.log(odometer);
import smartcar
# Get all vehicles associated with this access token
response = smartcar.get_vehicle_ids("<access-token>")
# Construct a new vehicle instance using the first vehicle's id
vehicle = smartcar.Vehicle(response["vehicles"][0], "<access-token>")
# Fetch the vehicle's odometer
odometer = vehicle.odometer()
print(odometer)
import com.smartcar.sdk.*;
// Get all vehicles associated with this access token
SmartcarResponse<VehicleIds> response = AuthClient.getVehicleIds("<access-token>");
String[] vehicleIds = response.getData().getVehicleIds();
// Construct a new vehicle instance using the first vehicle's id
Vehicle vehicle = new Vehicle(vehicleIds[0], "<access-token>");
// Fetch the vehicle's odometer
SmartcarResponse<VehicleOdometer> odometer = vehicle.odometer();
System.out.println(odometer.getData().getDistance());
import (
"context"
smartcar "github.com/smartcar/go-sdk"
);
// Create a smartcar client
var smartcarClient = smartcar.NewClient();
// Get all vehicles associated with this access token
var vehicleIDs, resErr = smartcarClient.GetVehicleIDs(
context.TODO(),
&smartcar.VehicleIDsParams{Access: "<access-token>"},
);
// Construct a new vehicle instance using the first vehicle's id
var vehicle = smartcarClient.NewVehicle(&smartcar.VehicleParams{
ID: vehicleIDs.VehicleIDs[0],
AccessToken: "<access-token>"},
);
// Fetch the vehicle's odometer
var odometer, resErr = vehicle.GetOdometer(context.TODO());
require 'smartcar'
# Get all vehicles associated with this access token
vehicle_ids = Smartcar::Vehicle.all_vehicle_ids(token: token)
# Construct a new vehicle instance using the first vehicle's id
vehicle = Smartcar::Vehicle.new(
token: "<access-token>",
id: vehicle_ids.first
)
# Fetch the vehicle's odometer
odometer = vehicle.odometer()
puts odometer.to_hash.slice(*%I(distance))
// Example response from Smartcar
{
"distance": 104.32
}
Reduce premium leakage from underreported mileage or offer pay-per-mile insurance.
Learn more about auto insuranceSimplify fleet tracking and predictive maintenance with our hardware-free telematics APIs.
Learn more about fleet management