apyhub
Back
▣ MODEL KIT · RETRIEVAL KIT

Calculate Carbon Footprint API

What it does

The Carbon Footprint API turns business activities into CO2e using the official UK government conversion factors from DESNZ (formerly published by DEFRA). Send a list of activities and get one result row per activity, in kgCO2e and tCO2e.

Each activity has a type. Travel types are flight, car, rail, bus, taxi, motorbike and ferry. The others are electricity, fuel, hotel, freight and factor for any official factor ID. For a flight, send from and to airport codes. The API works out the distance and adds the 8% uplift DESNZ recommends. For a car, send distance with size and fuel. Set owned to true for company cars so they count as Scope 1.

Every row shows the factor used, its factor ID and the split across Scope 1, 2 and 3. Set includeTotal to add a total row for the whole list. Use year to pick a factor set from 2023 to 2026, so last year's report stays consistent.

Two more modes help you map data. search finds official emission factors by words, such as "diesel litres" or "hotel japan". categories lists every factor category with its scope and units.

Teams use the Carbon Footprint API for GHG Protocol reporting, business travel emissions, carbon dashboards and CO2 emissions calculators in their own apps.

The Invoice Data Extraction API can pull kWh and litres from supplier bills. Show the Scope split with the Donut Chart API and export a report with the HTML to PDF API.

POST
Calculate Carbon Footprint
https://api.eu.apyhub.com/martin10291/carbon-footprint-api

QUICKSTART

GUIDE

Quickstart

Calculate emissions for a flight, a car trip, office electricity and a hotel stay with the latest DESNZ factors.

curl -X POST "https://api.eu.apyhub.com/martin10291/carbon-footprint-api" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "calculate",
    "includeTotal": true,
    "activities": [
      { "type": "flight", "from": "LHR", "to": "JFK", "cabin": "economy", "roundTrip": true },
      { "type": "car", "distance": 120, "unit": "km", "size": "medium", "fuel": "petrol" },
      { "type": "electricity", "kwh": 1000 },
      { "type": "hotel", "nights": 3, "country": "DE" }
    ]
  }'

What you'll get back

One row per activity plus a total row. The flight row is shown in full; the other rows are shortened.

{
  "count": 5,
  "items": [
    {
      "index": 0,
      "type": "flight",
      "description": "LHR (London Heathrow Airport) -> JFK (John F. Kennedy International Airport), economy class, round trip, 1 passenger(s)",
      "input": { "type": "flight", "from": "LHR", "to": "JFK", "cabin": "economy", "roundTrip": true },
      "kgCO2e": 1400.5062,
      "tCO2e": 1.400506,
      "kgCO2": 1388.5402,
      "kgCH4asCO2e": 0.1197,
      "kgN2OasCO2e": 11.8464,
      "byScope": { "scope1": 0, "scope2": 0, "scope3": 1400.5062 },
      "activityAmount": 11966.0479,
      "activityUnit": "passenger.km",
      "components": [
        {
          "factorId": "21_316_3170_11",
          "path": "Business travel- air > Flights > Long-haul, to/from UK > Economy class > With RF",
          "category": "Business travel- air",
          "scope": "Scope 3",
          "factorUnit": "passenger.km",
          "kgCO2ePerUnit": 0.11704,
          "quantity": 11966.047899,
          "kgCO2e": 1400.5062
        }
      ],
      "from": "LHR",
      "to": "JFK",
      "greatCircleKm": 5539.8,
      "distanceKm": 5983,
      "haul": "Long-haul, to/from UK",
      "cabin": "Economy class",
      "passengers": 1,
      "roundTrip": true,
      "radiativeForcing": true,
      "includesWellToTank": false,
      "factorYear": 2026,
      "notes": [
        "Great-circle distance 5540 km + 8% DESNZ uplift = 5983 km.",
        "Includes radiative forcing (non-CO2 climate effects of aviation), as DESNZ recommends."
      ],
      "source": "UK DESNZ Greenhouse gas reporting: conversion factors 2026",
      "sourceUrl": "https://www.gov.uk/government/collections/government-conversion-factors-for-company-reporting",
      "licence": "Open Government Licence v3.0",
      "attribution": "Contains public sector information licensed under the Open Government Licence v3.0. Source: UK Department for Energy Security and Net Zero (DESNZ), Greenhouse gas reporting: conversion factors."
    },
    { "index": 1, "type": "car", "description": "120.0 km medium car, petrol", "kgCO2e": 20.8932, "byScope": { "scope1": 0, "scope2": 0, "scope3": 20.8932 } },
    { "index": 2, "type": "electricity", "description": "1000 kWh UK grid electricity", "kgCO2e": 143.95, "byScope": { "scope1": 0, "scope2": 130.96, "scope3": 12.99 } },
    { "index": 3, "type": "hotel", "description": "3 night(s) x 1 room(s), hotel in Germany", "kgCO2e": 39.6, "byScope": { "scope1": 0, "scope2": 0, "scope3": 39.6 } },
    { "type": "total", "description": "Total of 4 activities", "kgCO2e": 1604.9494, "tCO2e": 1.604949, "byScope": { "scope1": 0, "scope2": 130.96, "scope3": 1473.9894 }, "errors": 0, "factorYear": 2026 }
  ]
}

Find a factor ID for anything not covered by an activity type:

{ "mode": "search", "query": "diesel litres", "limit": 5 }
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body
calculate = CO2e of your activities (one result row per activity); search = find official DESNZ factors by words (e.g. 'diesel litres', 'container ship', 'hotel japan') and get their factorId; categories = all factor categories with Scope, count and units.
Which official DESNZ factor set to use. latest = the newest published set (2026). Use an older year to match last year's report.
For mode=search: maximum number of factors returned.

About this endpoint

What it does

Calculate greenhouse gas emissions (CO2e) for business activities with the official UK DESNZ conversion factors. One endpoint has three modes, set with mode:

  • calculate (default): send activities and get one result row per activity.
  • search: find official factors by words and get their factorId.
  • categories: list every factor category with its scope and units.

Request Body

ParameterTypeMandatoryDescription
modeStringNocalculate, search or categories. Default: calculate.
yearStringNoDESNZ factor set: latest, 2026, 2025, 2024 or 2023. Default: latest (currently 2026).
activitiesObject ArrayYes, for calculateActivities to calculate. Maximum 100 per call. Each object needs a type. See the activity types below.
includeTotalBooleanNoFor calculate: add a final row with type: "total" that sums all activities by scope. Default: false.
queryStringYes, for searchWords that must all appear in the factor path, e.g. diesel litres, hotel japan, refrigerant R410A, waste landfill.
scopeStringNoFor search: only factors of this GHG Protocol scope, 1, 2 or 3. Empty = all scopes.
limitIntegerNoFor search: maximum factors returned. Default: 20. Range: 1 to 100.

Activity types

Distances use distance with unit (km or miles, default km).

typeFieldsNotes
flightfrom, to (IATA airport codes) or distance / distanceKm; cabin (economy, premium_economy, business, first, average; default economy); passengers (default 1); roundTrip (default false); radiativeForcing (default true)With airport codes, the great-circle distance gets the 8% uplift DESNZ recommends. Short-haul has no first or premium factor, so those cabins use the nearest DESNZ class. Scope 3.
cardistance, unit; size (small, medium, large, average); fuel (petrol, diesel, hybrid, phev, bev, cng, lpg, unknown); ownedDefault: average size, unknown fuel, Scope 3 business travel. owned: true counts a company car as Scope 1 (fuel) and Scope 2 (charging).
fuelfuel (e.g. diesel, petrol, natural gas, lpg, heating oil, coal, jet fuel); amount; unit (litres, kWh, kWh_net, tonnes, kg, m3, gallons)Scope 1.
electricitykwhUK grid only (location-based). Adds transmission and distribution losses as Scope 3. For other grids, use type: "factor" with a supplier factor. Scope 2.
hotelnights (default 1), rooms (default 1), country (default UK)Countries without a DESNZ hotel factor return 400 with the list of supported countries. Scope 3.
raildistance, unit; mode (national_rail, international_rail, tram, underground, bus, london_bus, coach); passengersDefault: national rail. Scope 3.
busdistance, unit; mode (same values as rail)Default: average local bus. Scope 3.
taxi, motorbike, ferrydistance, unitAverage DESNZ factor for each. Scope 3.
freightdistance, unit, weightTonnes; mode (hgv, hgv_refrigerated, van, rail, container_ship, bulk_carrier, general_cargo, reefer_ship, roro, tanker, air)Default: average laden non-refrigerated HGV. Scope 3.
factorfactorId (from search), amountApplies any official factor directly. Each search result includes a ready-made useWith object.

Add includeWellToTank: true to an activity to add the upstream well-to-tank factor as Scope 3.

Invalid input returns 400 with an invalid_input error that names the activity and field, e.g. an unknown airport code, a negative distance, an unknown type or more than 100 activities.

Response

ParameterTypeMandatoryDescription
countIntegerYesNumber of rows in items.
itemsObject ArrayYesResult rows. The fields depend on mode, see below.

calculate rows

FieldTypeDescription
indexNumberPosition of the activity in your request.
typeStringActivity type. The total row has total.
descriptionStringPlain-language summary of what was calculated.
inputObjectThe activity exactly as you sent it.
kgCO2eNumberEmissions in kg CO2e.
tCO2eNumberEmissions in tonnes CO2e.
kgCO2Number or nullCO2 part, in kg.
kgCH4asCO2eNumber or nullMethane part, in kg CO2e.
kgN2OasCO2eNumber or nullNitrous oxide part, in kg CO2e.
byScopeObjectscope1, scope2 and scope3 in kg CO2e.
activityAmountNumberQuantity the factor was applied to.
activityUnitStringUnit of that quantity, e.g. passenger.km, kWh, room.night.
componentsObject ArrayEach factor applied: factorId, path, category, scope, factorUnit, kgCO2ePerUnit, quantity, kgCO2e.
includesWellToTankBooleanWhether well-to-tank emissions were added.
factorYearNumberDESNZ factor set used.
notesString ArrayHow the result was worked out, e.g. distance uplift or scope choice.
sourceStringName of the DESNZ publication.
sourceUrlStringLink to the DESNZ conversion factors collection.
licenceStringOpen Government Licence v3.0.
attributionStringAttribution text required by the licence.
distanceKmNumberDistance used, for distance-based types.
from, toStringFlight airport codes.
greatCircleKmNumberFlight great-circle distance before the uplift.
haulStringDESNZ flight band, e.g. Long-haul, to/from UK.
cabinStringDESNZ cabin class used.
passengersNumberFlight passengers.
roundTripBooleanWhether the flight was doubled for a return trip.
radiativeForcingBooleanWhether non-CO2 aviation effects are included.

The total row (includeTotal: true) has type, description, kgCO2e, tCO2e, byScope, factorYear, errors and attribution.

search rows

FieldTypeDescription
factorIdStringID to use with type: "factor".
pathStringFull DESNZ factor path.
categoryStringFactor category.
scopeStringGHG Protocol scope.
unitStringUnit the factor applies to.
kgCO2ePerUnitNumberkg CO2e per unit.
kgCO2PerUnit, kgCH4asCO2ePerUnit, kgN2OasCO2ePerUnitNumberGas breakdown per unit.
factorYearNumberDESNZ factor set.
useWithObjectReady-to-send activity, e.g. {"type": "factor", "factorId": "1_101_1011_8", "amount": 1}.
type, licence, attributionStringfactor, licence name and attribution text.

categories rows

FieldTypeDescription
categoryStringCategory name, e.g. Fuels.
scopeStringGHG Protocol scope.
factorsNumberNumber of factors in the category.
unitsString ArrayUnits used by its factors.
examplesString ArrayA few example factor names.
factorYearNumberDESNZ factor set.
typeStringAlways category.

Factors: UK Department for Energy Security and Net Zero (DESNZ), Greenhouse gas reporting: conversion factors, licensed under the Open Government Licence v3.0.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.