Manage API Lifecycle with apic
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 catalogsCreate a new Catalog:
apic catalogs:createPush or Replace a Draft API:
apic drafts:push [-r ibm-x-name:version]List the API Products:
apic products:listCreate a new API Product on localhost:
apic create --type productPush an API Product (only the product artifact without the API spec) to the Catalog:
apic drafts:push test-product.yaml --product-onlyStage the Product with associated API:
apic publish --stagePublish 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.
Login - gets JSON Web Token
$ apic login -u [email protected] -p passw0rd -s apimanager.us-south.apiconnect.cloud.ibm.com
List Catalogs
$ 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
Create Catalog
$ apic catalogs:create Test --name test -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com Created 1a23bc456de78f901gh23ij4:Test
Push API to Drafts
$ apic drafts:push guestbook-api-swagger.json -o 1a23bc456de78f901gh23ij4 -s apimanager.us-south.apiconnect.cloud.ibm.com
Push API to Drafts replacing specified x-ibm-name:version
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.
List product
$ 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]
Create Product on localhost
$ apic create --type product --title "Test-Product" --apis "guestbook-api-swagger.json" Created test-product.yaml product definition [test-product:1.0.0]
Stage product
$ 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]
Publish product to state Staged to catalog
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]
Publish product to state Published to catalog
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]
Last updated
Was this helpful?