Skip to main content

Official Python SDK for ZeroCarbon.codes API

Project description

ZeroCarbon Python SDK

Official Python client for ZeroCarbon.codes - India's leading Carbon Accounting & Offsetting API.

Installation

pip install zerocarbon-sdk

Quick Start

from zerocarbon import ZeroCarbon

# Initialize client
client = ZeroCarbon(api_key="YOUR_API_KEY")

# Calculate flight emissions
emissions = client.calculate.flight(
    origin="DEL",
    destination="BOM",
    cabin_class="economy"
)
print(f"Emissions: {emissions['emissions_kg_co2e']} kg CO2e")

# Get offset recommendations
offsets = client.offsets.get_recommendations(
    emissions_kg_co2e=emissions['emissions_kg_co2e'],
    preferred_region="India"
)
print(f"Top project: {offsets['recommendations'][0]['name']}")

# Purchase and retire credits
transaction = client.offsets.purchase(
    project_id=offsets['recommendations'][0]['project_id'],
    quantity_kg_co2e=emissions['emissions_kg_co2e'],
    retirement_reason="Business flight offsetting"
)
print(f"Certificate: {transaction['certificate_url']}")

Features

  • ✅ Calculate emissions from flights, electricity, fuel, and more
  • ✅ AI-powered spend-based emission matching
  • ✅ Carbon offset recommendations
  • ✅ Purchase and retire carbon credits
  • ✅ Generate BRSR-compliant reports
  • ✅ Webhook support
  • ✅ Test mode for development

Documentation

Full documentation: https://docs.zerocarbon.codes

Examples

Calculate Electricity Emissions

emissions = client.calculate.electricity(
    amount_kwh=1000,
    country="IN",
    state="Maharashtra"
)
# Returns: 820 kg CO2e (using India grid factor)

Smart Spend Matching

emissions = client.calculate.spend(
    amount=100000,
    currency="INR",
    category="electricity",
    description="Monthly office electricity bill"
)
# AI automatically matches to emission factors

Generate BRSR Report

report = client.brsr.generate_report(
    company_id="comp_123",
    financial_year="2024-25",
    format="pdf"
)
print(report['download_url'])

Test Mode

Enable test mode to avoid real charges:

client = ZeroCarbon(
    api_key="test_YOUR_API_KEY",
    test_mode=True
)

License

MIT License - see LICENSE file for details.

Support

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

zerocarbon_python_sdk-2.0.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zerocarbon_python_sdk-2.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file zerocarbon_python_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: zerocarbon_python_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for zerocarbon_python_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 7dae5626e6f5cba2c6eb874d0b4c761abca0a77f7d31e0c724c43e3df73296f7
MD5 4efbcd2e7362a47ef90b70d6391af7c5
BLAKE2b-256 a86f7c5323dbbccf25c59064d74c7b3ffd64e273fb64fda76d24fc281f0b5c8b

See more details on using hashes here.

File details

Details for the file zerocarbon_python_sdk-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zerocarbon_python_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66418814d9d619f2c82a552b849fe2e221158a53c30527e182130eae4d79052d
MD5 c80ada90c68d80736b078115bf63316a
BLAKE2b-256 b5f4f60831b3f86190ab574b61000cbb3fd8b062a01746e3fb6cf003e4301557

See more details on using hashes here.

Supported by

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