# Website Carbon

> Estimate the carbon emissions of web pages with Website Carbon's keyless API, from Wholegrain Digital (the service behind websitecarbon.com). Turn a page's weight and its hosting into the CO2e a visit costs, its Digital Carbon Rating from A+ to F, and the yearly footprint at real traffic; compare pages against each other, weigh up green hosting, size up a file download or a month of CDN traffic, and fail a build when a page goes over its carbon budget. No account or API key required.

App · Analytics · 6 actions. Web page: https://docs.lodol.com/docs/integrations/website-carbon

## Actions

### Check carbon budget

Test a page against a carbon budget, a minimum Digital Carbon Rating, or both, and get a plain pass or fail to branch on, for a build step, a release check, or a scheduled audit that should raise an alert when a page gets heavier. Set at least one of the two: with neither filled in there is nothing to check. When a gram budget is set, the result also says what page weight would meet it and how many bytes the page is over.

**Inputs**

- Page weight (bytes) (`bytes`, number, required): How many bytes the page transfers when it loads. Take this from a browser's network panel, a Lighthouse or PageSpeed report, or a CDN log; 1 MB is 1,000,000 bytes. From 1 to 1000000000000000.
- Green hosting (`green`, true/false, required): Whether the page is served from a host running on renewable energy. Green hosting cuts the emissions of the same page by roughly a fifth, so set it deliberately; the Green Web Foundation's checker at thegreenwebfoundation.org/green-web-check will tell you which a domain is. Leave it off if you don't know. Default: `false`.
- Budget (grams of CO2e per visit) (`max_grams_per_view`, number): The most CO2e a single visit may cost, in grams. Around 0.5 g is a typical page; 0.1 g is a demanding target. Leave empty to check the rating only. At least 0.
- Minimum rating (`min_rating`, text): The worst Digital Carbon Rating the page may have and still pass, where A+ is the cleanest and F the heaviest. Leave empty to check the gram budget only. One of: `A+`, `A`, `B`, `C`, `D`, `E`, `F`.

**Outputs**

- `bytes` (number)
- `checks` (object)
- `cleaner_than` (number)
- `cleaner_than_percent` (number)
- `grams_co2e` (number)
- `green_hosting` (true/false)
- `kilobytes` (number)
- `kilograms_co2e_per_1000_views` (number)
- `megabytes` (number)
- `rating` (text)
- `rating_description` (text)
- `statistics` (object)
- `statistics_model` (text)
- `within_budget` (true/false)

**Example output**

```json
{
  "bytes": 1800000,
  "checks": {
    "carbon_budget": {
      "actual_grams_co2e": 0.18757190555334088,
      "bytes_over_budget": 840369,
      "estimated_byte_budget": 959631,
      "estimated_kilobyte_budget": 959.631,
      "headroom_grams_co2e": 0.0,
      "limit_grams_co2e": 0.1,
      "over_by_grams_co2e": 0.0875719,
      "reduction_needed_percent": 46.69,
      "within_budget": false
    },
    "rating": {
      "actual": "B",
      "bands_below_requirement": 0,
      "comparable": true,
      "meets_requirement": true,
      "required": "B"
    }
  },
  "cleaner_than": 0.8,
  "cleaner_than_percent": 80.0,
  "grams_co2e": 0.18757190555334088,
  "green_hosting": false,
  "kilobytes": 1800.0,
  "kilograms_co2e_per_1000_views": 0.187572,
  "megabytes": 1.8,
  "rating": "B",
  "rating_description": "Digital Carbon Rating B: band 3 of 7 on a scale where A+ is the cleanest and F the heaviest.",
  "statistics": {
    "adjusted_bytes": 1359000.0,
    "energy_kwh": 0.00037970021367073054,
    "grid_grams_co2e": 0.18757190555334088,
    "grid_litres_co2": 0.10432749386876819,
    "renewable_grams_co2e": 0.15318372286856177,
    "renewable_litres_co2": 0.08520078665949404
  },
  "statistics_model": "Current model",
  "within_budget": false
}
```

### Compare hosting options

Price the same page on green hosting and on ordinary grid-powered hosting, and get both sides in full (emissions, rating and percentile for each) plus what switching would save per visit and, if you give the traffic, per year. This is the case for moving a site to a renewable host, in the numbers a decision is made on.

**Inputs**

- Page weight (bytes) (`bytes`, number, required): How many bytes the page transfers when it loads. Take this from a browser's network panel, a Lighthouse or PageSpeed report, or a CDN log; 1 MB is 1,000,000 bytes. From 1 to 1000000000000000.
- Monthly page views (`monthly_page_views`, number): Optional. How many times the page is loaded in a typical month; supply it to get the yearly saving as well as the per-visit one. From 0 to 1000000000000.

**Outputs**

- `bytes` (number)
- `green_hosting` (object)
- `kilobytes` (number)
- `megabytes` (number)
- `savings` (object)
- `standard_hosting` (object)

**Example output**

```json
{
  "bytes": 1800000,
  "green_hosting": {
    "bytes": 1800000,
    "cleaner_than": 0.9,
    "cleaner_than_percent": 90.0,
    "grams_co2e": 0.15318372286856177,
    "green_hosting": true,
    "kilobytes": 1800.0,
    "kilograms_co2e_per_1000_views": 0.153184,
    "megabytes": 1.8,
    "rating": "A",
    "rating_description": "Digital Carbon Rating A: band 2 of 7 on a scale where A+ is the cleanest and F the heaviest.",
    "statistics": {
      "adjusted_bytes": 1359000.0,
      "energy_kwh": 0.00037970021367073054,
      "grid_grams_co2e": 0.18757190555334088,
      "grid_litres_co2": 0.10432749386876819,
      "renewable_grams_co2e": 0.15318372286856177,
      "renewable_litres_co2": 0.08520078665949404
    },
    "statistics_model": "Current model"
  },
  "kilobytes": 1800.0,
  "megabytes": 1.8,
  "savings": {
    "annual_kilograms_co2e_saved": 20.6329,
    "annual_tonnes_co2e_saved": 0.0206329,
    "grams_co2e_per_view": 0.0343882,
    "monthly_page_views": 50000,
    "percent_reduction": 18.33,
    "rating_change": "B \u2192 A",
    "rating_improves": true
  },
  "standard_hosting": {
    "bytes": 1800000,
    "cleaner_than": 0.8,
    "cleaner_than_percent": 80.0,
    "grams_co2e": 0.18757190555334088,
    "green_hosting": false,
    "kilobytes": 1800.0,
    "kilograms_co2e_per_1000_views": 0.187572,
    "megabytes": 1.8,
    "rating": "B",
    "rating_description": "Digital Carbon Rating B: band 3 of 7 on a scale where A+ is the cleanest and F the heaviest.",
    "statistics": {
      "adjusted_bytes": 1359000.0,
      "energy_kwh": 0.00037970021367073054,
      "grid_grams_co2e": 0.18757190555334088,
      "grid_litres_co2": 0.10432749386876819,
      "renewable_grams_co2e": 0.15318372286856177,
      "renewable_litres_co2": 0.08520078665949404
    },
    "statistics_model": "Current model"
  }
}
```

### Compare pages

Rank several pages by emissions, heaviest first, with each page's share of the total, to find which templates on a site are worth optimising, or to weigh a page against a competitor's. Give each page as the number of bytes it transfers; a URL will not do, because this API estimates from a page's weight rather than visiting it.

**Inputs**

- Pages (with the bytes each one transfers) (`pages`, list, required): One row per page. Each row needs the number of bytes that page transfers; a URL will not do, because this API estimates from a page's weight and cannot fetch the page to measure it. Naming a row and marking it as green-hosted are both optional. Up to 20 pages in one step.

**Outputs**

- `average_grams_co2e` (number)
- `highest_emissions` (object)
- `lowest_emissions` (object)
- `page_count` (number)
- `pages` (list)
- `total_bytes` (number)
- `total_grams_co2e` (number)
- `total_megabytes` (number)

**Example output**

```json
{
  "average_grams_co2e": 0.166325,
  "highest_emissions": {
    "bytes": 2900000,
    "grams_co2e": 0.2467959979549051,
    "green_hosting": true,
    "megabytes": 2.9,
    "name": "Pricing",
    "rating": "B"
  },
  "lowest_emissions": {
    "bytes": 620000,
    "grams_co2e": 0.06460810080170631,
    "green_hosting": false,
    "megabytes": 0.62,
    "name": "Blog post",
    "rating": "A+"
  },
  "page_count": 3,
  "pages": [
    {
      "bytes": 2900000,
      "cleaner_than": 0.8,
      "cleaner_than_percent": 80.0,
      "grams_co2e": 0.2467959979549051,
      "green_hosting": true,
      "kilobytes": 2900.0,
      "kilograms_co2e_per_1000_views": 0.246796,
      "megabytes": 2.9,
      "name": "Pricing",
      "rank": 1,
      "rating": "B",
      "rating_description": "Digital Carbon Rating B: band 3 of 7 on a scale where A+ is the cleanest and F the heaviest.",
      "share_of_total_percent": 49.46,
      "statistics": {
        "adjusted_bytes": 2189500.0,
        "energy_kwh": 0.000611739233136177,
        "grid_grams_co2e": 0.30219918116927147,
        "grid_litres_co2": 0.16808318456634874,
        "renewable_grams_co2e": 0.2467959979549051,
        "renewable_litres_co2": 0.1372679340625182
      },
      "statistics_model": "Current model"
    },
    {
      "bytes": 1800000,
      "cleaner_than": 0.8,
      "cleaner_than_percent": 80.0,
      "grams_co2e": 0.18757190555334088,
      "green_hosting": false,
      "kilobytes": 1800.0,
      "kilograms_co2e_per_1000_views": 0.187572,
      "megabytes": 1.8,
      "name": "Home",
      "rank": 2,
      "rating": "B",
      "rating_description": "Digital Carbon Rating B: band 3 of 7 on a scale where A+ is the cleanest and F the heaviest.",
      "share_of_total_percent": 37.59,
      "statistics": {
        "adjusted_bytes": 1359000.0,
        "energy_kwh": 0.00037970021367073054,
        "grid_grams_co2e": 0.18757190555334088,
        "grid_litres_co2": 0.10432749386876819,
        "renewable_grams_co2e": 0.15318372286856177,
        "renewable_litres_co2": 0.08520078665949404
      },
      "statistics_model": "Current model"
    },
    {
      "bytes": 620000,
      "cleaner_than": 0.95,
      "cleaner_than_percent": 95.0,
      "grams_co2e": 0.06460810080170631,
      "green_hosting": false,
      "kilobytes": 620.0,
      "kilograms_co2e_per_1000_views": 0.0646081,
      "megabytes": 0.62,
      "name": "Blog post",
      "rank": 3,
      "rating": "A+",
      "rating_description": "Digital Carbon Rating A+: band 1 of 7 on a scale where A+ is the cleanest and F the heaviest.",
      "share_of_total_percent": 12.95,
      "statistics": {
        "adjusted_bytes": 468100.0,
        "energy_kwh": 0.00013078562915325165,
        "grid_grams_co2e": 0.06460810080170631,
        "grid_litres_co2": 0.035935025665909046,
        "renewable_grams_co2e": 0.0527632823213935,
        "renewable_litres_co2": 0.02934693762715906
      },
      "statistics_model": "Current model"
    }
  ],
  "total_bytes": 5320000,
  "total_grams_co2e": 0.498976,
  "total_megabytes": 5.32
}
```

### Estimate annual emissions

Project a page's emissions across real traffic: give the page weight and how many times it is viewed in a month, and get the monthly and yearly totals in grams, kilograms and tonnes of CO2e, plus the volume of CO2 that represents and what green hosting would have saved over the year. A per-visit figure is too small to act on; this is the number a sustainability report or a reduction target is written against.

**Inputs**

- Page weight (bytes) (`bytes`, number, required): How many bytes the page transfers when it loads. Take this from a browser's network panel, a Lighthouse or PageSpeed report, or a CDN log; 1 MB is 1,000,000 bytes. From 1 to 1000000000000000.
- Green hosting (`green`, true/false, required): Whether the page is served from a host running on renewable energy. Green hosting cuts the emissions of the same page by roughly a fifth, so set it deliberately; the Green Web Foundation's checker at thegreenwebfoundation.org/green-web-check will tell you which a domain is. Leave it off if you don't know. Default: `false`.
- Monthly page views (`monthly_page_views`, number, required): How many times the page is loaded in a typical month. The API answers per single visit, and this turns that into the monthly and yearly figures a report or a target is written against. From 0 to 1000000000000.

**Outputs**

- `annual` (object)
- `annual_page_views` (number)
- `bytes` (number)
- `cleaner_than` (number)
- `cleaner_than_percent` (number)
- `grams_co2e` (number)
- `green_hosting` (true/false)
- `hosting_comparison` (object)
- `kilobytes` (number)
- `kilograms_co2e_per_1000_views` (number)
- `megabytes` (number)
- `monthly` (object)
- `monthly_page_views` (number)
- `per_1000_views` (object)
- `rating` (text)
- `rating_description` (text)
- `statistics` (object)
- `statistics_model` (text)

**Example output**

```json
{
  "annual": {
    "grams_co2e": 112543.0,
    "kilograms_co2e": 112.543,
    "litres_co2": 62596.5,
    "page_views": 600000,
    "tonnes_co2e": 0.112543
  },
  "annual_page_views": 600000,
  "bytes": 1800000,
  "cleaner_than": 0.8,
  "cleaner_than_percent": 80.0,
  "grams_co2e": 0.18757190555334088,
  "green_hosting": false,
  "hosting_comparison": {
    "annual_kilograms_co2e_on_green_hosting": 91.9102,
    "annual_kilograms_co2e_on_grid_hosting": 112.543,
    "annual_kilograms_co2e_saved_by_green_hosting": 20.6329
  },
  "kilobytes": 1800.0,
  "kilograms_co2e_per_1000_views": 0.187572,
  "megabytes": 1.8,
  "monthly": {
    "grams_co2e": 9378.6,
    "kilograms_co2e": 9.3786,
    "litres_co2": 5216.37,
    "page_views": 50000,
    "tonnes_co2e": 0.0093786
  },
  "monthly_page_views": 50000,
  "per_1000_views": {
    "grams_co2e": 187.572,
    "kilograms_co2e": 0.187572,
    "page_views": 1000,
    "tonnes_co2e": 0.000187572
  },
  "rating": "B",
  "rating_description": "Digital Carbon Rating B: band 3 of 7 on a scale where A+ is the cleanest and F the heaviest.",
  "statistics": {
    "adjusted_bytes": 1359000.0,
    "energy_kwh": 0.00037970021367073054,
    "grid_grams_co2e": 0.18757190555334088,
    "grid_litres_co2": 0.10432749386876819,
    "renewable_grams_co2e": 0.15318372286856177,
    "renewable_litres_co2": 0.08520078665949404
  },
  "statistics_model": "Current model"
}
```

### Estimate data transfer emissions

Estimate the emissions of moving data that is not a page: a file people download, a video stream, an email attachment, or a month of CDN traffic. Give the size in megabytes and how many times it is transferred. The page model assumes returning visitors have some of the bytes cached and discounts them; a download has no such discount, so that adjustment is taken back out here and the page-equivalent figure is returned alongside for comparison.

**Inputs**

- Size (MB) (`megabytes`, number, required): How large each transfer is, in megabytes (1 MB = 1,000,000 bytes). From 0 to 1000000000.
- Green hosting (`green`, true/false, required): Whether the page is served from a host running on renewable energy. Green hosting cuts the emissions of the same page by roughly a fifth, so set it deliberately; the Green Web Foundation's checker at thegreenwebfoundation.org/green-web-check will tell you which a domain is. Leave it off if you don't know. Default: `false`.
- Number of transfers (`transfers`, number): How many times the file is transferred (downloads, plays, or sends). Defaults to 1. From 1 to 1000000000000. Default: `1`.

**Outputs**

- `as_page_view` (object)
- `bytes` (number)
- `caching_adjustment_removed` (true/false)
- `gigabytes` (number)
- `grams_co2e_per_transfer` (number)
- `green_hosting` (true/false)
- `megabytes` (number)
- `returning_visitor_factor` (number)
- `statistics` (object)
- `total` (object)
- `transfers` (number)

**Example output**

```json
{
  "as_page_view": {
    "cleaner_than_percent": 7.0,
    "grams_co2e_per_view": 2.6051653549075127,
    "rating": "F"
  },
  "bytes": 25000000,
  "caching_adjustment_removed": true,
  "gigabytes": 0.025,
  "grams_co2e_per_transfer": 3.45055,
  "green_hosting": false,
  "megabytes": 25.0,
  "returning_visitor_factor": 1.3245,
  "statistics": {
    "adjusted_bytes": 18875000.0,
    "energy_kwh": 0.005273614078760146,
    "grid_grams_co2e": 2.6051653549075127,
    "grid_litres_co2": 1.448992970399558,
    "renewable_grams_co2e": 2.1275517065078025,
    "renewable_litres_co2": 1.1833442591596395
  },
  "total": {
    "grams_co2e": 34505.5,
    "kilograms_co2e": 34.5055,
    "tonnes_co2e": 0.0345055
  },
  "transfers": 10000
}
```

### Estimate page emissions

Estimate the carbon emissions of a single page load from the page's weight in bytes and whether it is on green hosting. Returns the grams of CO2e a visit costs, the page's Digital Carbon Rating from A+ to F, the percentage of measured pages it is cleaner than, and the energy and emissions behind those figures.

**Inputs**

- Page weight (bytes) (`bytes`, number, required): How many bytes the page transfers when it loads. Take this from a browser's network panel, a Lighthouse or PageSpeed report, or a CDN log; 1 MB is 1,000,000 bytes. From 1 to 1000000000000000.
- Green hosting (`green`, true/false, required): Whether the page is served from a host running on renewable energy. Green hosting cuts the emissions of the same page by roughly a fifth, so set it deliberately; the Green Web Foundation's checker at thegreenwebfoundation.org/green-web-check will tell you which a domain is. Leave it off if you don't know. Default: `false`.
- Calculation model (`legacy`, text): Leave empty. Set this only to reproduce a figure published under an older methodology; it changes the detailed statistics alone, and the headline emissions always use the current model. One of: `2` (Methodology used up to 19 April 2022), `3` (Methodology used up to July 2024).

**Outputs**

- `bytes` (number)
- `cleaner_than` (number)
- `cleaner_than_percent` (number)
- `grams_co2e` (number)
- `green_hosting` (true/false)
- `kilobytes` (number)
- `kilograms_co2e_per_1000_views` (number)
- `megabytes` (number)
- `rating` (text)
- `rating_description` (text)
- `statistics` (object)
- `statistics_model` (text)

**Example output**

```json
{
  "bytes": 12345678,
  "cleaner_than": 0.07,
  "cleaner_than_percent": 7.0,
  "grams_co2e": 1.0506427318758333,
  "green_hosting": true,
  "kilobytes": 12345.7,
  "kilograms_co2e_per_1000_views": 1.05064,
  "megabytes": 12.3457,
  "rating": "F",
  "rating_description": "Digital Carbon Rating F: band 7 of 7 on a scale where A+ is the cleanest and F the heaviest.",
  "statistics": {
    "adjusted_bytes": 9320986.89,
    "energy_kwh": 0.0026042536525055764,
    "grid_grams_co2e": 1.2865013043377547,
    "grid_litres_co2": 0.7155520254726591,
    "renewable_grams_co2e": 1.0506427318758333,
    "renewable_litres_co2": 0.5843674874693384
  },
  "statistics_model": "Current model"
}
```
