| name | gcloud-apihub |
| description | API hub via gcloud (`gcloud apihub`). Manage Apihub resources — apis, api-hub-instances, plugins, deployments, curations, dependencies, attributes, operations. |
gcloud apihub — API hub
Overview
Apigee API hub is a centralized catalog and governance platform for all of the APIs in your organization, regardless of where they run (Apigee, other gateways, or no gateway at all). You register APIs with versions, attach machine-readable specs (OpenAPI and others), record deployments and API operations, and enrich everything with attributes, curations, and dependencies for discovery and governance. A host project runs the API hub instance; runtime projects are attached to it so their APIs (e.g. Apigee proxies) can be registered and auto-discovered, and plugins integrate Google Cloud or third-party sources. The gcloud apihub group covers the full GA surface: instance provisioning, the API/version/spec/operation hierarchy, deployments, governance resources, discovery results, plugins, project registration/attachment, and long-running operations. The service to enable is apihub.googleapis.com.
Quick reference — common workflows
1. Enable the API and grant access
gcloud services enable apihub.googleapis.com --project PROJECT_ID
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="user:USER@example.com" \
--role="roles/apihub.admin"
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="user:USER@example.com" \
--role="roles/apihub.viewer"
2. Provision an API hub instance and register the host project
gcloud apihub api-hub-instances create --project=my-project \
--location=us-central1
gcloud apihub host-project-registrations create \
--host-project-registration=my-registration \
--gcp-project=my-gcp-project --project=my-project \
--location=us-central1
3. Register an API with a version and a spec
gcloud apihub apis create --api=my-api --display-name="My API" \
--project=my-project --location=us-central1
gcloud apihub apis versions create --version=my-version \
--api=my-api --display-name="My Version" --project=my-project \
--location=us-central1
gcloud apihub apis versions specs create --spec=my-spec \
--version=my-version --api=my-api --display-name="My Spec" \
--spec-type=openapi --project=my-project --location=us-central1
4. Lint a spec and retrieve its contents
gcloud apihub apis versions specs lint my-spec \
--version=my-version --api=my-api --project=my-project \
--location=us-central1
gcloud apihub apis versions specs get-contents my-spec --api=my-api \
--version=my-version --location=us-central1
5. Record a deployment
gcloud apihub deployments create --deployment=my-deployment \
--display-name="My Deployment" --deployment-type=apigee \
--project=my-project --location=us-central1
6. Attach a runtime project (and look up existing attachments)
gcloud apihub runtime-project-attachments create \
--runtime-project-attachment=my-attachment \
--runtime-project=my-runtime-project \
--project=my-project --location=us-central1
gcloud apihub runtime-project-attachments lookup \
--service-project=my-service-project --location=us-central1
7. Add a plugin and create a plugin instance
gcloud apihub plugins create --plugin=my-plugin \
--display-name="My Plugin" --type=apigee --project=my-project \
--location=us-central1
gcloud apihub plugins instances create --plugin-instance=my-instance \
--plugin=my-plugin --display-name="My Instance" \
--project=my-project --location=us-central1
Command groups
See index.md for a one-line index of all 83 commands.
Common flags & tips
--location is pervasive. Nearly every command takes --location (the region of the API hub instance, e.g. us-central1) plus --project; both can be inferred from a fully qualified resource name passed as the positional argument.
create commands use resource flags, not positionals. Several reference pages carry the note "The positional argument ... is currently not supported" — pass the ID via the matching flag instead: --api=, --version=, --spec=, --deployment=, --dependency=, --curation=, --plugin=, --plugin-instance=, --attachment style flags (--runtime-project-attachment=), and --host-project-registration=.
- Resource hierarchy:
apis → versions → specs / operations. Commands on nested resources require the ancestors as flags, e.g. specs describe my-spec --version=my-version --api=my-api.
- List commands support the standard gcloud list flags:
--filter, --limit, --page-size, --sort-by, --uri. list commands generally require --location as a flag (there is no positional parent).
- Long-running operations: provisioning and some mutations return operations; track them with
gcloud apihub operations describe/list/wait/cancel/delete.
- Host vs. runtime projects: the API hub instance lives in the host project (
api-hub-instances create, host-project-registrations create); attach service/runtime projects with runtime-project-attachments create, and find which attachment covers a given project with runtime-project-attachments lookup.
- IAM:
roles/apihub.admin grants full access to all API hub resources; roles/apihub.viewer grants read access. Provisioning also involves the API hub service agent (roles/apihub.runtimeProjectServiceAgent). See the predefined-roles docs for the full role list.
beta / alpha
There is no gcloud beta apihub surface (the beta reference URL returns 404). An alpha surface (gcloud alpha apihub) exists and mirrors the same 13 subgroups as GA (addons, api-hub-instances, apis, attributes, curations, dependencies, deployments, discovered-api-observations, external-apis, host-project-registrations, operations, plugins, runtime-project-attachments); it is where new fields and commands appear first and may change without notice.
Official documentation