pycarbontracer/README.md
Kumi c5d9c6f946
Update install command in README, bump version
- Updates the installation command in the README file to use the package name "pycarbontracer" instead of the repository URL
- Updates the version number in the "pyproject.toml" file from "0.9.0" to "0.9.1"
2023-08-23 10:03:40 +02:00

1.2 KiB

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 pycarbontracer

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.