Website Carbon Calculator API

Estimate CO2e per page view of a URL or byte count with the Sustainable Web Design model v4 (CO2.js): page weight, A+–F rating, yearly total, fixes.

GETPOSThttps://apibox.io.vn/v1/web-carbon

Give a url and the API loads the page like a first visit: the HTML, stylesheets, scripts, non-lazy images, preloads, icons, iframes and the web fonts referenced by same-site CSS (up to max_resources, default 40, max 80), and adds up the bytes sent over the network (Content-Length, or a gzip estimate for compressed responses without it). Or skip the crawl and send bytes yourself, e.g. the transfer size from DevTools, WebPageTest or har-tools.

Emissions use the Sustainable Web Design model version 4 as implemented by CO2.js (Green Web Foundation): energy per gigabyte for data centres, networks and user devices, operational plus embodied, multiplied by grid carbon intensity — the world average (494 g/kWh) by default, or a country's average with country=VN (or per segment: device_country, network_country, datacenter_country). The result is grams CO2e per view, the SWD digital carbon rating from A+ (≤ 0.040 g) to F (> 0.359 g), and monthly / yearly totals with views (per month). green=true applies the green-hosting factor when your host runs on verified renewable energy (check it at thegreenwebfoundation.org; the API does not look it up).

The page report lists bytes by type, third-party bytes, the largest files and concrete suggestions: oversized images, JPEG / PNG that could be WebP / AVIF, heavy web fonts, third-party and total JavaScript, text files served without compression. It is an estimate: only static HTML is read (no JavaScript execution), so tag managers, lazy-loaded content and video streams are not counted.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
urlquerystringyesPage to measure (or send bytes).
bytesquerynumbernoTransfer size in bytes instead of crawling a URL.
viewsquerynumbernoPage views per month: adds monthly and yearly kg CO2e.
greenquerybooleannofalsetrue when the site runs on verified green hosting.
countryquerystringnoGrid intensity of a country for all segments (ISO alpha-2 or alpha-3, e.g. VN); or device_country, network_country, datacenter_country.
max_resourcesquerynumberno40Maximum sub-resources fetched (0–80).
green_hosting_factorquerynumbernoAdvanced (0–1): share of data-centre energy that is renewable. Also first_visit_ratio, return_visit_ratio, data_reload_ratio.

Example

curl "https://apibox.io.vn/v1/web-carbon?bytes=2000000&views=10000&country=VN" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response

{
  "bytes": 2000000,
  "green_hosting": false,
  "green_hosting_source": "default (not green; pass green=true if your host is verified green, e.g. at thegreenwebfoundation.org)",
  "co2e_grams_per_view": 0.2933,
  "co2e_grams_per_page_load": 0.2933,
  "rating": "E",
  "rating_scale": {
    "A+": "≤ 0.040 g",
    "A": "≤ 0.079 g",
    "B": "≤ 0.145 g",
    "C": "≤ 0.209 g",
    "D": "≤ 0.278 g",
    "E": "≤ 0.359 g",
    "F": "> 0.359 g"
  },
  "views_per_month": 10000,
  "co2e_kg_per_month": 2.933,
  "co2e_kg_per_year": 35.196,
  "variables": {
    "grid_intensity_g_per_kwh": {
      "device": {
        "country": "VNM",
        "value": 486.13
      },
      "dataCenter": {
        "country": "VNM",
        "value": 486.13
      },
      "network": {
        "country": "VNM",
        "value": 486.13
      }
    },
    "first_visit_ratio": 1,
    "return_visit_ratio": 0,
    "data_reload_ratio": 0,
    "green_hosting_factor": 0
  },
  "model": "Sustainable Web Design model v4 (CO2.js 0.19 by the Green Web Foundation, Apache-2.0; grid intensity data from Ember, CC BY 4.0)",
  "disclaimer": "Estimate only: models average energy per byte; real emissions depend on networks, devices and hosting."
}

Use cases

  • Add page CO2e and an A+–F rating to ESG or sustainability reports
  • Compare a redesign against the old site before launch
  • Show agencies' clients the effect of image and font optimisation
  • Track page weight and emissions of key pages every week

FAQ

How accurate is it?

It is a model, not a measurement: SWD v4 uses average energy per byte. It is good for comparing pages and tracking change, not for exact carbon accounting.

Does it check green hosting?

Not automatically. Look your host up in the Green Web Foundation directory and pass green=true if it is verified; by default the grid average is used.

Why is my page lighter than in DevTools?

The crawler does not run JavaScript, so scripts loaded later by tag managers, lazy images and videos are missing. Send the DevTools transfer size as bytes for a full figure.

Related APIs

Start with 1,000 free requests every month. Get free API key →