Learn how to get started with Google Cloud APIs in Postman. If you are using Google Cloud APIs for the first time, you can follow the steps in this guide to call the APIs using requests sent through the Postman client. You can also use these requests to experiment with an API before you develop your application.
To use Google Cloud APIs in your applications, you first need to have a Google account. This allows you to use Google developer products, including Google Cloud console, gcloud CLI, Cloud Logging, and Cloud Monitoring. If you're new to Google Cloud, create an account to evaluate how Google products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
To use Cloud APIs, you also need to have a Google project. A project is equivalent to a developer account. It serves as a resource container for your Google Cloud resources. It also provides an isolation boundary for your usage of Google Cloud services, so you can manage quota limits and billing independently at the project level. Usage telemetry and dashboards are grouped by projects as well. If you don't already have a project, you can create one using the Google Cloud console.
To create a Google Cloud project:
Let's save our Google project ID as a Postman variable, so that we can use it in our API requests.
my-project-id
variable value. Before using any Cloud APIs, you should use Google Cloud console API Library to browse available Cloud APIs and discover the ones that best meet your business needs.
Some Cloud APIs are enabled by default. To use a Cloud API that is not enabled by default, you must enable it for your project. Depending on which services and which projects are involved from your application, including the client project and resource projects, you may need to enable an API for multiple projects. When you enable an API that depends on other APIs, those APIs are also enabled at the same time.
Let's enable the Compute Engine API to create and run virtual machines on Google Cloud Platform.
You will need to enable billing if your project is not already associated with a billing account. Let's do that in the next section.
Some Cloud APIs charge for usage. You need to enable billing for your project before you can start using these APIs in your project. The API usage in a project is charged to the billing account associated with the project.
If you don't have a billing account, go to the Google Cloud console billing page and follow the instructions to create one. Then link your billing account to your project.
How you authenticate to an API depends on your development environment and what authentication methods the API supports.
Setting up Application Default Credentials for use in a variety of environments is the most common approach, and is recommended for most applications. If the API supports API keys, that is another option. If your application needs to access Cloud resources owned by your end users, you create an OAuth 2.0 Client ID and use the authentication libraries. For general information about authentication, see Authentication at Google.
In the next section, let's set up OAuth 2.0.
To use OAuth 2.0 in your application, you need an OAuth 2.0 client ID, which your application uses when requesting an OAuth 2.0 access token.
To create an OAuth 2.0 client ID in the console:
https://oauth.pstmn.io/v1/browser-callback
. If you're testing from the Postman Desktop client, add the URI https://oauth.pstmn.io/v1/callback
. If you switch between the web and desktop application during your development workflow, you should add both URIs as redirect URIs. To add your OAuth 2.0 credentials to Postman:
https://accounts.google.com/o/oauth2/v2/auth
https://oauth2.googleapis.com/token
https://www.googleapis.com/auth/cloud-platform
In the following sections, let's explore some of the most popular APIs on Google Cloud Platform.
Compute Engine is a computing and hosting service that lets you create and run virtual machines on Google infrastructure. Compute Engine offers scale, performance, and value that lets you easily launch large compute clusters on Google's infrastructure. There are no upfront investments, and you can run thousands of virtual CPUs on a system that offers quick, consistent performance.
POST
method:projectId
. You can update path variables under a separate section beneath the Params tab in Postman. One of the path variables projectId
should reference a variable defined earlier, like {{my-project-id}}
. There is one variable referenced as {{my-zone}}
that is undefined. Add a new collection or environment variable called my-zone
with your preferred zone.{{my-project-id}}
. There are one variable referenced as {{vm-name}}
that has not yet been defined. Add a collection or environment variable called vm-name
with your preferred name for the instance of the virtual machine.Cloud Storage is a service for storing your objects in Google Cloud. An object is an immutable piece of data consisting of a file of any format. You store objects in containers called buckets. All buckets are associated with a project, and you can group your projects under an organization. Each project, bucket, and object in Google Cloud is a resource in Google Cloud.
After you create a project, you can create Cloud Storage buckets, upload objects to your buckets, and download objects from your buckets. You can also grant permissions to make your data accessible to principals you specify, or - for certain use cases such as hosting a website - accessible to everyone on the public internet.
POST
methodproject
with a value of {{my-project-id}}
which has been previously defined as a variable.{{bucket-name}}
. Add a collection or environment variable called bucket-name
with your preferred name for the bucket.object-name
that is referenced as a query parameterContent-type
header under the Headers tab.Google Cloud provides container resources such as organizations and projects that allow you to group and hierarchically organize other Google Cloud resources. This hierarchical organization helps you manage common aspects of your resources, such as access control and configuration settings. The Resource Manager API enables you to programmatically manage these container resources.
IAM lets you grant granular access to specific Google Cloud resources and helps prevent access to other resources. IAM lets you adopt the security principle of least privilege, which states that nobody should have more permissions than they actually need.
POST
method{{my-project-id}}
which has been previously defined as a variable.etag
with a value like BwX6zgFN+pY=
. etag
variable was set properly. POST
method{{my-project-id}}
like in our last request.etag
variable we set in the previous steps. See the IAM documentation for more examples of policies.409
http error code, retry the entire series of operations: read the allow policy again, modify it as needed, and write the updated allow policy. Also make sure the etag
property is set properly.Once you explore an API, you understand the basic building blocks of Google Cloud Platform. Next, organize your work into your own collections and workspaces in Postman.
Once you group API requests into collections, there are multiple ways to programmatically run those collections.
Once you have an API call working the way you want it to in Postman, generate client code to paste into your own applications.
For more hands-on tutorials, check out these resources.