The `google-cloud-billing` Python client library provides programmatic access to the Google Cloud Billing API, allowing developers to manage their billing accounts, link projects, or browse the catalog of SKUs and pricing information. It offers a high-level interface for interacting with Google Cloud Billing services. This library is actively maintained by Google, with regular updates to support new features and maintain compatibility with the latest Python versions.
pip install google-cloud-billingVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate the `CloudBillingClient` and list billing accounts accessible to the authenticated user. It relies on Application Default Credentials (ADC) for authentication. Ensure your local environment is authenticated (e.g., via `gcloud auth application-default login`) and that the service account or user account has the necessary IAM permissions (e.g., `billing.accounts.get`).
Upgrade your Python environment to Python 3.9 or a newer supported version.
To access detailed billing costs, configure Cloud Billing export to BigQuery via the Google Cloud Console. Then, use the `google-cloud-bigquery` library to query the exported datasets.
For local development, use `gcloud auth application-default login`. For production, leverage attached service accounts on GCP compute resources (e.g., Compute Engine, Cloud Run, Cloud Functions) or Workload Identity Federation for external workloads. Avoid explicit JSON key files where possible.
Review the official Google Cloud documentation on upcoming CUD billing model changes. Adjust your cost reporting and analysis tools to account for direct discounted pricing instead of credits. The API client will reflect the underlying data changes.
If you configure logging for this library, take care to restrict access to logs. Do not depend on the immutability of log events. Consider setting the `GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable for simple configuration or use advanced code-based configuration if strict control is needed.
No dependency data recorded yet.