Building APIs using Loopback

Building APIs using Loopback

I have been developing for a while now and I learnt so far is not just writing code but to understand business process and transforming them into computed logic.

Writing code isn’t big thing any more. Writing clever code is the new direction of 2015 coding standard. I like the philosophy introduced by Wordpress developer:


The world has changed a lot since then but one thing has not changed. Code is actually like writing poetry. With the introduction of new languages and platform we are moving into a new era. Modern world is full of micro service architecture, cross platform compatibility, realtime webapps and single backend supporting multiple frontend devices.

Single APIs powering millions of devices running on different platform. You want your APIs to be robust, secure and scalable. There was times when writing APIs take expertise and consume enormous amount of time but now you can build an APIs in less than two weeks and yes I am talking about a robust, secure and scalable API.

There are many frameworks in the market you can use which not only reduce your development lifecycle but also cut down your code you have to write and indeed time consumed in writing it.

Some of the frameworks in the market are:

  • Express
  • Restify
  • Actionhero
  • Loopback

Using framework is somewhat risky and requires some investment. Not only you are following an uncharted domain but also buying framework’s methodologies and restrictions for an anticipated productive gain.

Loopback is one such framework and trust me I admire it. from installation to your first model, loopback will make you up and running in less than 5 minutes. On top of this their documentation is well written and contain sample code throughout. For most of my development lifecycle I concentrate on writing my test cases and loopback takes care of the API’s CRUD functionality.

Why Loopback is Better

There are many features, loopback framework provide. I am going to list few of them that I like

No custom CRUD functionality

Loopback implement most of the required CRUD functionality by inheriting its PersistedModel. Defining the models implements the REST endpoints automatically. There is not need to write handlers for each endpoint. Extending the model is much easy as code reside in individual model JS files and properties in associated model JSON files.

Relationships between Models

Loopback provide many inbuilt relationships like BelongsTo, HasMany, HasManyThrough, HasAndBelongsToMany, Polymorphic and Embedded relations that allow you to connect, query, expose endpoints and perform all sorts of nifty functions with models.

Data Integration

Loopback support all of the major database like Oracle, SQL Server, MongoDB and MySQL. Multiple datasources can be used simultaneously to hold models. Loopback has recently released non-database connector to connect to services like SOAP and REST it easier to connect to third party provider using APIs


Loopback authenticate using local credentials or social plugins via passport. It was also simple to authorize access to protected resources with granular ACLs.


Loopback provide a perfect framework to frequently build apps and gradually reduce code base by almost 75%. This undoubtedly makes the API easier to build, debug, maintain and enhance.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.