Enode Developers

Fetch vehicle charge state

This guide demonstrates how to retrieve charge state data for a connected vehicle.

Copy linkPrerequisites

Copy linkStep 1: Fetch the user’s linked vehicles

First, call the /vehicles endpoint to fetch the user's linked vehicles. Pass an Enode-User-Id header with the request, referring to an existing user. In the example below, we reference the same user as 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 receive a response 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 linked vehicle from the response and copy the id, excluding the " quotes.

Copy linkStep 2: Fetch a specific user vehicle

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'll receive a response with the latest cached information for the specified vehicle. Refer to the API referenceAPI for details 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
}

Copy linkStep 3: Fetch updated charge state information

Call /vehicles/{vehicleId}/charge-state to fetch the latest charge state data from the vehicle's OEM APIs. For more information and additional parameters, consult our API referenceAPI.

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'll receive a response containing the updated charge state data. Learn more about this response in our API referenceAPI.

Sample

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

Copy linkAll done!

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

Was this article helpful?