Manage API Lifecycle with apic
Last updated
Last updated
The diagram below show the API lifecycle in API Connect.
To push a local API to a catalog in API Connect Manager and consecutively stage and publish the state of the API, this is the appropriate workflow:
Edit your API on localhost
Login to APIC to get a JSON Web Token
List the Catalogs in API Connect: apic catalogs
Create a new Catalog: apic catalogs:create
Push or Replace a Draft API: apic drafts:push [-r ibm-x-name:version]
List the API Products: apic products:list
Create a new API Product on localhost: apic create --type product
Push an API Product (only the product artifact without the API spec) to the Catalog: apic drafts:push test-product.yaml --product-only
Stage the Product with associated API: apic publish --stage
Publish the Product: apic publish
To find the organization, server etc, urldecode the apim_url
parameter in the URL to access API Connect Manager (apim) via your browser,
decodes to
Note that the organization to be used in apic
commands is not your IBM Cloud organization, but a separate API Connect organization.
$ apic login -u user1@us.ibm.com -p passw0rd -s apimanager.us-south.apiconnect.cloud.ibm.com
$ apic catalogs --organization 1a23bc456de78f901gh23ij4 --server apimanager.us-south.apiconnect.cloud.ibm.com apic-catalog://apimanager.us-south.apiconnect.cloud.ibm.com/orgs/1a23bc456de78f901gh23ij4/catalogs/sandbox apic-catalog://apimanager.us-south.apiconnect.cloud.ibm.com/orgs/1a23bc456de78f901gh23ij4/catalogs/test
$ apic catalogs:create Test --name test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Created 1a23bc456de78f901gh23ij4:Test
$ apic drafts:push guestbook-api-swagger.json -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com
x-ibm-name:version
$ apic drafts:push guestbook-api-swagger.json -r api-f75f1:1.0.0 -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com
Your Open API Spec or Swagger definition of the API must include an IBM extension property called x-ibm-name
, e.g. api-f75f1
, using <x-ibm-name>:<version>
to replace a specific version of your API.
$ apic products:list -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com appid-test-api:1.0.0 in sl1234567-dev:sandbox [status: published] guestbook-api:1.0.0 in sl1234567-dev:sandbox [status: published] app-id-oauth-proxy-product:1.0.0 in sl1234567-dev:sandbox [status: retired] test-api-product:1.0.0 in sl1234567-dev:sandbox [status: retired]
$ apic create --type product --title "Test-Product" --apis "guestbook-api-swagger.json" Created test-product.yaml product definition [test-product:1.0.0]
$ apic drafts:push test-product.yaml --product-only -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Pushed test-product.yaml product definition to 1a23bc456de78f901gh23ij4:drafts [test-product:1.0.0]
Staged
to catalog$ apic publish --stage test-product.yaml --catalog test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Staged test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0]
Published
to catalogapic publish test-product.yaml --catalog test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Staged test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0] Published test-product.yaml to 1a23bc456de78f901gh23ij4:test [test-product:1.0.0]