Christmas Sale

How to use Google Cloud API Platform and get an API key

Ever wondered what Google Cloud platform API is? Still not sure if your business needs it? It’s time to throw some light on this tool, that is used for various purposes. A Google Reviews widget, for example. Today we are going to discuss how to use it and get an API key.
Share:
Share on Facebook
Share on X
Share on LinkedIn
Share on WhatsApp
Copy Link
How to use Google Cloud API Platform and get an API key

What is Google Cloud API Platform

Google Cloud API is the key element of Google Cloud Platform. It helps users implement the power of everything from storage access to machine-learning based image analytics to their Cloud Platform applications. 

Cloud APIs can be accessed from server applications with Google client libraries in a wide range of well-known programming languages, and also from mobile apps with the Firebase SDKs, or via third-party clients. Such solutions let various interactions with the platform content for users, for example embed Google reviews on website.

Types of APIs

There are more than 20 categories of APIs in Google’s library. Let’s discuss some of them.

  • Maps APIs are used to add maps to websites, providing imagery and local data from Google Maps. Users can style maps to make it fit with their needs. They can also help in getting data from the same database used by Google Maps. It features more than 100 million businesses and points of interest that are updated on a regular basis.
  • YouTube APIs provide access to YouTube data – videos, playlists, channels. They also retrieve the analytics data, schedule reporting jobs containing it and download the resting bulk data reports from the CSV files. 
  • Drive API allows users to create mobile, web and desktop apps that can read, write and sync files in Google Drive. 
  • Calendar API lets users integrate their apps with Google Calendar, creating new ways of engaging the audience. 
  • Gmail API helps to view and manage Gmail mailbox data, for example threads, messages and labels. 
  • Docs API is used to read and write documents programmatically so that you could integrate the data from various sources using all the power of Google docs. 
  • Sheets API helps users to read, write, format data and also create chats in Google Sheets. 
  • Social APIs include a set of tools which allow users get access to information about profiles and contacts on Google People, and also get an admittance to posts and comments of a Blogger blog. 
  • Advertising APIs includes 12 different APIs which can help, for example, AdSense publishers to access their inventory and run earnings and performance reports.
  • Mobile APIs include Fitness, Android and Google Play services. They let users easily integrate gaming features in their mobile apps, manage their in-app products and users’ fitness tracking data. 
  • Cloud APIs allow users to automate their workflows by using their favorite language. 
  • Others. This category of APIs includes 62 options from controlling access to data by Google personnel to URL shortening. 

To get more information on each API provided by Google visit the API library. Now that you’ve chosen the ones that meet your needs let’s proceed to the next step. 

How to work with Cloud APIs

First thing you need to work with Cloud APIs is Google account. It allows you to apply Google developer products such as the Cloud Console and Stackdriver Logging and Monitoring. If you haven’t got a Google account yet, you can sign up by clicking here

Step 1. Create a Google project

To use any of Cloud APIs you’ve got to have a Google project which is equivalent to a developer account. It works as a recourse container for Google Cloud Platform (GCP) resources and provides an isolation boundary for usage of its services. You can create your project using the Cloud Console

Tip: you are to have at least one API key associated with your project.

Your project can own a wide range of resources, for instance, API keys, OAuth clients, BigQuery databases. When an application calls a Cloud API, the project which owns the app credentials is named the client project, while the project owning the target resource is called the resource project. Also, one API request may touch multiple resources.

Step 2. Enable APIs

For Cloud API usage, you have to enable it for your project or projects (if many). To enable an API you have to accept the Terms of Service and billing responsibility for the API. 

To enable an API, follow these steps:

  • Open the Google Cloud Console API Library. 
  • Select a project from the projects list, or create a new one.
  • In the API library, select the API you want to enable.
  • Click ENABLE on the API page.

You are always free to disable an API for your project at the same page if you’re no longer using it. Cloud APIs can also be enabled or disabled by means of Cloud SDK and Service Usage API. 

Some Cloud APIs require payments for usage. To use them you have to enable billing for your project. Click here and follow the instructions to do it.

Step 3. Start building applications

For building applications with the help of Cloud APIs it’s recommended to apply Google Cloud Client Libraries if available. All the Cloud Libraries handle common API features: authentication, error handling, retry and payload validation. 

Tip: You can find more information on Client Libraries here.

To successfully work with Google Cloud applications users have to create API keys. Let’s see how it can be done. 

Using and getting the API Keys

An API key is a simple encrypted string that used to call certain API that doesn’t need to access private user data. It’s a useful feature in clients such as browser and mobile applications which don’t have a backend server. 

All API keys have some limitations:

  • Only a limited number of Google Cloud services allows access with just an API key, without using another type of credential.
  • You can’t restrict access to specific users or service accounts as API keys do not identify the user of the application making the API request.
  • It’s much easier for others to use your API key.

Because of the limitations mentioned above Google recommends using the standard authentication flow. But there are limited cases when API keys are more appropriate.

1. Create your API key

Your account must be granted the primitive Editor role on the current project so that you could create an API key. 

Tip: Roles are used to provide a user, a group or a service account with permissions to use the resource. Find more info on roles here.

To create an API key, follow these steps:

  • Go to the APIs & Services→Credentials panel in Cloud Console.
  • Choose Create credentials option and then select API key from the dropdown menu.
  • The dialog box will display your newly created key.

In case you need to specify which web pages, IP addresses or apps can use your API key, you can add application restrictions based on your application type. Mind that you can only set one restriction type per API key. 

2. Use your API key

To do it you should pass the API key into a REST API call as a query parameter with the following format. Replace API_KEY here with your API key:

Code example for Google Cloud API

Here’s an example of passing an API key for a Cloud Natural Language API request for documents.analyzeEntities:

Passing an API key for a Cloud Natural Language

3. Secure your API keys

You should always keep your API key secure. Follow these practices to make it possible:

  • Never embed API keys directly in code as they may be accidentally exposed to the public. 
  • Do not store your API keys in files inside your application’s source tree.
  • Initialize application and key restrictions. This can prevent the impact of a compromised API key.
  • Don’t forget to delete all unneeded API keys.
  • Periodically regenerate your API keys from the Credentials page
  • Ensure that your code doesn’t contain API keys before releasing it. 

After you’ve made sure your API keys are secure, it’s time to add restrictions.

4. Add restrictions to API keys

All API keys are unrestricted by default. You have to restrict them to prevent them from being viewed publicly – for example, from a browser or on a device where the key is retained. 

Follow this steps to add API key restrictions:

  • Go to the APIs & Services→Credentials section in Cloud Console.
  • Choose the name of the existing API key.

You also can add application restrictions. These specify what websites, IP addresses or apps can use an API key. 

Only one restriction type can be set per API key.

There are five restriction types you can choose from according the needs of your app: 

  • None can be used for testing purposes only.
  • HTTP referrers can be used for API clients which run on a web browser.
  • IP addresses can be used to limit API key access to some particular IP addresses.
  • Android apps is there for Android applications. 
  • iOS apps can restrict API calls to specific iOS bundles. 

You can find more information on API restrictions here

Google Cloud Platform Pricing and Limits

Google Cloud API platform has lots of pricing options for all types of clients. You can see them all at the Price list page. 

But there’s also Free Tier – it guarantees free usage up to monthly limits of select products, including BigQuery and Compute Engine. Google cloud free options include Cloud Functions, Storage, and many more. 

For example:

NameLimits
Google Calendar API1,000,000 queries per day
Google Docs APIFree of charge
Gmail API1,000,000,000 quota units per day
Sheets API500 requests per 100 seconds per project, 100 requests per 100 seconds per user

To see the full list of options click here

For those who want to know the cost of paid services there’s a Pricing Calculator. To use, simply fill in all the empty fields and see the cost on Google Cloud Products calculated right for your needs. 

FAQ

Are there any support options for Google Cloud API?

Yes! Check the Getting Support page to find the useful info and get support contacts.

Can I use Google Cloud API for free?

You can check the list of free options here. Bear in mind that free trials are over when you use all of your credit.

Can I delete my Google Cloud API Console account?

Absolutely! Simply open your account, then check the left navigation Panel, click Data & personalization. On the Delete your Google Account panel, choose Delete option.

How can I upgrade my account to a paid one?

You must do it after a free trial ends. Open Google Cloud Console and click the Activate button. If the Activate button is not visible, on the menu bar, click Free trial status Activate button will appear.

Conclusion

Now you know how to get started with Google API Platform. We’ll be extremely interested to see your own experiences with this tool. Share your use cases and helpful tips in comments and don’t forget to tell us if this guide was helpful for you!

Christmas Sale
33% OFF
Catch the end-of-year sale!
Grab The Deal