IBM API Connect offers a series of APIs that allow users to have better control over the API Connect instances on IBM Cloud.
These APIs must be accessed using a token-based authentication called JSON Web Token (JWT) for improved security.
Prerequisites
- IBM API Connect plan
- API Connect Developer portal
- The API key of your account. You must have an API key to generate a token. For more information, please check out steps to generate API key.
Goal
In this post, I am going to show you how to obtain the JWT token using a curl command, and then I’ll call an API to get a list of products in a catalog from the developer portal as a demo.
On top of the JWT token, this particular API requires the following header and a parameter when you call it via CURL. Steps 2 and 3 will cover how to obtain necessary elements:
- Header: X-IBM-APIManagement-Context:<providerOrg>.<Catalog>
- Parameter: originURL, which is the URL of your API Connect developer portal
Please note that required headers and parameters vary depending on the API.
Step 1. Obtain the JWT token
Run the following command to obtain the JWT token:
Replace <APIKEY>
with the API key you have and change <REGION>
to the region where your instance is deployed:
- Sydney =
au
- Dallas =
us
- Washington =
us-east
- London =
eu
- Frankfurt =
eu-de
CURL command example:
Response example:
The response contains the JWT token. You need this token when you call APIs, so copy and paste it somewhere secure:
Step 2. Find the catalog name
Each catalog in your API Connect has its display name and a short name. We are going to use the short name when we call APIs, and here is how to find it:
- Open API Connect from the IBM Cloud Dashboard:
- Open a catalog published to the developer portal.
- Go to the Settings > Overview tab and look for the Name:
Step 3. Find the provider organization
Provider organization is a name assigned to your API Connect instance. When you call APIs, you can use either the provider organization name or ID. We used the following API to look up the configuration details of a portal based on its originURL:
Replace <REGION>
with the region where your instance is deployed and change <DEV PORTAL>
to your developer portal home URL:
- Sydney =
au-syd
- Dallas =
us-south
- Washington =
us-east
- London =
eu-gb
- Frankfurt =
eu-de
CURL command example:
Response example:
Step 4. Invoke Manager API
It’s time to get the product list. As per the document, we are calling this API endpoint using CURL:
Replace <JWT token>
with the JWT token obtained in Step 1. Change <providerOrgNAME/ID>
and <Catalog>
to the provider organization name or ID and the catalog short name obtained in Steps 2 and 3. Then, replace <REGION>
with the region where your instance is deployed.
- Sydney =
au-syd
- Dallas =
us-south
- Washington =
us-east
- London =
eu-gb
- Frankfurt =
eu-de
CURL command example:
Response example:
What’s next?
IBM API Connect offers a number of different APIs and now you are ready to explore the options. Please refer to the IBM Knowledge Center for IBM API Connect for the available API list.
For any questions or concerns, please contact IBM Cloud Support.