Carbem
A Rust library for retrieving carbon emission values from cloud providers.
Overview
Carbem provides a unified interface for querying carbon emission data from various cloud service providers. This library helps developers build more environmentally conscious applications by making it easy to access and analyze the carbon footprint of cloud infrastructure.
Features
- π Multi-provider support: Unified API for different cloud providers
- β‘ Async/await: Built with modern async Rust for high performance
- π Type-safe: Leverages Rust's type system for reliable carbon data handling
- π Easy to use: Simple and intuitive API design
- π Python Bindings: Native Python integration via PyO3
- π§ Flexible Filtering: Filter by regions, services, and resources
Installation
Rust Library
Add this to your Cargo.toml:
[]
= "0.2.0"
Python Package
Install from PyPI:
For development setup with maturin:
Quick Start
Using Rust
For standalone Rust applications, use the builder pattern with environment variables:
use ;
use ;
async
Using Python
For Python applications, use the get_emissions_py function:
# Azure configuration
=
# Query for last 30 days
=
= -
=
# Get emissions data
=
=
Create a .env file in your project root:
# Azure Carbon Emissions Configuration
CARBEM_AZURE_ACCESS_TOKEN=your_azure_bearer_token_here
# OR alternatively use:
# AZURE_TOKEN=your_azure_bearer_token_here
Configuration Parameters
Environment Variables (for Standalone Rust)
CARBEM_AZURE_ACCESS_TOKEN: Azure access tokenAZURE_TOKEN: Alternative Azure access token variable
Python Configuration
For Python applications, configuration is passed as JSON strings to the get_emissions_py function. See the Python API Documentation for detailed configuration examples and usage patterns.
Azure Configuration (AzureConfig)
The Azure provider requires minimal configuration:
use AzureConfig;
let config = AzureConfig ;
Object-Oriented API (Advanced Usage)
use ;
use ;
async
Supported Providers
Microsoft Azure β
- Report Types: All report type from the API are supported.
- Queries: All query parameters are supported.
Β Google Cloud Platform
Google Cloud Platform is not supported at the moment (October 11th 2025). Data are available only after exporting them to BigQuery as discussed in this page. Thus, one will need to make a query to the BigQuery API, which makes a standard implementation not possible at the moment.
Amazon Web Services (AWS)
AWS is not supported at the moment (October 11th 2025). Data are available in S3 buckets as discussed in this page. An endpoint existed but was discontinued on July 23rd 2025 (ref).
Roadmap
- Core library infrastructure
- Azure Carbon Emission Reports API
- IBM Cloud Carbon Calculator
- Amazon Web Services (AWS)
- Google Cloud Platform (GCP)
- Additional providers planned
Testing
The library includes a comprehensive test suite:
# Run all tests
# Run specific Azure provider tests
# Run with output
Test coverage includes:
- Provider creation and configuration
- Query conversion and validation
- Date parsing and time period handling
- Data conversion from Azure API responses
- Error handling for invalid configurations
Documentation
Rust Documentation
- API Documentation: Available on docs.rs
Python Documentation
- Python API Reference - Detailed function documentation and usage patterns
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
Acknowledgments
This project aims to support sustainability efforts in cloud computing by making carbon emission data more accessible to developers and organizations.