This tutorial shows you how to define and implement a REST API definition that proxies an
existing service in IBM® API
Connect Version 5.0.7 and
later.
Before you begin
The following diagram shows the sequential flow through the IBM API
Connect Developer toolkit tutorials for working with API definitions that call an existing endpoint. Before beginning a tutorial, ensure that you have completed the previous tutorials in the sequence. You can click a tutorial in the diagram to open the instructions for that tutorial.
Creating a REST API definition
Add and define a REST API to return the branch details of an example BankA.
To add and define a REST API, complete the following steps:
- Create a folder to hold your API and Product definitions, and change to that folder in a command window.
- Change directories to your LoopBack® project and enter the following command:
apic edit
After a brief pause, the console displays this
message:
Express server listening on http://127.0.0.1:9000
API Designer opens in your web
browser, initially displaying the login page if you haven't logged in recently.
Note: The login
page prompts you to Sign in with IBM Cloud. Enter your IBM Cloud credentials, which authenticates you
on IBM Cloud and provides access to the
API Manager features such as Publish, Explore, and Analytics. You will continue to work in API
Designer locally to create APIs, models and data sources.
where port_number is the port number to use.
- Log in to APIConnect Designer with the appropriate method.
- Click .
- Enter the appropriate information to create a REST API definition.
- In the Title field, enter Branches.
- The Name and Base Path fields autopopulate with
the terms branches and /branches respectively.
- Leave the Version field at 1.0.0.
- Leave the default Additional properties as they are.
- You do not add a product at this time, click Create API.
- If the API Editor help screen appears, click the sentence Learn more about composing APIs, or click Got it! to access the main screen immediately.
- In the side bar, click Lifecycle to display the Lifecycle panel. Ensure that the Enforced, Testable, and CORS toggles are set to the On position as shown in the following screen capture:

- In the side bar, click Security Definitions to display the
Security Definitions panel. Notice that clientIdHeader
security definition already exists, and in the Security section you see that
Option 1 is active with clientIdHeader (API Key).
- In the side bar, select Paths to display the Paths
panel. Create a new path by clicking the Add Path icon
.
- In the Path field, replace the default path segment with /details. When an operation is called, this path segment is appended to the URL of your API.

- By default, a single GET operation is already in your Path. Click the GET
button to expand the setting dialog.
- For the operation, provide a summary and a description as in the following table.
Table 1. Operation definition values
Field |
Value |
Summary |
Branch details |
Description |
Retrieve details of the current branches of BankA |

- In the side bar, click Definitions to display the
Definitions panel. Add a Definition by clicking the Add
Definition icon
.
- Expand your new definition by clicking new-definition-1. For the Name field, enter address, and a Description of The format of the address object.
- Using the same Definitions panel, configure the
Properties definition according to the following table. Edit the default
property and then create new properties by clicking Add Property and editing
the default values.
Table 2. Properties
Property Name |
Description |
Type |
Example |
street1 |
The first line of the address |
string |
4660 La Jolla Village Drive |
street2 |
The second line of the address |
string |
Suite 300 |
city |
The city of the address |
string |
San Diego |
state |
The state of the address |
string |
CA |
zip_code |
The zip code of the address |
string |
92122 |
This is an OpenAPI (Swagger 2.0) schema
definition and is presented to developers in the Developer
Portal to provide them with information
about the type of data to expect in their response.
The Required
column indicates whether a property is required for success if a rest-validate policy uses
the definition to perform validation. In this tutorial, no validation is performed and so none of
your properties need to be marked as required.
- Create a second definition by clicking the Add icon
in the Definitions panel.
- Name the definition branch and, in the Description field, enter The format of the branch field.
- Configure the branch definition to have the properties listed in the following table by creating new properties and editing the default property. Create new properties by clicking Add Property.
Table 3. Properties
Property Name |
Description |
Type |
Example |
address |
The address of the branch |
address |
|
type |
The type of branch |
string |
atm |
id |
The ID of the branch |
string |
9d72ece0-7e7b-11e5-9038-55f9f9c08c06 |
Notice that for the address property, the type of the property references another definition within your API and the example is left blank. In this manner, you can create complex data structures.

- In the side bar, select Paths to display the Paths panel. For the /details Path, click GET to expand the available settings. Include the branch definition in the GET operation Status Code 200 response by clicking the Schema field and selecting branch from the drop-down list.
- In the submenu navigation bar, click the Assemble tab to open the
assemble view.
- Access the invoke policy property sheet by clicking
the invoke label.
- Populate the Title, Description, and
URL fields according to the following table. When called, your API now
invokes the existing Branches API and uses
its response. In this tutorial, no transformations are applied to the response of this API and so
the entirety of the response is returned to the caller. You can see this response at https://apictutorials.mybluemix.net/branches.
Table 4. invoke fields
Field |
Value |
Title |
Branches Invoke |
Description |
Invoke an API to retrieve the status of all branches in the BankA
system |
URL |
https://apictutorials.mybluemix.net/branches |
Leave the remaining fields with their default values.
- Click the Save icon
to save your changes.
- Click the Source tab to view the OpenAPI (Swagger 2.0) definition of your API. All the
configuration you have performed is included in this definition, either as part of the standard OpenAPI (Swagger 2.0) schema, or as part of the
x-ibm-configuration
extension.
Your REST API is defined. This example helped you to configure the REST API invocation through
the Assembly tool. No coding was required. The definitions help developers who are creating
applications and integrating with the BankA Branches REST API for the first time.
Testing the REST API
Test your REST API to ensure that it is defined and implemented correctly.
To test the REST API, complete the following steps:
- Start the local test servers by completing the following steps:
- In the test console at the bottom of the screen, click the Start the servers icon:
- Wait until the
Running
message is displayed:Depending on your project configuration and whether other processes are running, a different port number might be displayed.
Note: If your
Micro Gateway is already running, you must restart it before you can test your changes, by clicking the
Restart the servers icon
.
- Click the Assemble tab.
- Click the Test icon
. The test tool opens, overlaying the palette.
- In the Operation section, use the drop-down menu to select the
get /details operation.
- At the bottom of the section, click Invoke. The operation is called by
the test tool. The response of your API is shown in the test tool.
In other tutorials you get a chance to test the API by using the Developer Portal and API Manager test tools, both of which run
online.
Creating a Product and a Plan for the REST API
Create a Product and a Plan so that you can later stage or publish your APIs.
To create a Product, complete the following steps:
- Click All APIs and then click the Products
tab.
- Click Add and then click New Product. The
New Product
window opens.
- Complete the fields as shown in the following table and then click Create product.
Table 5. Product fields
Field Name |
Value |
Title |
Banking Services |
Name |
banking-services |
Version |
1.0.0 |
- In the Visibility section you can control who the Product is visible to
and who can subscribe to its Plans. The Product visibility is set to
Public
and so anybody
will be able to see the Product when it is published to the Developer
Portal. When published, the Plans can be
subscribed to by Authenticated users
, which refers to users who have accounts in the Developer
Portal.
- In the APIs section, click the Add API icon
. The Select APIs window opens.
- Select the Branches API.
- Click Apply.
- Expand the Plan titled Default that has been automatically created.
Because no APIs have been excluded, the only API in the Product is included in the Plan.
- Enter Basic for the Title field and the
Name field.
- Add a rate limit to your /details operation by completing the following steps:
- Expand the Branches API.
- Click Override rate limit beside the get /details operation.
- Use the controls to set the rate limit as 10 requests per 1 minute against rate-limit-1, and select Enforce hard limit.

- Click the Save icon
to save your changes.
You have created the Banking Services Product with the Basic Plan within it, you added the
Branches API to the Basic Plan, added a rate limit to the
rate-limit-1
operation,
and staged your Banking Services Product to your development environment.
Note: These steps are not
necessary to test your APIs offline, but a Product is needed when making your APIs externally
available.
Publishing your Product
Publish your Product and the API it contains to make them externally available for later
tutorials.
- In the API Designer, click
Publish and then click Add and Manage Targets.
- Click Add a different target.
- In the API Connect host address field, enter the
address of your Management server, for example, example.host.com.
- Provide a user name and password for an API Manager account on your server and then
click Sign in.
- In the Organization field, select the provider organization that you want
to publish with.
- Select Sandbox from the list of Catalogs. If you have a large number of
Catalogs, use the Search field to refine the list of Catalogs.
- Click Save.
- Click Publish and then click your newly created target.
- Select Select specific products and then select your Banking Services Product.
- Click Publish. Your Product is now available through your gateway server
and visible in both API Manager and the Developer Portal,
Your Product and the API it contains are published to your specified target.
What you did in this tutorial
In this tutorial, you completed the following activities:
- Created a REST API definition.
- Tested a REST API.
- Created a Product that contains a Plan.
- Published a Product to a Catalog.