List Waste Filter Values
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/waste/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/waste/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/waste/unique-values \
--header 'x-organization-id: <x-organization-id>'{
"field": "<string>",
"total_count": 123,
"values": {
"value": "<string>",
"label": "<string>",
"count": 123
}
}List Waste Filter Values
Get the distinct values of a waste field for one facility, with record counts, to populate a filter dropdown
GET
/
v1
/
waste
/
unique-values
List Waste Filter Values
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/waste/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/waste/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/waste/unique-values \
--header 'x-organization-id: <x-organization-id>'{
"field": "<string>",
"total_count": 123,
"values": {
"value": "<string>",
"label": "<string>",
"count": 123
}
}← Wastes API
Get the distinct values a field takes across one facility’s waste records, each with the number of records using it. Call it before rendering a filter so the dropdown only offers values that actually exist — a list of every LER code in the catalogue would let a user pick one that returns nothing.
Cause:
The path is
/v1/waste, singular. The Wastes API is split across two prefixes: the records themselves live under /v1/wastes (plural), while this endpoint and the bulk operations live under /v1/waste. Calling /v1/wastes/unique-values does not 404 — it returns 405 Method Not Allowed, because the plural path matches PATCH /v1/wastes/{waste_id} and only its method is wrong. A 405 on a GET is the signal that you used the plural.facility_id is required, but one field ignores it. Four of the five fields scope their values to the facility you name. created_at does not: it filters only by organization, so it returns the creation dates of every waste record in the organization, whichever facility they belong to.The parameter is still mandatory for created_at — it is simply not applied. Do not rely on its values to describe the facility you asked about.Request
Headers
string
required
UUID of the organization the facility belongs to.Format: UUID
string
Your API key.
Query Parameters
string
required
The field to list values for. Five values are accepted:
file_id— the source files the records were imported fromcreated_at— the dates records were created onidentification_name— the waste identification names in useler_code— the European Waste Catalogue codes in userd_code— the recovery/disposal codes in use
422, so this is a closed list rather than free text.string
required
UUID of the facility whose records you are filtering.Format: UUID
Response
string
The field that was queried, echoed back.
integer
How many distinct values were found.
array[object]
The distinct values, each with its record count.
Show Value Object
Show Value Object
string
The raw value — a UUID string for
file_id, a date string for created_at, the code itself for ler_code and rd_code. This is what you send back as a filter.string
Human-readable caption. For
file_id it is the file name; for ler_code and rd_code it repeats the code itself, so you can render label uniformly without special-casing.integer
Number of waste records carrying this value.
There is no
null bucket, whatever the field. Records with no source file come back as the zero UUID, 00000000-0000-0000-0000-000000000000, with their own count — treat it as “no file”, not as a real id. The other three optional fields exclude their empty rows entirely, so their counts do not add up to the facility’s total record count.Example
curl -X GET "https://api.dcycle.io/v1/waste/unique-values?field=ler_code&facility_id=YOUR_FACILITY_ID" \
-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",
}
data = requests.get(
"https://api.dcycle.io/v1/waste/unique-values",
headers=HEADERS,
params={"field": "ler_code", "facility_id": "YOUR_FACILITY_ID"},
timeout=30,
).json()
# Only the LER codes this facility has actually reported
for item in data["values"]:
no_file = item["value"] == "00000000-0000-0000-0000-000000000000"
caption = "(no source file)" if no_file else item["label"]
print(f"{caption}: {item['count']} records")
const params = new URLSearchParams({
field: "ler_code",
facility_id: facilityId,
});
const response = await fetch(
`https://api.dcycle.io/v1/waste/unique-values?${params}`,
{
headers: {
"x-api-key": "YOUR_API_KEY",
"x-organization-id": "YOUR_ORGANIZATION_ID",
},
},
);
const data = await response.json();
const NO_FILE = "00000000-0000-0000-0000-000000000000";
const options = data.values.map((v) => ({
value: v.value,
caption: v.value === NO_FILE ? "(no source file)" : v.label,
count: v.count,
}));
Successful Response
Returns200 OK.
{
"field": "ler_code",
"total_count": 2,
"values": [
{
"value": "150101",
"label": "150101",
"count": 34
},
{
"value": "200301",
"label": "200301",
"count": 12
}
]
}
Common Errors
422 Unprocessable Entity
Cause:field or facility_id is missing. Both are required.
{
"detail": [
{
"loc": ["query", "facility_id"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
field is not one of the five accepted values.
{
"detail": [
{
"loc": ["query", "field"],
"msg": "value is not a valid enumeration member; permitted: 'file_id', 'created_at', 'identification_name', 'ler_code', 'rd_code'",
"type": "type_error.enum",
"ctx": {
"enum_values": ["file_id", "created_at", "identification_name", "ler_code", "rd_code"]
}
}
]
}
Use Cases
Build a filter that never comes back empty
Populate your LER or RD dropdown from this endpoint rather than from the full code catalogue. The catalogue has hundreds of codes; a given facility reports a handful, and offering the rest only produces empty result sets.Check what an import actually created
field=file_id groups a facility’s waste records by the file they came from, with counts — the quickest confirmation that an upload landed where you expected, and the input to a cleanup if it did not.
Related Endpoints
List Wastes
The records these values filter
List Waste Emission Factors
The LER and RD code catalogue, for creating records
Bulk Delete by Filters
Apply the filter you just built to a bulk delete
Wastes API
Everything the Wastes API covers
Was this page helpful?