No description
Find a file
Kumi 22a13889d2
refactor: add return type annotations to address, routing, and co2only methods
This commit adds return type annotations to the `address`, `routing`, and `co2only` methods in the `CarbonTracer` class. This helps improve code readability and provides better documentation by specifying the expected return types for these methods.
2023-08-23 10:17:44 +02:00
src/pycarbontracer refactor: add return type annotations to address, routing, and co2only methods 2023-08-23 10:17:44 +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 Update install command in README, bump version 2023-08-23 10:03:40 +02:00
README.md Update install command in README, bump version 2023-08-23 10:03:40 +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 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.