> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Waste Classification Codes

> Get waste classification codes (LER, RD, LOW) for waste management

# Waste Classification Codes

Retrieve waste classification codes used in the Dcycle system for waste management and emissions calculations. These codes are based on European waste regulations and help classify waste types and disposal methods.

<Note>
  Waste codes are **reference data** maintained by Dcycle. You cannot create or modify codes through the API - these endpoints are read-only.
</Note>

## Overview

Dcycle uses three types of waste codes:

* **LER** (Lista Europea de Residuos / European Waste List) - Waste type classification
* **RD** (Royal Decree) - Disposal method classification
* **LOW** (List of Waste) - Regional waste codes

## GET /api/v1/wastes/rd\_ler\_list

Get all waste disposal methods (RD codes) with their associated waste types (LER codes). This endpoint returns a complete mapping of which waste types can be processed with which disposal methods.

### Request

#### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `ff4adcc7-8172-45fe-9cf1-e90a6de53aa9`
</ParamField>

<ParamField header="x-user-id" type="string" required>
  Your user UUID

  **Example:** `a1b2c3d4-e5f6-7890-abcd-ef1234567890`
</ParamField>

No query parameters required.

### Response

<ResponseField name="[]" type="array">
  Array of RD-LER mapping objects

  <ResponseField name="rd_code" type="string">
    Royal Decree disposal method code

    **Examples:** `"D1"`, `"D5"`, `"R1"`, `"R3"`
  </ResponseField>

  <ResponseField name="rd_name" type="string">
    Disposal method description

    **Examples:** `"Landfill"`, `"Incineration"`, `"Energy recovery"`, `"Recycling"`
  </ResponseField>

  <ResponseField name="ler_list" type="array">
    Array of LER (waste type) objects applicable to this disposal method

    Each LER object contains:

    * `ler_code` (string) - European waste code (6-digit format: XX XX XX)
    * `ler_name` (string) - Waste type description
  </ResponseField>
</ResponseField>

### Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/api/v1/wastes/rd_ler_list" \
    -H "Authorization: Bearer ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "x-user-id: ${DCYCLE_USER_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  api_key = os.getenv("DCYCLE_API_KEY")
  org_id = os.getenv("DCYCLE_ORG_ID")
  user_id = os.getenv("DCYCLE_USER_ID")

  headers = {
      "Authorization": f"Bearer {api_key}",
      "x-organization-id": org_id,
      "x-user-id": user_id
  }

  response = requests.get(
      "https://api.dcycle.io/api/v1/wastes/rd_ler_list",
      headers=headers
  )

  rd_ler_mapping = response.json()
  print(f"Found {len(rd_ler_mapping)} disposal methods:")

  for disposal in rd_ler_mapping:
      print(f"\n{disposal['rd_code']} - {disposal['rd_name']}")
      print(f"  Applicable to {len(disposal['ler_list'])} waste types")
      # Show first 3 waste types
      for ler in disposal['ler_list'][:3]:
          print(f"    - {ler['ler_code']}: {ler['ler_name']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const apiKey = process.env.DCYCLE_API_KEY;
  const orgId = process.env.DCYCLE_ORG_ID;
  const userId = process.env.DCYCLE_USER_ID;

  const headers = {
    'Authorization': `Bearer ${apiKey}`,
    'x-organization-id': orgId,
    'x-user-id': userId
  };

  axios.get('https://api.dcycle.io/api/v1/wastes/rd_ler_list', { headers })
    .then(response => {
      const rdLerMapping = response.data;
      console.log(`Found ${rdLerMapping.length} disposal methods:`);

      rdLerMapping.forEach(disposal => {
        console.log(`\n${disposal.rd_code} - ${disposal.rd_name}`);
        console.log(`  Applicable to ${disposal.ler_list.length} waste types`);
        // Show first 3 waste types
        disposal.ler_list.slice(0, 3).forEach(ler => {
          console.log(`    - ${ler.ler_code}: ${ler.ler_name}`);
        });
      });
    })
    .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[
  {
    "rd_code": "D1",
    "rd_name": "Deposit into or onto land (e.g. landfill)",
    "ler_list": [
      {
        "ler_code": "01 01 01",
        "ler_name": "Wastes from mineral metalliferous excavation"
      },
      {
        "ler_code": "01 01 02",
        "ler_name": "Wastes from mineral non-metalliferous excavation"
      },
      {
        "ler_code": "02 01 01",
        "ler_name": "Sludges from washing and cleaning"
      }
    ]
  },
  {
    "rd_code": "D5",
    "rd_name": "Specially engineered landfill",
    "ler_list": [
      {
        "ler_code": "17 05 03*",
        "ler_name": "Soil and stones containing dangerous substances"
      },
      {
        "ler_code": "17 05 05*",
        "ler_name": "Dredging spoil containing dangerous substances"
      }
    ]
  },
  {
    "rd_code": "R1",
    "rd_name": "Use principally as a fuel or other means to generate energy",
    "ler_list": [
      {
        "ler_code": "19 12 10",
        "ler_name": "Combustible waste (refuse derived fuel)"
      },
      {
        "ler_code": "03 01 01",
        "ler_name": "Waste bark and cork"
      }
    ]
  },
  {
    "rd_code": "R3",
    "rd_name": "Recycling/reclamation of organic substances",
    "ler_list": [
      {
        "ler_code": "02 01 06",
        "ler_name": "Animal faeces, urine and manure"
      },
      {
        "ler_code": "02 03 01",
        "ler_name": "Sludges from washing, cleaning, peeling, centrifuging and separation"
      }
    ]
  }
]
```

## GET /api/v1/wastes/low\_codes

Get waste type codes (LOW codes) for a specific region. These codes are used when creating waste records to classify the type of waste being disposed.

### Request

#### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `ff4adcc7-8172-45fe-9cf1-e90a6de53aa9`
</ParamField>

<ParamField header="x-user-id" type="string" required>
  Your user UUID

  **Example:** `a1b2c3d4-e5f6-7890-abcd-ef1234567890`
</ParamField>

#### Query Parameters

<ParamField query="waste_region" type="string" required>
  Region code for waste classification

  **Common values:**

  * `ES` - Spain
  * `EU` - European Union (generic)
  * `UK` - United Kingdom
  * Other ISO 3166-1 alpha-2 codes

  **Example:** `"ES"`
</ParamField>

### Response

<ResponseField name="[]" type="array">
  Array of LOW (waste type) code objects

  <ResponseField name="low_id" type="string">
    Unique waste type identifier (UUID)
  </ResponseField>

  <ResponseField name="low_code" type="string">
    Waste type code (6-digit format: XX XX XX)

    **Examples:** `"01 01 01"`, `"15 01 01"`, `"20 01 01"`
  </ResponseField>

  <ResponseField name="low_name" type="string">
    Waste type description

    **Examples:** `"Paper and cardboard"`, `"Plastic packaging"`, `"Mixed municipal waste"`
  </ResponseField>
</ResponseField>

### Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/api/v1/wastes/low_codes?waste_region=ES" \
    -H "Authorization: Bearer ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "x-user-id: ${DCYCLE_USER_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  api_key = os.getenv("DCYCLE_API_KEY")
  org_id = os.getenv("DCYCLE_ORG_ID")
  user_id = os.getenv("DCYCLE_USER_ID")

  headers = {
      "Authorization": f"Bearer {api_key}",
      "x-organization-id": org_id,
      "x-user-id": user_id
  }

  # Get Spanish waste codes
  params = {"waste_region": "ES"}

  response = requests.get(
      "https://api.dcycle.io/api/v1/wastes/low_codes",
      headers=headers,
      params=params
  )

  low_codes = response.json()
  print(f"Found {len(low_codes)} waste type codes for Spain:")

  # Group by first 2 digits (waste category)
  categories = {}
  for waste in low_codes:
      category = waste['low_code'][:2]
      if category not in categories:
          categories[category] = []
      categories[category].append(waste)

  # Display waste categories
  for category, wastes in sorted(categories.items()):
      print(f"\nCategory {category}: {len(wastes)} waste types")
      for waste in wastes[:3]:  # Show first 3
          print(f"  - {waste['low_code']}: {waste['low_name']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const apiKey = process.env.DCYCLE_API_KEY;
  const orgId = process.env.DCYCLE_ORG_ID;
  const userId = process.env.DCYCLE_USER_ID;

  const headers = {
    'Authorization': `Bearer ${apiKey}`,
    'x-organization-id': orgId,
    'x-user-id': userId
  };

  // Get Spanish waste codes
  const params = { waste_region: 'ES' };

  axios.get('https://api.dcycle.io/api/v1/wastes/low_codes', { headers, params })
    .then(response => {
      const lowCodes = response.data;
      console.log(`Found ${lowCodes.length} waste type codes for Spain:`);

      // Group by first 2 digits (waste category)
      const categories = {};
      lowCodes.forEach(waste => {
        const category = waste.low_code.substring(0, 2);
        if (!categories[category]) {
          categories[category] = [];
        }
        categories[category].push(waste);
      });

      // Display waste categories
      Object.keys(categories).sort().forEach(category => {
        const wastes = categories[category];
        console.log(`\nCategory ${category}: ${wastes.length} waste types`);
        wastes.slice(0, 3).forEach(waste => {
          console.log(`  - ${waste.low_code}: ${waste.low_name}`);
        });
      });
    })
    .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
[
  {
    "low_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "low_code": "15 01 01",
    "low_name": "Paper and cardboard packaging"
  },
  {
    "low_id": "b2c3d4e5-f6g7-8901-bcde-fg2345678901",
    "low_code": "15 01 02",
    "low_name": "Plastic packaging"
  },
  {
    "low_id": "c3d4e5f6-g7h8-9012-cdef-gh3456789012",
    "low_code": "15 01 03",
    "low_name": "Wooden packaging"
  },
  {
    "low_id": "d4e5f6g7-h8i9-0123-defg-hi4567890123",
    "low_code": "15 01 04",
    "low_name": "Metallic packaging"
  },
  {
    "low_id": "e5f6g7h8-i9j0-1234-efgh-ij5678901234",
    "low_code": "15 01 05",
    "low_name": "Composite packaging"
  },
  {
    "low_id": "f6g7h8i9-j0k1-2345-fghi-jk6789012345",
    "low_code": "20 01 01",
    "low_name": "Paper and cardboard (municipal waste)"
  },
  {
    "low_id": "g7h8i9j0-k1l2-3456-ghij-kl7890123456",
    "low_code": "20 01 39",
    "low_name": "Plastics (municipal waste)"
  }
]
```

## Common Errors

### 400 Bad Request - Missing waste\_region

**Cause:** Field required

For `/api/v1/wastes/low_codes`:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Field required",
  "field": "waste_region"
}
```

**Solution:** Include the `waste_region` query parameter.

### 400 Bad Request - Invalid Region

**Cause:** Invalid region code

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Invalid region code",
  "code": "VALIDATION_ERROR"
}
```

**Solution:** Use a valid ISO 3166-1 alpha-2 country code.

### 403 Forbidden

**Cause:** Organization ID doesn't match your API key or user doesn't belong to organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Not authorized",
  "code": "FORBIDDEN"
}
```

**Solution:** Verify that `x-organization-id` matches your API key's organization.

## Use Cases

### Build Waste Type Selector

Create a dropdown selector for waste types:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
def get_waste_types_for_selector(region="ES"):
    """Get waste types organized by category"""

    response = requests.get(
        "https://api.dcycle.io/api/v1/wastes/low_codes",
        headers=headers,
        params={"waste_region": region}
    )

    waste_codes = response.json()

    # Organize by category (first 2 digits)
    categories = {}
    for waste in waste_codes:
        category_code = waste['low_code'][:2]
        category_name = get_category_name(category_code)

        if category_name not in categories:
            categories[category_name] = []

        categories[category_name].append({
            'id': waste['low_id'],
            'code': waste['low_code'],
            'name': waste['low_name']
        })

    return categories

def get_category_name(code):
    """Map category codes to names"""
    categories = {
        '01': 'Mining and quarrying wastes',
        '02': 'Agricultural wastes',
        '15': 'Packaging wastes',
        '16': 'Wastes not otherwise specified',
        '17': 'Construction and demolition wastes',
        '19': 'Waste treatment wastes',
        '20': 'Municipal wastes'
    }
    return categories.get(code, f'Category {code}')

# Usage
waste_types = get_waste_types_for_selector("ES")
print("Packaging Wastes:")
for waste in waste_types.get('Packaging wastes', []):
    print(f"  {waste['code']}: {waste['name']}")
```

### Find Applicable Disposal Methods

Find which disposal methods can be used for a specific waste type:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
def get_disposal_methods_for_waste(waste_ler_code):
    """Find applicable disposal methods for a waste type"""

    response = requests.get(
        "https://api.dcycle.io/api/v1/wastes/rd_ler_list",
        headers=headers
    )

    rd_ler_mapping = response.json()

    # Find disposal methods that accept this waste type
    applicable_methods = []
    for disposal in rd_ler_mapping:
        for ler in disposal['ler_list']:
            if ler['ler_code'] == waste_ler_code:
                applicable_methods.append({
                    'rd_code': disposal['rd_code'],
                    'rd_name': disposal['rd_name']
                })
                break

    if applicable_methods:
        print(f"Disposal methods for {waste_ler_code}:")
        for method in applicable_methods:
            print(f"  - {method['rd_code']}: {method['rd_name']}")
    else:
        print(f"No disposal methods found for {waste_ler_code}")

    return applicable_methods

# Example: Find disposal methods for plastic packaging
methods = get_disposal_methods_for_waste("15 01 02")
```

### Cache Waste Codes

Since waste codes don't change frequently, cache them:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from datetime import datetime, timedelta

class WasteCodesCache:
    def __init__(self, api_key, org_id, user_id):
        self.headers = {
            "Authorization": f"Bearer {api_key}",
            "x-organization-id": org_id,
            "x-user-id": user_id
        }
        self._low_codes_cache = {}
        self._rd_ler_cache = None
        self._cache_time = {}
        self.cache_duration = timedelta(days=7)  # Waste codes rarely change

    def get_low_codes(self, region):
        """Get LOW codes with caching"""

        if (region not in self._cache_time or
            datetime.now() - self._cache_time[region] > self.cache_duration):
            self._refresh_low_codes(region)

        return self._low_codes_cache.get(region, [])

    def _refresh_low_codes(self, region):
        """Refresh LOW codes cache"""

        response = requests.get(
            "https://api.dcycle.io/api/v1/wastes/low_codes",
            headers=self.headers,
            params={"waste_region": region}
        )

        codes = response.json()
        self._low_codes_cache[region] = codes
        self._cache_time[region] = datetime.now()

        print(f"✅ LOW codes cache refreshed for {region}: {len(codes)} codes")

    def get_rd_ler_mapping(self):
        """Get RD-LER mapping with caching"""

        if (self._rd_ler_cache is None or
            datetime.now() - self._cache_time.get('rd_ler', datetime.min) > self.cache_duration):
            self._refresh_rd_ler_mapping()

        return self._rd_ler_cache

    def _refresh_rd_ler_mapping(self):
        """Refresh RD-LER mapping cache"""

        response = requests.get(
            "https://api.dcycle.io/api/v1/wastes/rd_ler_list",
            headers=self.headers
        )

        self._rd_ler_cache = response.json()
        self._cache_time['rd_ler'] = datetime.now()

        print(f"✅ RD-LER mapping cache refreshed: {len(self._rd_ler_cache)} methods")

    def get_low_code_by_id(self, low_id, region):
        """Get specific LOW code by ID"""

        codes = self.get_low_codes(region)
        for code in codes:
            if code['low_id'] == low_id:
                return code
        return None

    def search_low_codes(self, query, region):
        """Search LOW codes by name or code"""

        codes = self.get_low_codes(region)
        query_lower = query.lower()

        results = []
        for code in codes:
            if (query_lower in code['low_code'].lower() or
                query_lower in code['low_name'].lower()):
                results.append(code)

        return results

# Usage
cache = WasteCodesCache(
    api_key=os.getenv("DCYCLE_API_KEY"),
    org_id=os.getenv("DCYCLE_ORG_ID"),
    user_id=os.getenv("DCYCLE_USER_ID")
)

# Search for plastic-related waste codes
plastic_wastes = cache.search_low_codes("plastic", "ES")
print(f"Found {len(plastic_wastes)} plastic waste codes")
```

### Validate Waste Code Before Creating Waste

Ensure the waste code exists before creating a waste record:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
def validate_waste_code(low_code, region):
    """Validate that a waste code exists in the region"""

    response = requests.get(
        "https://api.dcycle.io/api/v1/wastes/low_codes",
        headers=headers,
        params={"waste_region": region}
    )

    waste_codes = response.json()

    # Check if code exists
    for waste in waste_codes:
        if waste['low_code'] == low_code:
            return waste['low_id']

    raise ValueError(f"Waste code '{low_code}' not found in region '{region}'")

# Usage
try:
    low_id = validate_waste_code("15 01 02", "ES")
    print(f"✅ Valid waste code, LOW ID: {low_id}")
except ValueError as e:
    print(f"❌ {e}")
```

## Waste Code Categories

### LER Code Structure

LER codes follow a 6-digit hierarchical structure: **XX XX XX**

* **First 2 digits**: Waste source/activity
* **Middle 2 digits**: Process within activity
* **Last 2 digits**: Specific waste type

**Example:** `15 01 02`

* `15` - Waste packaging materials
* `01` - Packaging
* `02` - Plastic packaging

### Common LER Categories

| Code Range | Category                   | Examples                      |
| ---------- | -------------------------- | ----------------------------- |
| `01 XX XX` | Mining and quarrying       | Tailings, excavation waste    |
| `02 XX XX` | Agriculture, forestry      | Organic waste, packaging      |
| `15 XX XX` | Packaging                  | Paper, plastic, metal, glass  |
| `16 XX XX` | Not otherwise specified    | Batteries, electronics        |
| `17 XX XX` | Construction & demolition  | Concrete, wood, metal         |
| `19 XX XX` | Waste treatment facilities | Residues, sludges             |
| `20 XX XX` | Municipal waste            | Household waste, garden waste |

### Hazardous Waste Codes

Codes ending with an asterisk (\*) indicate **hazardous waste**:

* `17 05 03*` - Soil containing dangerous substances
* `16 06 01*` - Lead batteries
* `15 01 10*` - Packaging containing hazardous residues

<Warning>
  Hazardous waste requires special handling, disposal methods, and documentation. Check your local regulations.
</Warning>

## Disposal Method Codes (RD)

### D Codes (Disposal Operations)

| Code  | Description                   |
| ----- | ----------------------------- |
| `D1`  | Landfill deposit              |
| `D5`  | Specially engineered landfill |
| `D10` | Incineration on land          |
| `D13` | Blending before disposal      |
| `D15` | Storage pending disposal      |

### R Codes (Recovery Operations)

| Code  | Description                   |
| ----- | ----------------------------- |
| `R1`  | Energy recovery / fuel use    |
| `R3`  | Organic substance recycling   |
| `R4`  | Metal recycling               |
| `R5`  | Inorganic material recycling  |
| `R12` | Pre-treatment before recovery |
| `R13` | Storage pending recovery      |

## Best Practices

### 1. Cache Reference Data

Waste codes rarely change, so cache them for extended periods:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Good - Cache for 7 days
cache = WasteCodesCache()
codes = cache.get_low_codes("ES")

# Bad - Fetch every time
codes = requests.get("https://api.dcycle.io/api/v1/wastes/low_codes?waste_region=ES")
```

### 2. Use Region-Specific Codes

Always filter by the correct region:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Good - Use facility's region
facility_region = "ES"
codes = get_low_codes(waste_region=facility_region)

# Bad - Use wrong region
codes = get_low_codes(waste_region="US")  # Wrong region for Spanish facility
```

### 3. Store LOW IDs, Not Codes

When creating waste records, use the `low_id`, not the `low_code`:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# Good - Use UUID
waste_data = {
    "low_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    # ... other fields
}

# Bad - Use code string (won't work)
waste_data = {
    "low_code": "15 01 02",  # API expects low_id
    # ... other fields
}
```

### 4. Validate Before Creating Waste

Always validate that the waste code exists before submitting:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
def create_waste_safely(low_code, region, quantity, **kwargs):
    # 1. Validate code exists
    low_id = validate_waste_code(low_code, region)

    # 2. Create waste with validated ID
    waste_data = {
        "low_id": low_id,
        "quantity": quantity,
        **kwargs
    }

    response = requests.post(
        "https://api.dcycle.io/api/v1/wastes",
        headers=headers,
        json=waste_data
    )

    return response.json()
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Facilities" icon="building" href="/api-docs/facilities/list">
    View facilities where waste is generated
  </Card>

  <Card title="List Units" icon="ruler" href="/api-docs/units/list">
    Get units for waste quantities
  </Card>

  <Card title="List Invoices" icon="file-invoice" href="/api-docs/invoices/list">
    View facility consumption data
  </Card>

  <Card title="Authentication" icon="key" href="/api-docs/authentication">
    Learn about API authentication
  </Card>
</CardGroup>
