No description
Find a file
Kumi 14cc55b3df
Add 'publish' stage to .gitlab-ci.yml
We add a new 'publish' stage in .gitlab-ci.yml to handle publishing artifacts.
2023-08-23 09:57:39 +02:00
src/pycarbontracer Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00
.gitignore Current status 2023-08-16 11:28:38 +02:00
.gitlab-ci.yml Add 'publish' stage to .gitlab-ci.yml 2023-08-23 09:57:39 +02:00
config.dist.ini Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00
LICENSE Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00
pyproject.toml Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00
README.md Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00
test.py Fork pykeydelivery for CarbonTracer client 2023-08-22 19:14:00 +02:00

CarbonTracer API Python Client

This is a Python client for CarbonTracer. It is a wrapper around the CarbonTracer REST API, which allows you to calculate CO2 equivalents for personal transport.

Installation

pip install git+https://kumig.it/kumitterer/pycarbontracer.git

Usage

from pycarbontracer import CarbonTracer

# Create a new CarbonTracer instance

ct = CarbonTracer("YOUR_API_KEY")

# Or use CarbonTracer.from_config() if you have a config.ini in the format of config.dist.ini

# Calculate the CO2 equivalents for a train trip from Graz to Vienna

result = ct.routing("train", "8010 Graz", "1010 Wien")

# Print the result

print(f"CO2 equivalents: {result["response"]["data"]["co2eq"]} {result["response"]["data"]["unitco2eq"]}")

The CarbonTracer class also has methods for the location, address and co2only endpoints, as documented in the CarbonTracer API documentation. The documentation also includes information about the input and output parameters, so make sure to check it out.

License

This project is licensed under the MIT License - see the LICENSE file for details.