EV Battery API
Read an electric vehicle’s battery level and battery capacity with simple API requests.
Retrieve the state of charge (SoC) and the remaining range from a battery electric vehicle (BEV) or a plug-in hybrid vehicle (PHEV).
Know the capacity of an electric vehicle’s battery.
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 battery level
const battery = await vehicle.battery();
console.log(battery);
// Fetch the vehicle's battery capacity
const batteryCapacity = await vehicle.batteryCapacity();
console.log(batteryCapacity);
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 battery level
battery = vehicle.battery()
print(battery)
# Fetch the vehicle's battery capacity
battery_capacity = vehicle.battery_capacity()
print(battery_capacity)
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 battery level
SmartcarResponse<VehicleBattery> battery = vehicle.battery();
System.out.println(battery);
// Fetch the vehicle's battery capacity
SmartcarResponse<VehicleBatteryCapacity> batteryCapacity = vehicle.batteryCapacity();
System.out.println(batteryCapacity);
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 battery level
var battery, resErr = vehicle.GetBattery(context.TODO());
// Fetch the vehicle's battery capacity
var batteryCapacity, resErr = vehicle.GetBatteryCapacity(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 battery level
battery = vehicle.battery()
puts battery.to_hash.slice(*%I(percentRemaining range))
# Fetch the vehicle's battery capacity
battery_capacity = vehicle.battery_capacity()
puts battery_capacity.to_hash.slice(*%I(capacity))
// Example response from Smartcar (battery level)
{
"percentRemaining": 0.3,
"range": 40.5,
}
// Example response from Smartcar (battery capacity)
{
"capacity": 28.7,
}
Provide estimated charging times, automatic charging schedules, and EV trip planning in your app.
Learn more about EV chargingManage your customers’ residential EV charging to best balance electric grid load.
Learn more about energy and utilities