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.
The developer toolkit provides an integrated
development environment for developing APIs and applications that use the LoopBack® framework. To create a new LoopBack
project, use the command apic loopback; then use the apic edit
command to edit the project in the API Designer.
LoopBack is a high-performance Node.js interaction-tier framework for APIs and micro-services. However, you can also use the developer toolkit to create language-independent APIs by using OpenAPI (Swagger 2.0) to proxy to an existing backend implementation or to augment applications developed in other languages or frameworks such as Express®, Java™, Swift, Go, and others.
When using LoopBack projects, you can publish the API to an API Connect Catalog that provides socialization via the developer portal and policy enforcement via the gateway, and the application to an API Connect App that provides Node.js runtime capability. To proxy to existing backend services or develop applications using other languages or frameworks, use OpenAPI projects that support publishing the OpenAPI (Swagger 2.0) definitions to API Connect Catalogs.
Creating development artifact definitions
Use the apic create command to create development artifacts, by using the following commands:
| Command | Description |
|---|---|
apic create --type api |
Create an OpenAPI (Swagger 2.0) definition. |
apic create --type 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 --type product |
Create an API Product definition. |
apic create --type model |
Create a LoopBack model to a LoopBack project: (Use in a LoopBack application project). |
apic create --type datasource |
Create a LoopBack data source to a LoopBack project: (Use in a LoopBack application project). |
--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 --type api --title Routes
apic create --type product --title "Climb On"
You can also create the API and Product definitions at the same time:
apic create --type api --title Routes --product "Climb On"
apic create --type 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 --type api --title Routes
apic create --type api --title Ascents
apic create --type product --title "Climb On" --apis "routes.yaml ascents.yaml"
Validating development artifact definitions
After you edit development artifacts or right 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 APIs created above
apic validate climb-on.yaml --product-only # Validate the Product only (do not validate the referenced APIs)
$ref field to reference a fragment of OpenAPI (Swagger 2.0) code that is defined in a separate file, the $ref field is replaced with the contents of the target file before the API definition is validated by the apic validate command. For more information, see Developing LoopBack applications
After you've created a LoopBack application with the
apic loopback command, you can add additional functionality to the application with
the commands listed in the following table . Run these commands from the application's project root
directory.
| Command | Description |
|---|---|
apic loopback:boot-script |
Create a new boot script. |
apic loopback:acl |
Define an access control list for accessing LoopBack models. |
apic loopback:middleware |
Define and register Express middleware to define the phase of execution. |
apic loopback:property |
Add additional properties to a Loopback model. |
apic loopback:remote-method |
Add remote methods to a LoopBack model. |
apic loopback:relation |
Add relationships between LoopBack models. |
apic loopback:export-api-def |
Export an OpenAPI (Swagger 2.0) and a Product definition from LoopBack models. |
apic loopback:swagger |
Generate a LoopBack application project from an OpenAPI (Swagger 2.0) definition. |
Stability: prototypebecause IBM® is looking for feedback on them before certifying them for production.