# Carbon Footprint API - CO2 Calculator, Official Factors (`martin10291/carbon-footprint-api`) Actor

No API key. CO2e emissions calculator on the official UK government (DESNZ) conversion factors 2023-2026: flights by IATA code (haul, cabin class, radiative forcing, +8% routing uplift), cars by size/segment and fuel incl. EV and hybrid, fuels by litre/kWh/tonne/gallon, UK electricity with grid loss

- **URL**: https://apify.com/martin10291/carbon-footprint-api.md
- **Developed by:** [Martin Petrov](https://apify.com/martin10291) (community)
- **Categories:** Developer tools, Automation, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Carbon Footprint API - CO2 Calculator, Official Factors

**No API key. Problem:** your travel app, logistics tool, checkout CO2 label, ESG report or AI agent needs a CO2 number it can defend. Most carbon APIs return one number from undisclosed factors, so an auditor cannot trace it. Building it yourself means reading the 2,600-row government factor spreadsheet every June, mapping flight hauls and cabin classes, and keeping last year's set for the old report.

**This API:** one JSON call turns activities into kg CO2e with the **official UK government (DESNZ) conversion factors 2023, 2024, 2025 and 2026**, the set most companies use for GHG Protocol and SECR reports. Every answer shows the factor ID, the factor path, its year, the Scope 1/2/3 split and the CO2 / CH4 / N2O split.

- **Flights:** IATA codes (`LHR` -> `JFK`): great-circle distance + 8% DESNZ routing uplift, haul (domestic, short, long, international), cabin class, passengers, round trip, radiative forcing on/off.
- **Cars:** by size or market segment, petrol, diesel, hybrid, plug-in hybrid, electric, LPG, CNG. Business travel (Scope 3) or `owned: true` company car (Scope 1 fuel + Scope 2 charging + grid losses).
- **Fuels:** diesel, petrol, natural gas, LPG, propane, heating oil, coal, jet fuel, wood pellets... in litres, kWh (gross or net), tonnes, kg, m3, US gallons.
- **Electricity:** UK grid (location-based Scope 2) + transmission losses (Scope 3).
- **Hotels:** room nights in 40 countries. **Rail, bus, coach, tram, metro, taxi, motorbike, ferry.**
- **Freight:** tonne-km by truck (rigid/artic, laden %, refrigerated), van, rail, container ship, bulk carrier, tanker, air (IATA codes).
- **Any of the 2,600 official factors** by `factorId` (find them with `mode: search`), plus optional well-to-tank (upstream) emissions.
- Up to 100 activities per call, < 50 ms per call, optional total row.

### Example (API)

```bash
curl -X POST "https://api.apify.com/v2/acts/martin10291~carbon-footprint-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"activities": [{"type": "flight", "from": "LHR", "to": "JFK", "cabin": "economy", "roundTrip": true},
                      {"type": "freight", "mode": "hgv", "distance": 500, "weightTonnes": 12}], "includeTotal": true}'
```

Output row (measured 2026-11-14, factor set 2026):

```json
{"type": "flight", "description": "LHR (London Heathrow Airport) -> JFK (John F. Kennedy International Airport), economy class, round trip, 1 passenger(s)",
 "activityAmount": 11966.05, "activityUnit": "passenger.km", "kgCO2e": 1400.5062, "tCO2e": 1.400506,
 "kgCO2": 1388.5402, "kgCH4asCO2e": 0.1197, "kgN2OasCO2e": 11.8464,
 "byScope": {"scope1": 0.0, "scope2": 0.0, "scope3": 1400.5062}, "factorYear": 2026,
 "components": [{"factorId": "21_316_3170_11", "scope": "Scope 3", "path": "Business travel- air > Flights > Long-haul, to/from UK > Economy class > With RF",
                 "factorUnit": "passenger.km", "kgCO2ePerUnit": 0.11704, "quantity": 11966.05, "kgCO2e": 1400.5062}],
 "greatCircleKm": 5539.8, "distanceKm": 5983.0, "haul": "Long-haul, to/from UK", "cabin": "Economy class", "radiativeForcing": true,
 "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", "licence": "Open Government Licence v3.0"}
```

More inputs:

- `{"activities": [{"type": "car", "distance": 120, "unit": "miles", "segment": "suv", "fuel": "phev", "owned": true}]}`
- `{"activities": [{"type": "fuel", "fuel": "natural gas", "amount": 12000, "unit": "kwh", "includeWellToTank": true}]}`
- `{"activities": [{"type": "hotel", "country": "JP", "nights": 4}, {"type": "rail", "distance": 300}]}`
- `{"activities": [{"type": "freight", "mode": "air", "from": "PVG", "to": "FRA", "weightKg": 500}]}`
- `{"mode": "search", "query": "refrigerant R410A"}` -> official factors with `factorId`, then `{"type": "factor", "factorId": "...", "amount": 2}`
- `{"mode": "categories"}` -> all 30 factor categories with Scope and units. `"year": 2024` -> last year's set for a 2024 report.

### Use from agents (MCP)

Add the Apify MCP server (`https://mcp.apify.com?tools=martin10291/carbon-footprint-api`) to Claude, Cursor or any MCP client and ask: "What is the CO2 footprint of a business-class return flight Sofia-London plus 3 hotel nights in the UK?".

### Schedule it

Set `onlyNew: true` and a `monitorId`, keep `year` on latest and schedule the actor monthly: a row comes back only when its official value changes (DESNZ publishes a new set each June), so your stored footprints stay current.

### Input

| Field | Meaning |
|---|---|
| `mode` | calculate (default), search, categories |
| `activities` | list of activities, each with `type` (flight, car, fuel, electricity, hotel, rail, bus, coach, tram, underground, taxi, motorbike, ferry, freight, factor) and its fields |
| `query`, `scope`, `limit` | for search |
| `year` | latest (2026), 2025, 2024, 2023 |
| `includeTotal` | add one total row |
| `onlyNew`, `monitorId` | monitor mode |

### Limits (honest)

- Factors are the UK government set. Flights, freight, fuels, cars and hotels are used worldwide in reports; the electricity factor is the UK grid only (other countries return a clear error instead of a wrong number).
- Car, bus and taxi factors reflect the UK fleet. Results are estimates for reporting, not measurements.

### Source and licence

Contains public sector information licensed under the Open Government Licence v3.0. Source: UK Department for Energy Security and Net Zero, "Greenhouse gas reporting: conversion factors" 2023-2026 (gov.uk). Airport coordinates: OurAirports (public domain). Not affiliated with the UK government.

# Actor input Schema

## `mode` (type: `string`):

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.

## `activities` (type: `array`):

List of activities (max 100). Each object has a 'type': flight {from, to (IATA codes) or distanceKm, cabin: economy|premium_economy|business|first|average, passengers, roundTrip, radiativeForcing (default true)}; car {distance, unit: km|miles, size: small|medium|large|average or segment: mini|supermini|lower_medium|upper_medium|executive|luxury|sports|suv|mpv, fuel: petrol|diesel|hybrid|phev|bev|cng|lpg|unknown, owned: true for company cars}; fuel {fuel: diesel|petrol|natural gas|lpg|propane|heating oil|coal|jet fuel|wood pellets..., amount, unit: litres|kWh|kwh_net|tonnes|kg|m3|gallons}; electricity {kwh} (UK grid); hotel {country: ISO code or name, nights, rooms}; rail/bus/coach/tram/underground {distance, passengers}; taxi {distance}; motorbike {distance, size}; ferry {distance, passengerType: foot|car}; freight {mode: hgv|hgv_refrigerated|van|rail|container_ship|bulk_carrier|general_cargo|tanker|air, weightTonnes or weightKg, distance or from/to IATA for air}; factor {factorId, amount} for any official factor from search. Optional per activity: includeWellToTank (adds upstream fuel Scope 3), year.

## `query` (type: `string`):

For mode=search: words that must all appear in the factor path, e.g. 'diesel litres', 'hotel japan', 'refrigerant R410A', 'waste landfill'.

## `scope` (type: `string`):

For mode=search: only factors of this GHG Protocol scope. Empty = all scopes.

## `year` (type: `string`):

Which official DESNZ factor set to use. latest = the newest published set (2026). Use an older year to match last year's report.

## `includeTotal` (type: `boolean`):

For mode=calculate with 2+ activities: add one extra row with the total kgCO2e and the Scope 1/2/3 split of all activities.

## `limit` (type: `integer`):

For mode=search: maximum number of factors returned.

## `onlyNew` (type: `boolean`):

Monitor mode: return only activities/factors whose result is new or changed since the last run with the same Monitor ID (for example when DESNZ publishes a new factor set each June).

## `monitorId` (type: `string`):

Name of the saved state used by 'Only new or changed results'. Use one ID per scheduled report.

## Actor input object example

```json
{
  "mode": "calculate",
  "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",
      "country": "DE",
      "nights": 3
    }
  ],
  "year": "latest",
  "includeTotal": false,
  "limit": 50,
  "onlyNew": false
}
```

# Actor output Schema

## `results` (type: `string`):

Calculate: one row per activity with kgCO2e, tCO2e, Scope 1/2/3 split, CO2/CH4/N2O split, every official factor used (ID, path, unit, value, quantity), distance, notes, source and OGL attribution. Search: one row per official factor. Categories: one row per factor category.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "calculate",
    "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",
            "country": "DE",
            "nights": 3
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("martin10291/carbon-footprint-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "calculate",
    "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",
            "country": "DE",
            "nights": 3,
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("martin10291/carbon-footprint-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "calculate",
  "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",
      "country": "DE",
      "nights": 3
    }
  ]
}' |
apify call martin10291/carbon-footprint-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,martin10291/carbon-footprint-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qhyjEf94moYTLVLe1/builds/l3LsARgJEnqtXuERg/openapi.json
