cbilling
Multi-cloud billing SDK for Rust. Query billing data from 7 cloud providers through a unified API.
Looking for the terminal UI / CLI tool? See cbilling-cli.
Supported Providers
| Provider | Feature | API | Currency |
|---|---|---|---|
| Alibaba Cloud | aliyun |
BSS OpenAPI | CNY |
| AWS | aws |
Cost Explorer | USD |
| Tencent Cloud | tencentcloud |
Billing API v3 | CNY |
| Volcengine | volcengine |
Billing API | CNY |
| UCloud | ucloud |
UBill API | CNY |
| Google Cloud | gcp |
Cloud Billing + BigQuery | USD |
| Cloudflare | cloudflare |
Billing API v4 | USD |
Install
[]
# All providers (default)
= "0.1"
# Or pick only what you need
= { = "0.1", = false, = ["aws", "aliyun"] }
Quick Start
Direct Provider Client
use AliyunBillingClient;
async
Unified Service (recommended)
Normalizes all providers into a single BillingData struct with automatic pagination and credential loading from environment variables:
use CloudBillingService;
async
API
Provider Clients
Each provider exposes a typed client:
// Aliyun
new
.query_instance_bill
.query_account_bill
// AWS
new_with_default_credentials
.get_cost_and_usage
// Tencent Cloud
new
.get_bill_summary
.get_bill_detail
// Volcengine
new
.list_bill_detail
// UCloud
new
.query_bill_list
// GCP
new
.list_billing_accounts
.query_billing_costs
// Cloudflare
new_with_token
.get_subscriptions
.get_all_billing_history
Unified Service
get_configured_providers
Data Model
Configuration
Each provider reads credentials from environment variables:
| Provider | Environment Variables |
|---|---|
| Aliyun | ALIBABA_CLOUD_ACCESS_KEY_ID ALIBABA_CLOUD_ACCESS_KEY_SECRET |
| AWS | AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY |
| Tencent Cloud | TENCENTCLOUD_SECRET_ID TENCENTCLOUD_SECRET_KEY |
| Volcengine | VOLCENGINE_ACCESS_KEY_ID VOLCENGINE_SECRET_ACCESS_KEY |
| UCloud | UCLOUD_PUBLIC_KEY UCLOUD_PRIVATE_KEY UCLOUD_PROJECT_ID |
| GCP | GCP_PROJECT_ID + GCP_SERVICE_ACCOUNT_JSON |
| Cloudflare | CLOUDFLARE_ACCOUNT_ID CLOUDFLARE_API_TOKEN |
Multi-account JSON config is also supported via <PROVIDER>_ACCOUNTS env vars. See examples/.
Feature Flags
| Feature | Description |
|---|---|
aliyun |
Alibaba Cloud (default) |
tencentcloud |
Tencent Cloud (default) |
aws |
AWS Cost Explorer (default) |
volcengine |
Volcengine (default) |
ucloud |
UCloud (default) |
gcp |
Google Cloud (default) |
cloudflare |
Cloudflare (default) |
all-providers |
All of the above |
Project Structure
cbilling/
src/ # Library crate (cbilling)
providers/ # One module per cloud provider
service.rs # Unified query API
models.rs # Shared data types
error.rs # Error types
crates/
cbilling-cli/ # CLI + TUI crate (cbilling-cli)
examples/ # Per-provider usage examples
Examples
License
Apache-2.0