Introduction to dependencies

This page applies to Apigee and Apigee hybrid.

API hub dependencies help you see and manage the relationships between API operations. Finding and tracking an API's dependencies helps you manage your API ecosystem more efficiently. For example, dependencies can help you discover the potential impact of changing or deprecating an API, troubleshoot issues, or analyze adherence to cost or compliance regulations. The APIs can be stored within API hub or external to API hub.

What is a dependency?

API hub models a dependency as a directional relationship between API operations, where one API operation is the supplier and the other the consumer. For example, let's say the PetStore API calls an operation in the Location API. In this case, the PetStore API is dependent on an operation provided by the Location API. In API hub, we refer to PetStore as the consumer and Location as the supplier.

Figure 1 illustrates the supplier/consumer relationship between API operations. The Payment API's /debit operation consumes the Fraud Detection API's /detect operation. The debit operation is the consumer, and the fraud detection operation is the supplier in this relationship.

Likewise, /detect consumes operations that are supplied by the UserProfile API and the GeoLocation API. In this case, the /detect operation is the consumer and the other two are the suppliers.

API hub dependencies API hub dependencies

Figure 1. Mapping of API dependencies

Create a dependency

You can create a dependency between API operations added to API hub from an uploaded API specification or an external API.

The basic steps to create a dependency in API hub are:

  1. Find two APIs that may have operations that may be dependent. The operations may be in registered APIs or external APIs.
  2. Determine which API is the supplier and which is the consumer. As discussed previously, the consumer invokes the supplier.
  3. Use the Create Dependency API to create the dependency between the supplier and consumer.

For details on calling the Create Dependency API and an example, see Create Dependency API.

Find dependencies

The List Dependency API is a good way to find dependencies in API hub. The API lets you filter on the fields consumer.operation_resource_name, consumer.external_api_resource_name, supplier.operation_resource_name, and supplier.external_api_resource_name.

The basic steps for finding dependencies are:

  1. Use the List Dependency API to list all dependencies or use the API's filter feature to narrow your search.
  2. Use the Get Dependency API to drill down into any broken dependencies to discover more details such as the supplier name.

Here's an example API call to list dependencies:

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

Identify broken dependencies

To identify broken dependencies, follow these basic steps:

  1. Use the List Dependency API to list all dependencies or use the API's filter feature to narrow your search.
  2. Identify which of the returned dependencies have an error flag set.
  3. Use the Get Dependency API to drill down into any broken dependencies to discover more details such as the supplier name.

    Here's a sample response, where the error condition indicates the supplier operation was removed:

    {
      "name": "projects/common-dev-15/locations/us-central1/dependencies/user-to-pet",
      "consumer": {
          "displayName": "POST - /v2/user",
          "operationResourceName": "projects/common-dev-15/locations/us-central1/apis/payments-api/versions/2ff89c88-e8b6-48c4-a1c2-bdbb2a929bde/operations/createuser"
      },
      "supplier": {
          "displayName": "POST - /v2/pet",
          "operationResourceName": "projects/common-dev-15/locations/us-central1/apis/payments-api/versions/2ff89c88-e8b6-48c4-a1c2-bdbb2a929bde/operations/addpet"
      },
      "state": "VALIDATED",
      "description": "Dependency from user to pet API",
      "discoveryMode": "MANUAL",
      "createTime": "2024-04-17T19:33:31.215978712Z",
      "updateTime": "2024-04-17T19:33:31.737505297Z",
      {
        "error": "SUPPLIER_NOT_FOUND",
        "errorTime": 2024-05-18T20:23:42.465324Z
      }
    }

Other dependency operations

After you create a dependency, you can use API hub APIs to get details for a dependency, find dependencies by filtering a list of all dependencies in API hub, delete a dependency, and update a dependency's description. All of the Dependency APIs are described in detail in the API reference and in Manage dependencies.