Skip to main content

A command line tool containing a validator for carbon.txt files, by the Green Web Foundation

Project description

Carbon.txt Validator

This repository holds the code for the Green Web Foundation carbon.txt validator. It reads carbon.txt files and validates them against a spec defined on http://carbontxt.org. We use it to host active development of this validator and to manage/discuss technical issues.

When you validate a carbon.txt file on the carbon.txt website, it is using the API offered by this validator.

What is the carbon.txt project?

If you are new to the carbon.txt project, you can think of it a project to sustainability data easier to discover and use on the web. Carbon.txt is a single place to look on any domain – /carbon.txt – for public, machine-readable, sustainability data relating to that company.

Visit the Green Web Foundation website for a full overview.

Usage

There are two main ways to use the validator - as a command line tool, via the CLI, or as a web servier, via the HTTP API.

With the CLI

Run a validation against a given domain, or file, say if the file is valid TOML, and it confirms to the carbon.txt spec.

The following commands assume you are working in a virtual environment:

# parse the carbon.txt file on default paths on some-domain.com
carbon-txt validate domain some-domain.com

# parse a remote file available at https://somedomain.com/path-to-carbon.txt
carbon-txt validate file https://somedomain.com/path-to-carbon.txt

# parse a local file ./path-to-file.txt
carbon-txt validate file ./path-to-file.txt

# pipe the contents of a file into the file validation command as part of a pipeline
cat ./path-to-file.com | carbontxt validate file

With the HTTP API

You can also validate carbon.txt files sent over an HTTP API.

# run the carbon-txt validator as a server using the default django server. Not for production
carbon-txt serve

This will start an local server that by default listens on http://127.0.0.1:8000, looking something like thr screenshot below:

Screenshot of the validator API

Further guidance on usage

Please see the dedicated documentation site for the validator for details about how the validator works, and how to install it, extend it, and to deploy it.

Installation

[!TIP] See more detailed guidance on installation on the dedicated valiator docs site.

Using pip

You can install the latest release of the carbon.txt validator using pip. we assume that the carbon.txt validator is run inside a virtual environment. Learn more about virtual environments with Python.

python -m pip install carbon-txt

Using uv

If you are not using virtual environments directly, you can use it with uv. This is the recommended way to run the project, and the one we actively support.

Add carbon-txt to a project with uv add:

uv add carbon-txt

You can now run the command line tool with uv run carbon-txt

Running outside a project

If you have uv installed, you can run the command line tool like so:

# check a file
uv tool run carbon-txt validate ./path/to/file

# run a server
uv tool run carbon-txt serve

This will download the latest published version from Pypi and run the corresponding CLI command

Further details are in the dedicated docs on read the docs for the validator

More on the Carbon.txt project

Further technical documentation

There are a number of places where we hold technical documentation, beyond the validator here. The best starting point to find what you're looking for is on https://carbontxt.org/.

The issues sections of our main github repos is also a great source of help. You might find someone has already asked for help on the same issue and you’ll find an answer. We appreciate those that take the time to create public issues for this reason, it may help someone who encounters something similar after you.

Where to raise a technical issue with the project

Technical issues can cover a broad range of things. We take this to mean:

  • Reporting a bug or something not working as you expect.
  • Suggesting a new feature or improvement that could be made.

Our project GitHub repos are generally the best place to raise technical issues like these. We have a number of repos that cover different aspects of our project. Here’s a summary of those and a link to the relevant issues part of that repo:

Extending the carbon.txt approach such as running your own validator service or creating plugins (this repository) - https://github.com/thegreenwebfoundation/carbon-txt-validator/issues

Using the carbon.txt validator tools on our public website - https://github.com/thegreenwebfoundation/carbon-txt-site/issues

Developing the carbon.txt syntax and specification - https://github.com/thegreenwebfoundation/carbon.txt/issues

If you are unsure of the best repo for your issue, please just make your best guess. We'll move it if we think it necessary.

Collaborate, donate or fund this project

We are always open for discussions about how people can contribute back to the development and success of this tool through collaboration or financial donations. Please use the Green Web Foundation support form to let us know what you’d like to chat about.

Commercial support

The Green Web Foundation offers commercial consulting on:

  • using the carbon.txt validator to parse and process sustainability disclosures online,
  • disclosing this information in a way that validators can pick up, by implementing carbon.txt files
  • requesting disclosures from suppliers using the carbon.txt convention

For this, the fastest way to get a direct response is to use the Green Web Foundation support form.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

carbon_txt-0.0.20.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carbon_txt-0.0.20-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file carbon_txt-0.0.20.tar.gz.

File metadata

  • Download URL: carbon_txt-0.0.20.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for carbon_txt-0.0.20.tar.gz
Algorithm Hash digest
SHA256 6a0658cc06fb309c7296abeada2bdf9161d3f64d7b8da0e8a57566ec300d00dc
MD5 76f42953ade466fc2cca9e05a3d347d2
BLAKE2b-256 a9d98acb25b00816bfe3d54535ea4b2fe2073a20b8e0fbfc76963b290feeb296

See more details on using hashes here.

Provenance

The following attestation bundles were made for carbon_txt-0.0.20.tar.gz:

Publisher: release.yml on thegreenwebfoundation/carbon-txt-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file carbon_txt-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: carbon_txt-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 43.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for carbon_txt-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 2d689170582d47431ff969dda21e4d0e4a2de35715a1df075d337f8ab199d274
MD5 5fa9a62b327c302960855590fe6417f4
BLAKE2b-256 3d638a1de6f37a049eeb556efebcc10456bc1e33f5aace18c3df6775fb311f82

See more details on using hashes here.

Provenance

The following attestation bundles were made for carbon_txt-0.0.20-py3-none-any.whl:

Publisher: release.yml on thegreenwebfoundation/carbon-txt-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page