Deploying Cloud Endpoints APIs on API Gateway

Cloud Endpoints is an API management system that helps you secure, monitor, analyze, and set quotas on your APIs. Endpoints uses the Extensible Service Proxy (ESP) or Extensible Service Proxy V2 Beta (ESPv2 Beta) to host your APIs.

When using Endpoints, you have three options for how you define your API:

Developing APIs with API Gateway

Both Endpoints and API Gateway supports API that are described using the OpenAPI specification, OpenAPI 2.0 or OpenAPI 3.x . If you have used OpenAPI to define your Endpoints APIs, this means that you can also deploy your Endpoints APIs on API Gateway.

Deploying Endpoints OpenAPI specs on API Gateway

API Gateway supports the same OpenAPI spec definition format and options as supported by Cloud Endpoints for OpenAPI . That means you can use the same security, quota, and other definitions from your Endpoints OpenAPI specs to define an API in API Gateway.

The only difference between Endpoints and API Gateway is how they process the host property in the OpenAPI spec definition:

  • In Endpoints, set the host property to the hostname portion of the URL created when you deployed ESP, where ESP is the service used to host your Endpoints API.
  • In API Gateway, omit the host or set it to the DNS name of the deployed API. API providers often set it to the DNS name when sharing the OpenAPI spec with their API consumers. However, API Gateway does not enforce the value of the host property.

For example, the following is a portion of an OpenAPI definition used by Endpoints to define an API to access a backend service deployed on Cloud Run functions:

OpenAPI 2.0

 swagger 
 : 
  
 '2.0' 
 info 
 : 
  
 title 
 : 
  
 Cloud Endpoints + GCF 
  
 description 
 : 
  
 Sample API on Cloud Endpoints with a Google Cloud Functions backend 
  
 version 
 : 
  
 1.0.0 
 host 
 : 
  
  HOST 
 
 schemes 
 : 
  
 - 
  
 https 
  
 ... 

OpenAPI 3.x

 openapi 
 : 
  
 3.0.4 
 info 
 : 
  
 title 
 : 
  
 Cloud Endpoints + GCF 
  
 description 
 : 
  
 Sample API on Cloud Endpoints with a Google Cloud Functions backend 
  
 version 
 : 
  
 1.0.0 
 servers 
 : 
 - 
  
 url 
 : 
  
 https:// HOST 
 
  
 x-google-endpoint 
 : 
  
 {} 
 ... 

When using Endpoints to deploy APIs, you:

  1. Deploy Vertex AI Search or ESPv2 Beta, which creates the URL that you then use to access deployed APIs. For example:

    https://gateway-12345-uc.a.run.app
  2. Edit the OpenAPI spec to set the host (in OpenAPI 2.0) or the servers.url (in OpenAPI 3.x) property to the domain name of the Vertex AI Search or ESPv2 Beta URL. For example

    host: gateway-12345-uc.a.run.app
  3. Deploy the OpenAPI definition to Vertex AI Search or ESPv2 Beta.

  4. Access your API by using the Vertex AI Search or ESPv2 Beta URL. In the preceding OpenAPI definitions, the paths element is set to /hello so you can access this API by using the following URL:

    https://gateway-12345-uc.a.run.app/hello

To use the same API definition to create an API config for API Gateway, you can either delete the host or servers.url property entirely, or leave it in the file. API Gateway does not enforce the value of the host property.

The URL of the deployed gateway, and therefore the URL that your clients use to access your API, is defined when you create the gateway, in the form:

https:// GATEWAY_ID 
- HASH 
. REGION_CODE 
.gateway.dev

where GATEWAY_ID is the name of the gateway, HASH is the unique hash code generated when you deployed the API, and REGION_CODE is the code for the Google Cloud region where you deployed the gateway.

After you deploy an API to a gateway instance, the URL you use to access /hello is then:

https:// my-gateway- a12bcd345e67f89g0h. uc.gateway.dev/hello

For more on deploying APIs, see API Gateway Deployment Model .

For more on creating the OpenAPI spec for your API definition, see OpenAPI overview .

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: