How to pull data from Google Cloud Pricing Calculator with API

Introduction

When scaling up your organization’s infrastructure needs, you will need to extrapolate the appropriate billing plans for your resources. With the aid of effective pricing models, cost management solutions and resource planning, you can scale your infrastructure to meet your exact needs. However, it is difficult to extrapolate the cost of your infrastructure if you do not comprehend the pricing plans for your GCP services. In situations like these, we can utilize the Google Cloud Billing API or the Pricing Calculator to help assimilate the cloud resources you are using.

To understand how to avail a better billing experience, you need to know about your GCP services and cloud billing. Various GCP services range from compute, storage, network, and other services. While employing any of these GCP services, we are charged strictly based upon our cloud usage. Cloud billing on the other hand, organizes billing hierarchically and is connected to a billing account where you can link multiple projects. Cloud billing is controlled by an Identity and Access Management (IAM) service and is accessible by a self-service or an invoiced account.

In this article, we will discuss two approaches to understand billing :

1. Google Cloud Billing Catalog API

2. Google Cloud Pricing Calculator

With the Google Cloud Billing Catalog API, you can get the pricing information for all the services utilized in the Google Cloud Platform. You can additionally use them to predict bills, understand cost breakdown, and view the charges for a specific service. The Google Cloud Pricing Calculator gives businesses perspective on the overall cost of cloud services and helps in making better and more informed decisions.

Cloud Billing Catalog API

The Google Cloud Billing Catalog API lets users predict their bills and estimate their costs effectively. It is a real-time pricing tool offered by Google and allows users to create and manage sub-accounts through Catalog API. When using the Catalog API, you can also store the lists of SKUs (Stock Keeping Units) within a service. The list of all SKUs within a service includes information such as: List pricing, Description, Categorizations, and Availability regions.

If you are looking to access the Catalog API, the recommended way to start is to use a client library in your desired programming language. You can use a REST API call to create, access, list services, and update all your billing accounts.

To get started, enable the Cloud Billing Catalog API in your project. You will also need access to an API key. Next, you can make a GET request to the following URL to list all public available services:

GET https://cloudbilling.googleapis.com/v1/services?key=API_KEY

You will receive a JSON response with the list of services:

{  "services": [    {      "name": "[SERVICE_NAME]",      "serviceId": "[SERVICE_ID]",      "displayName": "[DISPLAY_NAME]",    },    [...]  ],  "nextPageToken": "[NEXT_PAGE_TOKEN]"}

The [SERVICE_NAME] is the name of the service. The [SERVICE_ID] is the unique identifier of the service. The [DISPLAY_NAME] is the human-readable name of the service. You may also further refer to the REST API documentation for more details.

To send requests to the Catalog API using RPC, we need authentication for the project. Navigate to the Cloud console and select the Create service account key page. You can further select the service account, enter a name and select your role (Project > Owner). You can now create a JSON file that contains your GOOGLE_APPLICATION_CREDENTIALS and you can further use it to send requests to the Catalog API.

While using the Catalog API, you must be careful that billing is enabled at the project level and not the API level. It means that some APIs might be charged as per the usage of the API, which will be further billed based on project usage.

Cloud Pricing Calculator

The Cloud Pricing Calculator is a web-based application that allows you to compare the cost of running various types of cloud services on GCP. Compared to using Catalog API, the Cloud Pricing Calculator is relatively easier to use and offers greater flexibility with the least technical overhead.

To get started with the Cloud pricing calculator, you can select the particular services you need and describe the components to be added to the system. For example, for Compute Engine we can select instance type, region, time commitment, compute units, etc.. and we can retrieve a monthly price estimate.

The Cloud Pricing Calculator uses Google Cloud API s to query pricing data. If you are designing a new system, you can use the Cloud Pricing Calculator to get a quick price estimate for the components necessary. You can also customize the component’s names and break down the system into multiple environments. Once completed, you can share it with your team through email or a uniquely generated link.

The most important aspect of using the Cloud Pricing Calculator is to understand what cloud services you will be deploying. Before adding the components to the system, we need to comprehend what they are and how they will be utilized. For example, if we are planning to use virtual machines, we need to list the instance type, region, time commitment, and compute units. We will also need to know what application we are planning to deploy. Administering these details will help us make the best possible use of cloud billing and pricing tools.

Conclusion

Using the Catalog API and the Cloud Pricing Calculator, you can now set up your infrastructure needs and break down the cost analysis of your cloud services. To gain significant insight into your current infrastructure, varied cloud cost factors and comprehensive visualization, Economize might be the right choice for you. Save now and invest in the future of your business.

Discover what’s possible

Help me reduce my cloud costs

You're spending a lot on cloud — but do you know how much?
We are committed to making your cloud spend simpler and help you optimize it.

You should also check out this other helpful content.

The Marketing Automation Essentials

Learn all you need to know about marketing automation and customer journeys.

The Marketing Automation Essentials

Learn all you need to know about marketing automation and customer journeys.

Get started with Economize today

With our powerful recommendations and easy-to-use tool, it's never been easier to reduce your cloud costs.
add_action( 'wp_footer', function() { if ( ! defined( 'ELEMENTOR_VERSION' ) ) { return; } ?>