This page applies to Apigee and Apigee hybrid.
View Apigee Edge documentation.
If you want to build your own custom portal or manage the purchasing process manually, the following sections describe how to purchase and manage API product subscriptions using the API. See also Integrate Apigee monetization in your Drupal-based developer portal.
Purchasing API product subscriptions using the API
To purchase an API product subscription, issue a POST
request to the following API:
https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions
Configure the API product subscription request by passing the required fields in the request body, as described in Resource: Subscriptions.
For example, the following API call purchases a subscription to the HelloworldProduct
API product for the specified developer:
curl "https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions" \ -X POST \ -H "Authorization: Bearer $TOKEN" \ -H "Content-type: application/json" \ -d '{"apiproduct":"HelloworldProduct"}'
Where $TOKEN
is set to your OAuth 2.0 access token, as described in
Obtaining an OAuth 2.0 access token. For information about the curl
options used in this example, see
Using curl. For a description of the environment variables used,
see Setting environment variables for Apigee API requests.
The following provides an example of the response output. startTime
is set to the current time.
{ "name": "69f8bb42-a8e4-4a2c-b932-d82b51d37b72", "apiproduct": "HelloworldProduct", "startTime": "1615987132000", "createdAt": "1615903252000", "lastModifiedAt": "1615903252000" }
For more information, see the Purchase API product subscription API
Expiring an API product subscription immediately
To expire an API product subscription immediately, issue a POST
request to the following API:
https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions/$SUBSCRIPTION:expire
For example, the following API call expires the API product subscription with the name 69f8bb42-a8e4-4a2c-b932-d82b51d37b72
for the specified developer:
curl "https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions/69f8bb42-a8e4-4a2c-b932-d82b51d37b72:expire" \ -X POST \ -H "Authorization: Bearer $TOKEN"
Where $TOKEN
is set to your OAuth 2.0 access token, as described in
Obtaining an OAuth 2.0 access token. For information about the curl
options used in this example, see
Using curl. For a description of the environment variables used,
see Setting environment variables for Apigee API requests.
The following provides an example of the response output. endTime
is set to the current time.
{ "name": "33f8dd42-c7x5-3s3f-b098-d=c93h22m36b47", "apiproduct": "WeatherReport", "startTime": "1613494852000", "endTime" : "1617894954000", "createdAt": "1613494852000", "lastModifiedAt": "1613494852000" }
Listing all API product subscriptions for a developer
To list all API product subscriptions for a developer, issue a GET
request to the following API:
https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions
Optionally, you can pass the following fields to support pagination:
startKey
to specify the name of the API product subscription from which to start displaying the list of subscriptions. If omitted, the list starts from the first item. Use withcount
to provide more targeted filtering. For example, to view the API product subscriptions from 51-150, set the value ofstartKey
to the name of the 51st subscription and set the value ofcount
to 100.count
to specify the number of rate plans to return in the API call. Use withstartKey
to provide more targeted filtering. The maximum limit is 1000. Defaults to 100.
For example, the following API call lists all API product subscriptions for the specified developer:
curl "https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions" \ -X GET \ -H "Authorization: Bearer $TOKEN"
Where $TOKEN
is set to your OAuth 2.0 access token, as described in
Obtaining an OAuth 2.0 access token. For information about the curl
options used in this example, see
Using curl. For a description of the environment variables used,
see Setting environment variables for Apigee API requests.
The following provides an example of the response output:
{ "developerSubscriptions": [ { "name": "69f8bb42-a8e4-4a2c-b932-d82b51d37b72", "apiproduct": "HelloworldProduct", "startTime": "1615987132000", "createdAt": "1615903252000", "lastModifiedAt": "1615903252000" }, { "name": "33f8dd42-c7x5-3s3f-b098-d=c93h22m36b47", "apiproduct": "WeatherReport", "startTime": "1614124552000", "createdAt": "1613494852000", "lastModifiedAt": "1613494852000" } ] }
For more information, see the List API product subscriptions API.
Viewing details about an API product subscription
To view details about an API product subscription for a developer, issue a GET
request to the following API:
https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions/$SUBSCRIPTION
For example, the following API call lists all API products subscriptions for the specified developer:
curl "https://apigee.googleapis.com/v1/organizations/$ORG/developers/$DEVELOPER_EMAIL/subscriptions/69f8bb42-a8e4-4a2c-b932-d82b51d37b72" \ -X GET \ -H "Authorization: Bearer $TOKEN"
Where $TOKEN
is set to your OAuth 2.0 access token, as described in
Obtaining an OAuth 2.0 access token. For information about the curl
options used in this example, see
Using curl. For a description of the environment variables used,
see Setting environment variables for Apigee API requests.
The following provides an example of the response output:
{ "name": "69f8bb42-a8e4-4a2c-b932-d82b51d37b72", "apiproduct": "HelloworldProduct", "startTime": "1615987132000", "createdAt": "1615903252000", "lastModifiedAt": "1615903252000" }
For more information, see the Get API product subscription API.