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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file pycarbontracer-0.9.1.tar.gz.

File metadata

  • Download URL: pycarbontracer-0.9.1.tar.gz
  • Upload date:
  • Size: 10.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pycarbontracer-0.9.1.tar.gz
Algorithm Hash digest
SHA256 54a4fd49096aa45b3e1d9338984e9b1adf9e42fa51500b7b1b56ca31c32724c4
MD5 495667f585bcfd3cd15f89ab49371f63
BLAKE2b-256 7e100e4635d15f58a8c9d7c2e5debf21c749f0b14ea7e6d1e3aa751c7ff0ceb6

See more details on using hashes here.

File details

Details for the file pycarbontracer-0.9.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pycarbontracer-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00a084737612d8f8e972c0d4bb4550f65a82d3e1679f19c7b15c7f3ea4db1b97
MD5 9babe7cc8530ed13726fd3e2018386dc
BLAKE2b-256 c423ce30d16e46db46eb8214afd7a67d7a4566bf2f1bc20e60f8b374d26fc55b

See more details on using hashes here.

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