Creating APIs and applications

You can develop API proxies and API implementations by using the developer toolkit. In the documentation, API refers to the API proxy and application refers to the API implementation.

LoopBack® is a high-performance Node.js interaction-tier framework for APIs and micro-services. The LoopBack framework can be downloaded and installed using the CLI + LoopBack + Designer option for downloading the toolkit. See Installing the toolkit. To create a new LoopBack project, use the command apic lb4.
Note: IBM® API Connect is packaged with, and supports, LoopBack version 4. For more information on how to migrate your LoopBack 3 applications to LoopBack 4, see LoopBack 4 Migration Guide.

You can use the developer toolkit or LoopBack to create language-independent APIs by using OpenAPI to proxy to an existing backend implementation or to augment applications that are developed in other languages or frameworks such as Express®, Java™, Swift, Go, and others.

Creating development artifact definitions

Use the apic create command to create development artifacts, by using the following commands:

Command Description
apic create:api Create an OpenAPI definition.
apic create:api --wsdl filename Create a SOAP API definition from a WSDL definition file, or a .zip file that contains the WSDL definition files for a service. The name and version of the generated API are obtained from the WSDL file.

If you upload a .zip file, you can include in the .zip file an options file to specify additional directives. For details, see Using an options file when importing a WSDL service.

apic create:product Create an API Product definition.
Note: You can create an API or Product from an OpenAPI template file by using the --template template-name option.

You can also create Product and API definitions non-interactively by providing the --title option. This option sets several values that you can also customize with additional options; for example:

apic create:api --title Routes
apic create:product --title "Climb On"

You can also create the API and Product definitions at the same time:

apic create:api --title Routes --product "Climb On"
apic create:api --wsdl globalweather.wsdl --product "Weather Forecasting"

Alternatively, you can create APIs and then reference them when you create a new Product; for example:

apic create:api --title Routes
apic create:api --title Ascents
apic create:product --title "Climb On" --apis "routes.yaml ascents.yaml"

Validating development artifact definitions

After you edit development artifacts or before you publish artifacts, best practice is to validate them; for example:

apic validate routes.yaml                      # Validate an API
apic validate climb-on.yaml                    # Validate the Product and its APIs
apic validate climb-on.yaml --product-only     # Validate the Product only (do not validate the referenced APIs)
Note: If the OpenAPI file that defines your API uses a $ref field to reference a fragment of OpenAPI code that is defined in a separate file,the $ref field is replaced with the contents of the target file before the draft API is created with the apic drafts:validate command. For more information, see Using $ref to reuse code fragments in your OpenAPI files.

Developing LoopBack applications

After you've created a LoopBack application with the apic lb4 app command, you can add additional functionality to the application with the commands listed in the following table. Run these commands from the project root directory of the application. APIs created with LoopBack can be imported into API Manager.

Command Description Subcommands
apic lb4 Create LoopBack project and project artifacts.

With no subcommand, creates a new LoopBack project.

Note: To use the apic lb4 command, you need to add a double dash, --, after the lb4 subcommand to tell apic that the options behind the -- are for the subcommand belonging to lb4. The second -- is to signify the end of the options. For example,
$ apic lb4 controller -- --help
  • app - Create a new LoopBack project (default)
  • controller - Add a controller to a LoopBack 4 application
  • datasource - Add a datasource to a LoopBack 4 application
  • discover - Discover models from relational databases
  • example - Download one of LoopBack 4 example projects
  • extension - Create a LoopBack 4 extension
  • import-lb3-models - Import one or more LoopBack 3 models to a LoopBack 4 application
  • interceptor - Generate interceptors
  • model - Add a new model to a LoopBack 4 application
  • observer - Generate life cycle observers for application start and stop
  • openapi - Generate controllers and models from OpenAPI specs
  • relation - Add a relation between two models in a LoopBack 4 application
  • repository - Add a new repository for a selected model to a LoopBack 4 application
  • rest-crud - Generate rest configs for model endpoints
  • service - Add a new remote or local service to a LoopBack 4 application
  • update - Check or update project dependencies of LoopBack modules