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

API Gateway supports APIs that are described using the OpenAPI specification, version 2.0. That means you can deploy your OpenAPI specs from Endpoints 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, shown below is a portion of an OpenAPI spec used by Endpoints to define an API to access a backend service deployed on Cloud Functions:

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: ESP_HOST
schemes:
  - https
produces:
  - application/json
paths:
  /hello:
  ...

For Endpoints, you:

  1. Deploy ESP, which creates the URL that you then use to access APIs deployed to ESP. For example:

    https://gateway-12345-uc.a.run.app
  2. Edit the OpenAPI spec to set the hostproperty to the domain name of the ESP URL. For example

    host: gateway-12345-uc.a.run.app
  3. Deploy the OpenAPI spec to ESP.

  4. Access your API by using the ESP URL. In the OpenAPI spec above, 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

As you can see, for Endpoints you must first deploy ESP to be able to set the value of the host property.

To use this API definition to create an API config for API Gateway, you can either delete the host 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 GCP 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