# Bus: DEFRA 🇬🇧

💡 **High-Level Description:**

DEFRA's methodology for calculating the carbon footprint of bus travel is based on standardized emission factors published by the UK government. These factors are derived from extensive national data sources and provide a reliable basis for estimating greenhouse gas emissions from different types of bus transportation.

DEFRA's methodology takes into account various bus categories, including local buses operating within and outside London, as well as long-distance coaches. Emissions are calculated based on factors such as fuel consumption, average occupancy rates, and energy efficiency. Additionally, DEFRA offers flexibility in emissions reporting by supporting two energy scopes: **Tank-to-Wheel (TTW)** and **Well-to-Wheel (WTW)**, with WTW being the default option for a more comprehensive lifecycle assessment.

By leveraging DEFRA's well-established reporting framework, businesses and policymakers can ensure consistent and transparent carbon accounting for bus travel, aligning with UK environmental reporting regulations and sustainability strategies. **Versioning:** Use `methodology_version` to pin the DEFRA **Conversion Factors** year (e.g., "2024"). If omitted, SQUAKE **uses the latest supported year**.

***

### **Sample API Requests**

#### A. Without audit mode (for pre-booking/quotes)

```json
{
  "expand": ["items"],
  "items": [
    {
      "audit": false,
      "type": "bus",
      "external_reference": "test_1",
      "origin": "London",
      "destination": "Bristol",
      "bus_type": "coach",
      "number_of_travelers": 3,
      "energy_scope": "wtw",
      "methodology": "DEFRA",
      "methodology_version": "2024"
    }
  ]
}
```

#### B. With audit mode (for finalized/post-booking calculations)

```json
{
  "expand": ["items"],
  "audit_for": "<Auditable Entity ID>",
  "items": [
    {
      "audit": true,
      "type": "bus",
      "external_reference": "test_1",
      "origin": "London",
      "destination": "Bristol",
      "bus_type": "coach",
      "number_of_travelers": 3,
      "energy_scope": "wtw",
      "methodology": "DEFRA",
      "methodology_version": "2024"
    }
  ]
}
```

> **Note:** `audit_for` is optional. Provide when calculating on behalf of a specific Auditable entity; otherwise omit.

***

### **API Request Items**

* `type`: `bus` **(required)**
* `methodology`: `DEFRA` **(required)**
* `methodology_version`: DEFRA Conversion Factors year (e.g., `2024`). **Optional**; if omitted → **latest supported year**.
* `external_reference`: Correlate response to request (max 128 chars).
* `number_of_travelers`: Minimum `1`. **Default:** `1`.
* `origin` / `destination`: Postal, IATA/ICAO, UN/LOCODE, or `lat,lon`.
* `distance_in_km`: If present, **overrides** origin/destination.
* `bus_type` (options):
  * `local_bus_not_london`
  * `local_bus_london`
  * `average_local_bus` *(default)*
  * `coach`
* `energy_scope`:
  * `wtw` *(default)* — well‑to‑wheel
  * `ttw` — tank‑to‑wheel
* `"audit"`: boolean (optional). Set to `true` to create immutable audit records for finalized calculations. Must be enabled for your account.

***

## Origin/Destination Formats (Enriched)

SQUAKE will try to resolve the `origin`/`destination` regardless of its format. Ideally:

* **Addresses:** Use the Post standard.
* **Airports:** Use IATA/ICAO code (regex: `^[A-Z]{3,4}$`, e.g., `MUC`).
* **Ports/Trade locations:** Use UN/LOCODE (regex: `^[A-Z]{2}\W?[A-Z2-9]{3}$`, e.g., `DEHAM`).
* **Coordinates:** Pass latitude/longitude (regex: `^[-+]?\d{1,3}\.\d{1,10}\s?,\s?[-+]?\d{1,3}\.\d{1,10}$`, e.g., `+40.712,-74.006`).

**Provider/Stop Codes for Buses**

* You can also reference **bus stops or stations** using provider-prefixed stop IDs:
  * Format: `<provider>:<stop_id>` (e.g., `flixbus:2006`).
* **Common provider prefixes:** `flixbus`, `distribusion`, `busbud`.

> If a value cannot be resolved, SQUAKE will **fallback to generic (non‑journey‑specific)** DEFRA bus factors.

**Examples**

```jsonc
// Using provider stop codes
{
  "type": "bus",
  "methodology": "DEFRA",
  "origin": "flixbus:london_victoria",
  "destination": "flixbus:bristol_bond_st",
  "bus_type": "coach",
  "number_of_travelers": 1,
  "energy_scope": "wtw",
  "methodology_version": "2024"
}

// Using UN/LOCODEs
{
  "type": "bus",
  "methodology": "DEFRA",
  "origin": "GBLON",
  "destination": "GBBRS",
  "bus_type": "coach",
  "number_of_travelers": 1
}

// Using coordinates
{
  "type": "bus",
  "methodology": "DEFRA",
  "origin": "+51.495,-0.144",
  "destination": "+51.455,-2.597",
  "bus_type": "coach",
  "number_of_travelers": 1
}
```

***

### **Default Values**

* `bus_type`: `average_local_bus`
* `energy_scope`: `wtw`
* `methodology_version`: latest supported DEFRA year

***

### **Sample API Response**

```json
{
  "carbon_quantity": 15240,
  "carbon_unit": "gram",
  "items": [
    {
      "carbon_quantity": 15240,
      "carbon_unit": "gram",
      "external_reference": "test_1",
      "type": "bus",
      "methodology": "DEFRA",
      "methodology_version": "2024",
      "bus_type": "coach",
      "energy_scope": "wtw",
      "distance": 190.0,
      "distance_unit": "kilometer"
    }
  ]
}
```

***

### **Versions**

* **Behavior:** If `methodology_version` is omitted, SQUAKE automatically applies the **latest supported** DEFRA Conversion Factors year. Pin a specific year for reproducibility and auditability.

***

### **Bibliography**

* UK Government — **Greenhouse Gas Emissions: Research & Statistics**: <https://www.gov.uk/environment/greenhouse-gas-emissions#research\\_and\\_statistics>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-integration.squake.earth/api-calculations-request-response/travel/bus/bus-defra.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
