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.
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
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
url | query | string | yes | Page to measure (or send bytes). | |
bytes | query | number | no | Transfer size in bytes instead of crawling a URL. | |
views | query | number | no | Page views per month: adds monthly and yearly kg CO2e. | |
green | query | boolean | no | false | true when the site runs on verified green hosting. |
country | query | string | no | Grid intensity of a country for all segments (ISO alpha-2 or alpha-3, e.g. VN); or device_country, network_country, datacenter_country. | |
max_resources | query | number | no | 40 | Maximum sub-resources fetched (0–80). |
green_hosting_factor | query | number | no | Advanced (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"const res = await fetch('https://apibox.io.vn/v1/web-carbon?bytes=2000000&views=10000&country=VN', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/web-carbon?bytes=2000000&views=10000&country=VN",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/web-carbon?bytes=2000000&views=10000&country=VN');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));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
URL Metadata
Fetch any URL and get its title, description, Open Graph and Twitter Card tags, favicon, canonical, feeds and JSON-LD as JSON.
H:HTTP Headers
See the HTTP status and every response header of a URL, with a summary of security headers like HSTS, CSP and X-Frame-Options.
301Redirect Checker
Follow every 301, 302, 307 and 308 redirect of a URL and get the full chain with status codes, the final URL and the number of hops.