The Apigee API can be used to programmatically develop and manage APIs with a set of RESTful operations.
You can use the Apigee API to integrate API proxy management into your organization's software development lifecycle (SDLC). A common usage of the Apigee API is to write scripts or code that deploy API proxies or that migrate API proxies from one environment to another, as part of a larger automated process that also deploys or migrates other applications.
For more information, see Apigee API.
Enabling the Apigee API
Obtaining an OAuth 2.0 access token
The Apigee API supports OAuth 2.0 for user authentication. With OAuth 2.0, you exchange your Google Cloud credentials for an access token that you can then use to make secure calls to the Apigee API. Once you obtain a token, you do not need to exchange your credentials again until the token expires.
To obtain an OAuth 2.0 access token:
- Generate a key for your service account using the GCP console,
as described in Creating and managing service account keys.
A JSON file that contains your service account credentials is downloaded to your computer.
- Using your Google Cloud credentials, you can obtain an OAuth 2.0 access token to pass with calls to the
Apigee API using one of the following methods:
Use gcloud to obtain an OAuth 2.0 access token, passing the service account credentials JSON file that you downloaded in step 1 using
GOOGLE_APPLICATION_CREDENTIALSenvironment variable. For more information, see gcloud beta auth application-default print-access-token.
gcloud auth application-default print-access-token
Use oauth2l to obtain an OAuth 2.0 access token, passing the service account credentials JSON file that you downloaded in step 1.
oauth2l fetch --json ~/sa-credentials-file.json cloud-platform
An OAuth2.0 token is returned.
- Copy the OAuth 2.0 token returned and store it in a variable, such as
TOKEN. For example:
- When you call the Apigee API, pass the OAuth 2.0 access token in the Authorization header.
curl "https://apigee.googleapis.com/v1/organizations/myorg/apis/myApiProxy" \ -X GET \ -H "Authorization: Bearer $TOKEN"
Setting environment variables for Apigee API requests
The Apigee API and gcloud CLI examples provided throughout the documentation use one or more of the environment variables defined in the following table.
By setting the environment variables upfront to meaningful values in your environment, you can copy and paste the example requests to execute them in your own environment with minimal or no modifications.
||Name of your API proxy.|
||Name of the API product.|
||ID of an app.|
||Email address of the developer.|
||Name of your environment, such as |
||Name of your resource.|
||Your Apigee organization.|
||Revision number of your API proxy.|
||Name of your shared flow.|
The examples within this section use
curl to demonstrate how to develop applications
using the Apigee API.
curl is an open source, command-line tool for transferring data
with URL syntax, supporting common protocols such as HTTP and HTTPS.
The following table summarizes the curl command-line options used in the examples.
||Defines the request body, which you can pass directly or by specifying a filename.|
||Defines form-based data that you can pass by specifying a filename.|
||Defines a request header.
You must pass the following information in the request header:
||Specifies the type of request (GET, POST, and so on).|
curl "https://apigee.googleapis.com/v1/organizations/$ORG/apis" \ -X GET \ -H "Authorization: Bearer $TOKEN"
$TOKEN is set to your OAuth 2.0 access token, as described in
Obtaining an OAuth 2.0 access token.