Get started with API Gateway and API hub

This tutorial shows you how to connect API Gateway with API hub to enable seamless publishing of API metadata from your API Gateway project to API hub.

In this tutorial, you'll use the Google Cloud console.

Task List

Use the following task list as you work through the tutorial. All tasks are required to connect API Gateway with API hub.

  1. Perform the prerequisite steps described in Before you begin.

  2. Deploy an API to API Gateway.

  3. Attach your API Gateway project to API hub.

  4. View your API Gateway API in API hub.

  5. Avoid incurring charges to your Google Cloud account. See Clean up.

Before you begin

Before you begin, ensure that you have completed the following prerequisite steps:

  1. Set up API Gateway in your project.

  2. Set up API hub in your host project.

Set up API Gateway in your project

To set up API Gateway in your project, do the following:

  1. In the Google Cloud console, go to the API Gateway page.

    Go to API Gateway

  2. API Gateway requires that you enable the following Google services:

    Name Title
    apigateway.googleapis.com API Gateway API
    servicemanagement.googleapis.com Service Management API
    servicecontrol.googleapis.com Service Control API

    If you have not previously enabled these services for the project you select, you are prompted to do so.

  3. Confirm that billing is enabled for your project.

    Learn how to enable billing

Set up API hub in your host project

  1. Create or select a Google Cloud project to use as your host project.

    A host project is a Google Cloud project in your Google Cloud organization that you designate as the consumer project for all API hub resources. A single API hub instance can be provisioned per host project.

    To provide centralized discovery of APIs across all of your API Gateways, we recommend using one dedicated host project for the API hub instance and attaching multiple API Gateway projects, referred to as runtime projects, to the API hub instance.

  2. Grant Identity and Access Management (IAM) roles required to connect API Gateway with API hub.

  3. Provision API hub in your host project.

Deploy an API to API Gateway

Complete the API Gateway quickstart to deploy a "hello world" Cloud Run service and create a gateway that points to that service.

For example, the helloworld API is deployed to the helloworld-gateway API Gateway, as shown on the Gateways page in Google Cloud console.

helloworld API hosted on helloworld-gateway gateway

Attach your API Gateway project to API hub

To attach your API Gateway project to API hub, do the following:

  1. In the Google Cloud console, go to the API hub page.

    Go to API hub

  2. Select your API hub host project in the drop-down.
  3. Click Settings from the left navigation menu to open the Settings page.
  4. Go to the Project associations tab.
  5. Click Attach runtime project.
    This displays the Select a resource pane.
  6. Click the Google Cloud project where API Gateway is provisioned.
  7. In the Project association settings pane, select API Gateway and any other API assets you want to automatically import.
  8. Click Save.

Your runtime project is attached and displayed in the list of attached runtime projects in the Google Cloud console.

For example:

myproject project attached as a runtime project in API hub

View your API Gateway API in API hub

To view your API Gateway API in API hub, do the following:

  1. In the Google Cloud console, go to the APIs page in API hub.

    Go to API hub

  2. Locate the "hello world" API you deployed to API Gateway.

    If necessary, select Gateway: API Gateway in the Filter drop-down to display only the API Gateway APIs.

    For example:

    helloworld API displayed on APIs page in hub

  3. Click the API to view more details, including the API metadata.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, you can:

Alternatively, you can also delete the Google Cloud projects used for this tutorial.

What's next