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

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

  1. Find two APIs that may have dependencies you wish to track.
  2. List the versions of the two APIs using the List Versions API. Or, you can use the List Operations API and filter results to find dependent operations.
  3. Determine which operation is the supplier and which is the consumer. As discussed previously, the consumer operation invokes an operation from the supplier.
  4. Use the Create Dependency API to create the dependency between the supplier operation and consumer operation.

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 based on key attributes, including the source operation name, the destination operation name, and the state of the dependency.

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.