List Recharge Filter Values
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/logistics/recharges/unique-values', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/logistics/recharges/unique-values"
headers = {"x-organization-id": "<x-organization-id>"}
response = requests.get(url, headers=headers)
print(response.text)curl --request GET \
--url https://api.dcycle.io/v1/logistics/recharges/unique-values \
--header 'x-organization-id: <x-organization-id>'{
"field": "<string>",
"total_count": 123,
"values": {
"value": {},
"label": {},
"count": 123
}
}Get the distinct values of a recharge field, with record counts, to populate a filter dropdown
GET
/
v1
/
logistics
/
recharges
/
unique-values
List Recharge Filter Values
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/logistics/recharges/unique-values', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/logistics/recharges/unique-values"
headers = {"x-organization-id": "<x-organization-id>"}
response = requests.get(url, headers=headers)
print(response.text)curl --request GET \
--url https://api.dcycle.io/v1/logistics/recharges/unique-values \
--header 'x-organization-id: <x-organization-id>'{
"field": "<string>",
"total_count": 123,
"values": {
"value": {},
"label": {},
"count": 123
}
}← Logistics API
Get the distinct values a field takes across your organization’s logistics recharges, each with the number of records using it. Call it before rendering a filter so the dropdown offers only values that exist.
That makes “there are no recharges” and “I misspelled the field” look identical. The three accepted values are
The second entry is the bucket of recharges with no fuel set — nine real records, not an error.
field is free text, not a closed list — and an unsupported value does not return 422. It returns an empty array:{ "field": "fuel", "total_count": 0, "values": [] }
fuel_name, file_id and vehicle_license_plate; check your spelling against them before concluding the organization has no data.Only
active recharges are counted. Recharges still processing, or in error, are excluded from these values. A filter built from this response therefore describes your calculated data, not everything you uploaded.Request
Headers
string
required
UUID of the organization whose recharges you are filtering.Format: UUID
string
Your API key.
Query Parameters
string
required
The field to list values for. Three values are supported:
fuel_name—valueis the fuel id,labelis the fuel namefile_id—valueis the file id,labelis the file namevehicle_license_plate—valueandlabelare both the plate; blank and missing plates are excluded
Response
string
The field that was queried, echoed back verbatim — including when it is not a supported one.
integer
How many distinct values were found.
array[object]
The distinct values, each with its record count.
Show Value Object
Show Value Object
string | null
The raw value to send back as a filter.
null when the underlying field is empty — for fuel_name and file_id that is a real bucket of recharges with no fuel or no source file, with its own count.string | null
Human-readable caption. For
fuel_name and file_id it comes from an outer join, so it can be null even when value is set — a fuel or file id that no longer resolves to a row.integer
Number of active recharges carrying this value.
Example
curl -X GET "https://api.dcycle.io/v1/logistics/recharges/unique-values?field=fuel_name" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-organization-id: YOUR_ORGANIZATION_ID"
import requests
HEADERS = {
"x-api-key": "YOUR_API_KEY",
"x-organization-id": "YOUR_ORGANIZATION_ID",
}
ACCEPTED = {"fuel_name", "file_id", "vehicle_license_plate"}
def recharge_filter_values(field):
# The API will not tell you the field is wrong, so check it yourself
if field not in ACCEPTED:
raise ValueError(f"{field!r} is not one of {sorted(ACCEPTED)}")
return requests.get(
"https://api.dcycle.io/v1/logistics/recharges/unique-values",
headers=HEADERS,
params={"field": field},
timeout=30,
).json()
data = recharge_filter_values("fuel_name")
for item in data["values"]:
print(f"{item['label'] or '(unknown fuel)'}: {item['count']}")
const ACCEPTED = ["fuel_name", "file_id", "vehicle_license_plate"];
async function rechargeFilterValues(field) {
if (!ACCEPTED.includes(field)) {
throw new Error(`${field} is not one of ${ACCEPTED.join(", ")}`);
}
const params = new URLSearchParams({ field });
const response = await fetch(
`https://api.dcycle.io/v1/logistics/recharges/unique-values?${params}`,
{
headers: {
"x-api-key": "YOUR_API_KEY",
"x-organization-id": "YOUR_ORGANIZATION_ID",
},
},
);
return response.json();
}
Successful Response
Returns200 OK.
{
"field": "fuel_name",
"total_count": 2,
"values": [
{
"value": "7c3f1a26-8d45-4b90-a1e3-52f6b8c40d97",
"label": "Diesel",
"count": 412
},
{
"value": null,
"label": null,
"count": 9
}
]
}
Common Errors
422 Unprocessable Entity
Cause:field is missing entirely. Note that this is the only thing that fails validation here — a present but unsupported field succeeds with an empty array.
{
"detail": [
{
"loc": ["query", "field"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
Use Cases
Build a recharge filter that matches reality
Populate the fuel or file dropdown from this endpoint rather than from the full fuel catalogue. It also tells you how many records sit behind each option, which lets you show counts next to each choice.Spot recharges with no fuel assigned
Anull value in a fuel_name response is the count of recharges with no fuel. Those records cannot calculate emissions, and this is the cheapest way to notice they exist.
Related Endpoints
List Recharges
The records these values filter
Bulk Delete Recharges
Apply the filter you just built to a bulk delete
Create Recharge
Add the recharges you will be filtering
Logistics API
Everything the Logistics API covers
Was this page helpful?