Cloud Billing Catalog API: GCP pricing in real-time

Cloud Billing Catalog API: GCP pricing in real-time



05 June 2020

Getting ready to utilize GCP services and not sure about the pricing and the plans, this blog is for you. Before going into the depth, let’s have a basic terminology.

Understand about Cloud Billing

GCP Services:

GCP provides many services: Computing and hosting, Storage, Databases, Networking,Big data and Machine Learning. So if you use any GCP services you have to pay for each of them. It can be configured as per our requirement.

Cloud billing:

Cloud billing is applied for GCP resources. To use the GCP resources you need to create a billing account. These resources are organized hierchachially. A billing account belongs to a GCP project. It can be linked to one or more projects. Cloud billing account is controlled by Cloud Identity and Access management (Cloud IAM) roles. A cloud billing account is linked to Google payments Profile.

Note: If your project is not linked to a cloud billing account, you cannot be able to use GCP services that require billing.

Billing services:


From the above diagram, Billing account is linked to Projects 1, 2, 3, and 4, that means it pays for costs incurred by the three projects. Cloud Billing account is also linked to a Google payments profile, which gathers information like payment methods, address, and name.

There are two types of cloud billing account:

  1. Self service account:
    It prefers the Payment instrument that can be done by credit or debit card. This is called an online payment account.
  2. Invoiced account:
    It prefers the payment instrument that can be a check or wire transfer. Here invoices are sent via mail or electronically.

Cloud Billing Catalog API

Google provides a real time pricing tool for cloud platforms that is called Cloud Billing Catalogue API where users can Predict bills, and Estimate the costs. Users can create and manage sub-accounts through the GCP API . API allows the user to connect to the GCP existing accounts and allow new users programmatically. It also stores the list of SKU (Stock Keeping Units) within a service.

SKU: It is a product code that helps to identify the price, product options, invoices and manufacturer of the merchandise. It tracks inventory in your retail store.

Using cloud billing API we get following

  • Provides a list of all public services including relevant metadata about each service
  • It is Human readable description of the SKU
  • It provides Public pricing of the SKU
  • It is Regions based, where the SKU is available for purchase

To access the billing API services, google provides several client libraries which can be installed into your application and access the services with your desired programming language. It can also be accessed by using REST API call. Use the following endpoint to access the REST API and can create, access, grant access, list all cloud services, update billing accounts.

One should require authentication to send requests to the billing API through RPC. To create the authentication for the project, make sure to enable the cloud billing API. Follow the below steps to access the authentication.

  • Go to the Cloud console and select the Create service account key page.
  • On the service account list, select the service account.
  • Enter a name in the Service account name field.
  • From the role list select Project  > Owner.
  • Click on create, a JSON file will be created which contains GOOGLE_APPLICATION_CREDENTIALS.

You can use this GOOGLE_APPLICATION_CREDENTIALS to send requests to the billing API through RPC.

To call the cloud billing REST API,  you require an API key. API keys are a string that is encrypted. It is used when calling APIs that don’t need to access private users data. API keys are used for browser and mobile applications that don’t have a backend server. It is used to track API requests that are associated with your GCP project for billing accounts. To create an API key, move ahead with the below steps.

  • Navigate to the API console.
  • Select your project from the list of projects or create a new project.
  • Select API & services from the left side menu.
  • Select credentials.
  • Click on create credentials and select API key.

Some google API charge for the usage. Billing is enabled at project level not the API level. Every billable API used in the project will be billed based on the project usage. The usage in the project is billed using the specified payment mode. One can change the payment mode any time.

To calculate your total costs for running a specific workload on GCP visit the pricing calculator.


Blog Categories
Request a quote