Manage API resources

This page applies to Apigee and Apigee hybrid.

Register an API

When you register an API with API hub, you create and store an entity that represents the API. We call this entity an API resource. API resources stored in API hub are searchable and provide detailed operational and descriptive information about the API. Either at the time you register an API or afterwards, you can add and edit API resource attributes to build a rich description of the API.

Console

To register an API:

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

    Go to API hub
  2. Click Register API.
  3. Under General details, optionally specify a unique ID for the API. If you do not supply an ID, the system will generate one for you. If you wish to enter an ID, click Specify Unique ID.

    The ID must be 4-500 characters, and valid characters are /[A-Z][a-z][0-9]-/. The ID is the last component of the fully qualified, unique API resource name, which is in the format: projects/PROJECT/locations/LOCATION/apis/API_ID

  4. (Required) Provide a display name for the API resource.
  5. Optionally add additional attributes that describe the API. You can return to the API at any time to add or change API attributes. See Edit an API resource.
    • Owner information: (Optional) The name and email address of the API owner.
    • Additional details: (Optional) Specify attributes to help define your API and make it more easily searchable. You can define default values for some of these attributes in Settings. For details, see Manage attributes.
    • User defined attributes: (Optional) These are attributes that you define in Settings. For details, see Manage attributes.
  6. Click Register.

REST

To register an API, use the Create API REST API.

curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -d '{
    "display_name": "DISPLAY_NAME",            # Required attribute
    "description": "DESCRIPTION"               # description is an optional attribute
    }
    'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis?api_id=API_ID

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
  • API_ID: (Optional) Enter a unique ID for the API. If you do not supply this query parameter, the system will generate a unique ID for you. The ID must be 4-500 characters, and valid characters are /[A-Z][a-z][0-9]-/. The ID is the last component of the fully-qualified, unique API resource name, which is in the format: projects/PROJECT/locations/LOCATION/apis/API_ID
  • DISPLAY_NAME: (Required) The display name of the API resource. You can use any name you wish.
  • DESCRIPTION: (Optional) You can add a number of optional attributes to describe the API resource, including a description, an owner, a link to the API documentation, and more. These optional attributes are listed and described in the API resource definition.

List API resources

This section explains how to list the API resources in API hub. By adding a filter, you can limit the APIs returned in the response.

Console

To list API resources:

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

    Go to API hub

    A list of all APIs added to API hub are listed on the APIs home page.

  2. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.

REST

To list all API resources in your API hub project, use the List APIs API:

curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis"
  -X GET -H "Authorization: Bearer: $(gcloud auth print-access-token)" -H "Content-Type: application/json"

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.

Sample output:

{
  "apis": [
    {
      "name": "projects/myproject/locations/us-central1/apis/a035eb3b-658e-467a-89d3-9cca2bbacd32-2",
      "displayName": "TestApi2",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/a035eb3b-658e-467a-89d3-9cca2bbacd32-1",
      "displayName": "TestApi1",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/foo9013cfev",
      "displayName": "sample",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/foo90121",
      "displayName": "sample",
      "documentation": {}
    },
    ...
    ],
    "nextPageToken": "f4f4d78b-a974-46db-a214-dc139f8e9c8a"
  }

REST example with filter

You can filter list results using the API. In this example, we filter APIs based on an system defined attribute:

curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis' \
  -d filter="owner.email=\"testowner3@gmail.com\"" -d page_size=10

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.

Sample output, filtered by owner:

{
  "apis": [
    {
      "name": "projects/myproject/locations/us-central1/apis/theme-park-management-api",
      "displayName": "Theme Park Management API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/restaurant-api",
      "displayName": "Restaurant API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/casino-management-api",
      "displayName": "Casino Management API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/hotel-boooking-api",
      "displayName": "Hotel Booking API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/test-march-26-api3",
      "displayName": "Test Pets API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/test-march-26-api2",
      "displayName": "Test Pets API",
      "documentation": {}
    },
    {
      "name": "projects/myproject/locations/us-central1/apis/test-march-26-api1",
      "displayName": "Test Pets API",
      "documentation": {}
    }
  ]
}

Get API resource details

This section explains how to get the details about an API resource.

Console

To view details of an API resource:

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

    Go to API hub
  2. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API.
  3. Click an API to view its details page.

REST

To view details of an API resource, use the Get API resource details API:

curl "https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID"
  -H "Authorization: Bearer: $(gcloud auth print-access-token)" -X GET -H "Content-Type: application/json"

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
  • API_ID: The unique ID of the API resource.

Sample output:

{
  "name": "projects/myproject/locations/us-central1/apis/myapi",
  "displayName": "My Test API",
  "description": "This is a test API.",
  "documentation": {},
  "owner": {
    "displayName": "Test API,
    "email": "testowner@gmail.com"
  },
  "versions": [
    "projects/myproject/locations/us-central1/apis/myapi/versions/myapi-version1"
  ],
  "createTime": "2024-03-26T10:13:15.668867002Z",
  "updateTime": "2024-03-26T10:13:16.700716401Z"
}

Delete an API resource

This section explains how to delete an API resource.

Console

To delete an API resource:

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

    Go to API hub
  2. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API to delete.
  3. From the Actions menu (the right side of the row containing the API), click Delete.

REST

To delete an API from API hub, use the Delete API API:

curl -X DELETE -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID'

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
  • API_ID: The unique ID of the API resource to delete.

Edit an API resource

This section explains how to edit an API resource. Not all API resource attributes are editable. For the list of editable attributes, see the Patch API reference document.

Console

To edit an API:

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

    Go to API hub
  2. Use Filter to specify keywords to filter the list of APIs. If needed, use Search to locate an API to edit.
  3. Click an API to view its details page.
  4. Click Edit API.
  5. On the Edit API page, make your changes. Click Continue to move to the next set of editable attributes.
    • General details: You can edit the display name of the API.
    • Owner information: The name and email address of the API owner.
    • Additional details: These are the system-defined attributes. You can specify custom default values for these attributes in Manage attributes.
    • User defined attributes: These are the custom, user-defined attributes. You can specify custom attributes in Manage attributes.
  6. Click Save.

REST

To edit an API resource, use the Patch API resource API.

curl -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -d '{
          "display_name": "Updated Test Docs API",        # Example request body with changes
          "description": "This is the updated test API.",
          "owner": {
            "display_name": "Updated Docs Owner",
            "email": "updateddocsowner@gmail.com"
            }
          }
          ' https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/apis/API_ID

Replace the following:

  • HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
  • HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
  • API_ID: The unique ID of the API to update.
  • Request Body: Use the request body to specify the attributes you wish to change. See the API request body description.