To generate a cost estimate based on your projected usage,
use thepricing calculator.
New Google Cloud users might be eligible for afree trial.
When you finish the tasks that are described in this document, you can avoid
continued billing by deleting the resources that you created. For more information, seeClean up.
Before you begin
Sign in to your Google Cloud account. If you're new to
Google Cloud,create an accountto evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Linux and macOS users: This tutorial provides an example of usingcurl, which typically comes pre-installed on your operating system.
If you don't havecurl, you can download it from thecurlReleases and downloads page.
Windows users: This tutorial provides an example usingInvoke-WebRequest, which is
supported in PowerShell 3.0 and later.
Update the gcloud CLI and install the Endpoints
components.
gcloud components update
Make sure that the Google Cloud CLI (gcloud) is authorized to access
your data and services on Google Cloud:
gcloud auth login
In the new browser tab that opens, select an account.
Set the default project to your project ID.
gcloud config set projectYOUR_PROJECT_ID
ReplaceYOUR_PROJECT_IDwith your project ID.
If you have other Google Cloud projects, and you want to usegcloudto manage them, seeManaging gcloud CLI configurations.
Select the region where you want to create your App Engine
application. Run the following command to get a list of regions:
gcloud app regions list
Create an App Engine application.
ReplaceYOUR_PROJECT_IDwith your Google Cloud
project ID andYOUR_REGIONwith the region that you
want the App Engine application created in.
The configuration sample displays the lines near thehostfield, which you need to modify. To deployopenapi-appengine.yamlto Endpoints, the complete OpenAPI document is required.
The exampleopenapi-appengine.yamlcontains a section for
configuring authentication that isn't needed for this tutorial. You don't
need to configure the lines withYOUR-SERVICE-ACCOUNT-EMAILandYOUR-CLIENT-ID.
OpenAPI is a language-agnostic specification. The sameopenapi-appengine.yamlfile is in thegetting-startedsample in
each language GitHub repository for convenience.
On the line with thehostfield, replaceYOUR-PROJECT-IDwith your Google Cloud project
ID. For example:
host: "example-project-12345.appspot.com"
Endpoints uses the text configured in thehostfield as
the service name. When you deploy the API to the App Engine backend, a
DNS entry with a name in the formatYOUR-PROJECT-ID.appspot.comis created automatically.
For information about the fields in the OpenAPI document that
Endpoints requires, seeConfiguring
Endpoints.
Thegcloudcommand then calls the Service Management
API to create a managed service with the name that you specified in thehostfield of theopenapi-appengine.yamlfile.
Service Management configures the service according to the
settings in theopenapi-appengine.yamlfile. When you make changes toopenapi-appengine.yaml, you must redeploy the file to update the
Endpoints service.
As it is creating and configuring the service, Service Management
outputs information to the terminal. You can safely ignore the warnings about
the paths in theopenapi-appengine.yamlfile not requiring an API key.
When it finishes configuring the service, Service Management displays a
message with the service configuration ID and the service name, similar to the
following:
Service Configuration [2017-02-13r0] uploaded for service [example-project-12345.appspot.com]
In the preceding example,2017-02-13r0is the service
configuration ID, andexample-project-12345.appspot.comis the
Endpoints service. The service configuration ID consists of a
date stamp followed by a revision number. If you deploy theopenapi-appengine.yamlfile again on the same day, the revision
number is incremented in the service configuration ID. You can view
the Endpoints service configuration on theEndpoints>Servicespage in the Google Cloud console.
At a minimum, Endpoints and ESP require the
following Google services to be enabled:
Name
Title
servicemanagement.googleapis.com
Service Management API
servicecontrol.googleapis.com
Service Control API
In most cases, thegcloud endpoints services deploycommand enables these
required services. However, thegcloudcommand completes successfully but
doesn't enable the required services in the following circumstances:
If you used a third-party application such as Terraform, and you don't
include these services.
You deployed the Endpoints configuration to an existing
Google Cloud project in which these services were explicitly disabled.
Use the following command to confirm that the required services are enabled:
gcloud services list
If you do not see the required services listed, enable them:
To determine theENDPOINTS_SERVICE_NAMEyou can either:
After deploying the Endpoints configuration, go to theEndpointspage in the Cloud console. The list of possibleENDPOINTS_SERVICE_NAMEare shown under theService namecolumn.
For OpenAPI, theENDPOINTS_SERVICE_NAMEis what you specified in thehostfield of your OpenAPI spec. For gRPC, theENDPOINTS_SERVICE_NAMEis what you specified in thenamefield of your gRPC Endpoints configuration.
For more information about thegcloudcommands, seegcloudservices.
Deploying the API backend
So far you have deployed the OpenAPI document to Service Management,
but you haven't yet deployed the code that serves the API backend. This
section walks you through deploying the sample API and ESP to App Engine.
To deploy the API backend:
Add your service name to theapp.yamlfile:
Java
Open theendpoints/getting-started/src/main/appengine/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command.name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
Python
Open theendpoints/getting-started/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command.name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
Go
Open theendpoints/getting-started/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command.name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
PHP
Open theendpoints/getting-started/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command. If you have# previously run the deploy command, you can list your existing configuration# ids using the 'configs list' command as follows:## gcloud endpoints configs list --service=YOUR-PROJECT-ID.appspot.com#name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
Ruby
Open theendpoints/getting-started/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command.name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
NodeJS
Open theendpoints/getting-started/app.yamlfile.
endpoints_api_service:# The following values are to be replaced by information from the output of# 'gcloud endpoints services deploy openapi-appengine.yaml' command.name:ENDPOINTS-SERVICE-NAMErollout_strategy:managed
ReplaceENDPOINTS-SERVICE-NAMEwith the name of your
Endpoints service. This is the same name that you configured in thehostfield of your OpenAPI document. For example:
Therollout_strategy: managedoption
configures ESP to use the latest deployed service configuration. When you
specify this option, up to 5 minutes after you deploy a new service
configuration, ESP detects the change and automatically begins using it. We
recommend that you specify this option instead of a specific configuration ID
for ESP to use.
Save theapp.yamlfile.
Because theendpoints_api_servicesection is included in theapp.yamlfile, thegcloud app deploycommand deploys and
configures ESP in a separate container to your App Engine
flexible environment. All request traffic is routed through ESP, and it
proxies requests and responses to and from the container running your
backend server code.
Make sure you are in theendpoints/getting-starteddirectory.
This is where youropenapi-appengine.yamlconfiguration file is
located.
Run the following command to deploy the sample API and ESP
to App Engine:
Thegcloud app deploycommand creates a DNS record in the
formatYOUR_PROJECT_ID.appspot.com, which you use when
you send requests to the API. We recommend that you wait a few minutes before
sending requests to your API while App Engine completely initializes.
Now that the service is running on App Engine you can send requests to
it.
Create an API key and set an environment variable
The sample code requires an API key. To simplify the request, you set an
environment variable for the API key.
In the same Google Cloud project that you used for your API, create an API key on the
API credentials page. If you want to create an API key in a different Google Cloud project,
seeEnabling an API in your Google Cloud project.
In the previous example, the first two lines end in a backtick. When you paste the
example into PowerShell, make sure there isn't a space following the backticks.
For information about the options used in the example request, seeInvoke-WebRequestin the Microsoft
documentation.
Third-party app
You can use a third-party application such as the Chrome browser
extensionPostmanto send the
request:
SelectPOSTas the HTTP verb.
For the header, select the keycontent-typeand the valueapplication/json.
For the body, enter the following: {"message":"hello world"}
In the URL, use the actualappspot.comaddress and API key rather than the environment variables. For example: https://example-project-12345.appspot.com/echo?key=AIza...
The API echoes back the message that you send it, and responds with the
following:
To avoid incurring charges to your Google Cloud account for the resources used in this
tutorial, either delete the project that contains the resources, or keep the project and
delete the individual resources.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis tutorial guides users through configuring and deploying a sample API and the Extensible Service Proxy (ESP) on an App Engine flexible environment instance, utilizing the OpenAPI specification for the REST API.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves setting up a Google Cloud project, downloading sample code, configuring Endpoints using the \u003ccode\u003eopenapi-appengine.yaml\u003c/code\u003e file, and deploying both the Endpoints configuration and the API backend.\u003c/p\u003e\n"],["\u003cp\u003eUsers will learn how to deploy an API using multiple coding languages such as Java, Python, Go, PHP, Ruby, and Nodejs, ensuring all required Google services are enabled for smooth operation.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial includes instructions for creating an API key, using it to send requests to the deployed API, and monitoring API activity via Endpoints and Logs Explorer.\u003c/p\u003e\n"],["\u003cp\u003eGuidance is also provided on cleaning up resources to avoid incurring charges and exploring further steps, such as sharing the API, learning about authentication, and community support.\u003c/p\u003e\n"]]],[],null,[]]