Page Contents

Previously: This article continues off from Implmenting features.

Preparing your API for consumption

Interacting with your API

We’ll use the repo loopback4-example-getting-started to demonstrate how Swagger UI can be used to test your endpoints.

First, git clone the repository, install its dependencies, and run the application:

$ git clone
$ cd loopback4-example-getting-started
$ npm i
$ npm start

Open http://localhost:3000/swagger-ui to see the API endpoints defined by swagger.json.

The Swagger UI displays all of the endpoints defined in your application.

Clicking on one of the endpoints will show the endpoint’s documentation as defined in your API spec. Next, click on Try It Out to send a request to the endpoint. If the endpoint takes parameters, assign the values before the request is sent. If the parameter involves a body, a template is given for you to edit as specified in your spec. Click Execute to send the request:

The response to the request can be seen below the Execute button, where the response code and the body are displayed. Ideally, each endpoint should be tested with good and bad inputs to confirm that the returned responses are as expected.

Closing thoughts

Congratulations! You now have successfully created and tested an API with LoopBack 4. We hope you enjoy the test-drive. Your feedback matters and please share your thoughts with us.

This is just the beginning of the full LoopBack 4 developer experience. The first beta release lays out the new foundation of LoopBack for extension developers. It also demonstrates a path to create REST APIs from OpenAPI specs together with Controllers and Repositories. More features will be added in the coming weeks and months.

Here is a sneak peek of what’s coming:

The train is moving and welcome on board! Your participation and contribution will make LoopBack 4 an even more powerful framework and greater community/ecosystem. The team is very excited about the new journey. We look forward to working with you on more ideas, more pull requests, and more extension modules. Let’s make LoopBack 4 rock together!