Skip to main content

Simple Python wrapper to fetch data from CarbonTracer (carbontracer.uni-graz.at)

Project description

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.

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

pycarbontracer-0.9.1.tar.gz (10.8 MB view hashes)

Uploaded Source

Built Distribution

pycarbontracer-0.9.1-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

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