Enode Developers

Fetch vehicle charge state

In this guide, we will show you how to fetch the charge state information of a user’s connected vehicle.

PrerequisitesCopy link

Step 1: Fetch the user’s linked vehiclesCopy link

To begin, let’s make a request to fetch our users linked vehicles by calling the /vehicles endpoint. You refer to your user by passing an Enode-User-Id header with our request. Make sure you refer to an existing user. In the example below, we refer to the same user as we referred to in the first guide.

Sample

curl https://enode-api.sandbox.enode.io/vehicles \
-X GET \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Enode-User-Id: 1ab23cd4"

If you provided the correct values, you should get a response back containing an array of the user’s linked vehicles.

Sample

[
  {
    "id": "c6198bd9-9a25-425d-afc3-a61ee974d1a8",
    "isReachable": true,
    "lastSeen": "2022-02-11T09:12:26.465Z",
    "capabilities": { ... },
    "chargingLocationId": null
  },
  // If you linked multiple vehicles, they will show up here
]

Pick any of the linked vehicles from the response and copy the id, excluding the " quotes.

Step 2: Fetch a specific user vehicleCopy link

Using the id of the vehicle you want to fetch information for, you can call the /vehicles/{vehicleId} endpoint.

Sample

curl https://enode-api.sandbox.enode.io/vehicles/{YOUR_COPIED_ID} \
-X GET \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Enode-User-Id: 1ab23cd4"

If you provided the correct values, you should get a response back containing the latest cached information for the specified vehicle. See the API reference for more information on caching.

Sample

{
  "smartChargingPolicy": { ... },
  "chargeState": { ... },
  "location": { ... },
  "information": {
    "id": "c6198bd9-9a25-425d-afc3-a61ee974d1a8",
    "brand": "TESLA",
    "model": "Model S Sedan",
    "year": 2019
  },
  "odometer": { ... },
  "capabilities": { ... },
  "id": "c6198bd9-9a25-425d-afc3-a61ee974d1a8",
  "isReachable": true,
  "lastSeen": "2022-02-11T09:19:34.220Z",
  "chargingLocationId": null
}

Step 3: Fetch updated charge state informationCopy link

Fetch the updated charge state information by calling /vehicles/{vehicleId}/charge-state. This will pull the latest updated charge state data from the vehicle’s OEM APIs and return the data. For further information and additional parameters, see our API reference.

Sample

curl https://enode-api.sandbox.enode.io/vehicles/{YOUR_COPIED_ID}/charge-state \
-X GET \
-H "Authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Enode-User-Id: 1ab23cd4"

If you provided the correct values, you should get a response back with the updated vehicle charge state information. You can learn more about this response in our API reference.

Sample

{
  "isPluggedIn": false,
  "isCharging": false,
  "batteryLevel": 93,
  "range": 558,
  "isChargingReasons": [
    "NOT_PLUGGED_IN"
  ],
  "batteryCapacity": 75,
  "chargeLimit": 100,
  "chargeRate": null,
  "chargeTimeRemaining": null,
  "lastUpdated": null
}

All done!Copy link

Congratulations, you just fetched updated charge state information from a vehicle! For extra credit, you can repeat step 3 to fetch other updated information by replacing the charge-state endpoint with location, odometer or information.

You can continue exploring our API and features through the links below.

Download Postman collection

Our API schema wrapped in a Postman collection

Browse our API reference

The ins and outs of our endpoints