Skip to main content
GET
/
v1
/
vehicles
/
{vehicle_id}
/
consumptions
/
unique-values
Get Vehicle Consumption Unique Values
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/vehicles/{vehicle_id}/consumptions/unique-values', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "field": "<string>",
  "total_count": 123,
  "values": {
    "value": {},
    "label": {},
    "count": 123
  }
}

Get Vehicle Consumption Unique Values

Retrieve all unique values for a specific consumption field for a given vehicle, along with the count of records for each value. Useful for building filter dropdowns or understanding data distribution.
Use Case: This endpoint is commonly used to populate filter options in a UI — for example, listing all distinct file IDs that have been used to import consumption records so users can filter by source file.

Request

Path Parameters

vehicle_id
uuid
required
The UUID of the vehicleExample: 550e8400-e29b-41d4-a716-446655440000

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Query Parameters

field
string
required
The consumption field to get unique values forAvailable values: file_idExample: field=file_id

Response

field
string
The field name that was queried
total_count
integer
Total number of unique values found
values
array[object]
List of unique values with their record counts

Example

curl -X GET "https://api.dcycle.io/v1/vehicles/550e8400-e29b-41d4-a716-446655440000/consumptions/unique-values?field=file_id" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

{
  "field": "file_id",
  "total_count": 2,
  "values": [
    {
      "value": "880e8400-e29b-41d4-a716-446655440000",
      "label": "consumption_import_2024_q1.csv",
      "count": 24
    },
    {
      "value": null,
      "label": null,
      "count": 3
    }
  ]
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{
  "detail": "Invalid API key",
  "code": "INVALID_API_KEY"
}

404 Not Found

Cause: Vehicle not found in organization
{
  "code": "VEHICLE_NOT_FOUND",
  "detail": "Vehicle with id=UUID('...') not found"
}

422 Validation Error

Cause: Missing or invalid field parameter
{
  "detail": [
    {
      "loc": ["query", "field"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Vehicle Consumptions

List all consumption records for a vehicle

Bulk Delete Consumptions by Filters

Delete consumptions matching filter criteria

Vehicle Unique Values

Get unique values for vehicle fields

Vehicle Overview

Learn about the Vehicles API