Website Carbon API


How is your website impacting the planet?.

The internet consumes a lot of electricity. 416.2TWh per year to be precise. To give you some perspective, that’s more than the entire United Kingdom.

From data centres to transmission networks to the devices that we hold in our hands, it is all consuming electricity, and in turn producing carbon emissions.

For more information about how we calculate the carbon emissions, please visit https://www.websitecarbon.com/how-does-it-work/


What is the API

The API powers https://www.websitecarbon.com/, in that it runs the tests that produces the results the website shows.

The API is build with PHP, Flight, Google Page Speed Insights, and the Green Web Foundation API


API Endpoints

/

The page you are viewing at the moment

https://api.websitecarbon.com

/site?url={xxx}

This endpoint accepts a URL parameter and will run a test in real time to calculate the carbon emissions generated per page view

This endpoint is cached and will only test the same URL once every 24 hours

https://api.websitecarbon.com/site?url=wholegraindigital.com

/website?url={xxx}

This endpoint accepts a URL parameter, and returns an array of urls linking to the history page for all pages

https://api.websitecarbon.com/website?url=wholegraindigital.com

/history?url={xxx}

This endpoint accepts a URL parameter and a page parameter and returns 10 results at a time

https://api.websitecarbon.com/history?url=wholegraindigital.com

/data?bytes={xxx}&green={1/0}

An endpoint to calculate the emissions of a page by manually passing the bytes and whether or not it is powered by green hosting

https://api.websitecarbon.com/data?bytes=1000&green=1

/b?url={xxx}

An endpoint with refined data output powering the website carbon badge.

https://api.websitecarbon.com/b?url=wholegraindigital.com

For more information, visit https://wholegrain.gitlab.io/website-carbon-badges/