![](https://cdn.qwiklabs.com/assets/labs/start_lab-f45aca49782d4033c3ff688160387ac98c66941d.png)
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Deploying the Endpoints configuration
/ 20
Deploying the API backend
/ 20
Sending requests to the API
/ 20
Add a quota to the API
/ 20
Create API key and testing quota limit by sending requests
/ 20
In this lab you will deploy a sample API with Google Cloud Endpoints, which are a set of tools for generating APIs from within an App Engine application. The sample code will include:
IATA
code (for example, SFO, JFK, AMS).After you send some requests to the sample API, you can view the Cloud Endpoints Activity Graphs and Logs. These are tools that allow you to monitor your APIs and gain insights into their usage.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
To publish a REST API to Endpoints, an OpenAPI configuration file that describes the API is required. The lab's sample API comes with a pre-configured OpenAPI file called openapi.yaml
.
Endpoints uses Google Service Management
, an infrastructure service of Google Cloud, to create and manage APIs and services. To use Endpoints to manage an API, you deploy the API's OpenAPI configuration to Service Management.
To deploy the Endpoints configuration...
endpoints-qwikstart
directory, enter the following:Cloud Endpoints uses the host
field in the OpenAPI configuration file to identify the service. The deploy_api.sh
script sets the ID of your Cloud project as part of the name configured in the host
field. (When you prepare an OpenAPI configuration file for your own service, you will need to do this manually.)
The script then deploys the OpenAPI configuration to Service Management using the command: gcloud endpoints services deploy openapi.yaml
As it is creating and configuring the service, Service Management outputs some information to the console. You can safely ignore the warnings about the paths in openapi.yaml
not requiring an API key. On successful completion, you see a line like the following that displays the service configuration ID and the service name:
Click Check my progress to verify the objective.
So far you have deployed the OpenAPI configuration to Service Management, but you have not yet deployed the code that will serve the API backend. The deploy_app.sh
script included in the lab sample creates an App Engine flexible environment to host the API backend, and then the script deploys the API to App Engine.
endpoints-quickstart/scripts
directory. Then, run the following script:The script runs the following command to create an App Engine flexible environment in the gcloud app create --region="$REGION"
It takes a couple minutes to create the App Engine flexible backend.
ERROR: NOT_FOUND: Unable to retrieve P4SA: from GAIA
message, rerun the deploy_app.sh
script.
You'll see the following displayed in Cloud Shell after the App Engine is created:
The script goes on to run the gcloud app deploy
command to deploy the sample API to App Engine.
You'll then see a line like the following in Cloud Shell:
It takes several minutes for the API to be deployed to App Engine. You'll see a line like the following when the API is successfully deployed to App Engine:
Click Check my progress to verify the objective.
The script echoes the curl
command that it uses to send a request to the API, and then displays the result. You'll see something like the following in Cloud Shell:
The API expects one query parameter, iataCode
, that is set to a valid IATA airport code such as SEA or JFK.
You just deployed and tested an API in Cloud Endpoints!
Click Check my progress to verify the objective.
With APIs deployed with Cloud Endpoints, you can monitor critical operations metrics in the Cloud Console and gain insight into your users and usage with Cloud Logging:
If the Permissions side panel is not open, click Show Permissions Panel. The Permissions panel allows you to control who has access to your API and the level of access.
Click the Deployment history tab. This tab displays a history of your API deployments, including the deployment time and who deployed the change.
Click the Overview tab. Here you'll see the traffic coming in. After the traffic generation script has been running for a minute, scroll down to see the three lines on the Total latency graph (50th, 95th, and 99th percentiles). This data provides a quick estimate of response times.
At the bottom of the Endpoints graphs, under Method, click the View logs link for GET/airportName. The Logs Viewer page displays the request logs for the API.
Enter CTRL+C in Cloud Shell to stop the script.
Cloud Endpoints lets you set quotas so you can control the rate at which applications can call your API. Quotas can be used to protect your API from excessive usage by a single client.
Click Check my progress to verify the objective.
You'll see something like the following on the console:
After running the script for 5-10 seconds, enter CTRL+C in Cloud Shell to stop the script.
Send another authenticated request to the API:
You'll see something like the following on the console:
If you get a different response, try running the generate_traffic_with_key.sh
script again and retry.
Click Check my progress to verify the objective.
Congratulations! You've successfully rate-limited your API. You can also set varying limits on different API methods, create multiple kinds of quotas, and keep track of which consumers use which APIs.
This lab is part of a series of labs called Qwik Starts. These labs are designed to give you a little taste of the many features available with Google Cloud. Search for “Qwik Starts” in the lab catalog to find the next lab you’d like to take!
For more information about quotas, see the following:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual last updated April 25, 2024
Lab last tested April 25, 2024
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one