About LoopBack

  • Use the CLI to generate REST APIs
  • Connect devices and browsers to data and services
  • Open source and extensible

Core

Set up models and create REST APIs in minutes

  • Easy-to-use CLI wizard
  • Create models based on your schema if you have one
  • Create dynamic models if you don't
  • Built-in API Explorer

Model relation support

  • Define hasMany, belongsTo, hasAndBelongsToMany relationships
  • Automatically generates corresponding REST endpoints

Easy authentication and authorization setup

  • Built-in role-based access controls
  • oAuth user and registration models baked in
  • Add custom policies using CLI or JSON
  • Browser support (JSONP and CORS)

MIT open-source license

Client SDKs

Native Mobile and Browser SDKs

  • Easily persist data with a database API on the client
  • Store files, send push notifications, and call custom server-side code
  • Android / Java
  • iOS
  • Browser JavaScript (Angular)

Juggler

Connect to backend data stores

  • MySQL, Oracle, MongoDB, and others
  • Other REST services
  • Discovery APIs for Oracle and MySQL

Run ad-hoc queries

  • Run dynamic queries on devices, browsers and the server
  • Support for NoSQL-style queries against relational databases

Add-on Components

Push notifications

  • Backend push system with simple API calls
  • Supports both Android and iOS

Storage service

  • Integrate with cloud storage providers
  • Organize data in containers and files

Third party login

  • Use third party login providers like Facebook, GitHub etc
  • Map inbound and outbound credentials to users

Geolocation

  • Validate and store geolocations
  • Find nearby results with geo filters

More Information

Getting Started

Install

Assuming you have already installed Node...

Install the StrongLoop tools for LoopBack applications.

$ npm install -g strongloop

If you installed slc before, update it.

$ slc update

Create app

Create a "Hello World" LoopBack application.

$ slc loopback
[?] Enter a directory name where to create the project: hello-world
[?] What's the name of your application? hello-world

Create models

$ cd hello-world
$ slc loopback:model

The generator guides you through creating your model. Enter the values highlighted in blue. To accept the default, just press Enter.

[?] Enter the model name: person
[?] Select the data-source to attach person to: db (memory)
[?] Expose person via the REST API? Yes
[?] Custom plural form (used to build REST URL): people
Let's add some person properties now.

Define a firstname property for the person model

Enter an empty property name when done.
[?] Property name: firstname

Hit Enter to accept the default string type:

[?] Property type: (Use arrow keys)
❯ string
  number
  boolean
  object
  array
  date
  buffer
  geopoint
  (other)

Make the property required.

[?] Required? (y/N) y

Repeat these steps for lastname property.

Press Enter when prompted for a property name to finish up and create the model.

Run the application

$ slc run 

This command runs the apps just like node . but enables you to monitor your app with strong agent, run and control a multi-process cluster, and has lots of other devops features. See Getting started with slc for details.

Explore your REST API

Load http://0.0.0.0:3000/explorer to see the built-in API Explorer..

The API Explorer enables you to exercise all the generated API endpoints. There are create, read, update, and delete (CRUD) endpoints for the people model you just created.

For more information, see the Using the API Explorer in the documentation. You may also want to follow the Getting Started tutorial.


 

Examples

  • Office Supplies App - a simple example that illustrates creating models, relations between models, and basic access control.
  • Banking App - Simple mobile app that illustrates how to impose access controls. Front-end uses Angular, Cordova, and Ionic.
  • LoopBack Mobile Getting Started App - Basic example app with both iOs and Android front-ends.
  • Database connector example - illustrates connecting to MySQL, Oracle, PostgreSQL, and MS SQL Server databases. Each database connector has its own branch in the GitHub repository.
  • Datagraph example - illustrates model relationship APIs over REST.
  • Access control example - Example using authentication and authorization.

Create backend app and models

Use the LoopBack Yeaoman generator to create the project and two models for office supplies app.

$ mkdir office-supplies
$ cd office-supplies
$ slc loopback
$ slc loopback:model product
$ slc loopback:model category

Create a secure REST API

Secure all the model APIs, then allow admins to modify products.

$ yo loopbacK:acl

Easily persist data

LoopBack models have a full set of methods for create, read, update, and delete (CRUD) operations. For example:

category.create({name: 'stationery', id: 1});
product.create({
  categoryId: 1,
  name: 'Pencil',
  price: 0.99
});

Define model relations

Use simple JSON declarative syntax to set up relations between models. For example, the following specifies that a product belongs to one category (identified by categoryId) and has one owner (identified by ownerId).

"product": {
    "options": {
      "relations": {
        "category": {
          "model": "category",
          "type": "belongsTo",
          "foreignKey": "categoryId"
        },
        "owner": {
          "model": "category",
          "type": "belongsTo",
          "foreignKey": "ownerId"
        }
      }
    },
    "properties": {},
    "public": true,
    "dataSource": "db"
  },

Run ad-hoc queries

Call directly into the LoopBack APIs directly from iOS, Android, or client JavaScript.

Node.js:

MyProduct.find({
    where: {price: {lt: 100}},
    order: 'price ASC',
    limit: 3
}, function(err, products) {
    ...
});

iOS Objective-C:

[MyProduct createWithDictionary:@{
    @"name": @"Pencil",
    @"price": @0.99
}]

Android Java:

MyProductRepository repo =
    adapter.createRepository(MyProduct.class);
    MyProduct pencil = repo.create();
    pencil.name = "Pencil";
    pencil.price = 0.99;
    pencil.save();

HTML5:

MyProduct.create({
    name: 'Pencil',
    price: 0.99
});

Connect to Oracle database

Easily connect to backend databases such as Oracle.

var loopback = require('loopback');
var ds = loopback.createDataSource('oracle', {
    "host": "demo.strongloop.com",
    "port": 1521,
    "database": "XE",
    "username": "demo",
    "password": "L00pBack"
});

Automatically discover and expose database tables

The Oracle and MySQL connectors provide APIs that enable you to "discover" model definition information from existing databases, including schema information such as column names and datatypes and relation information such as primary and foreign keys.

var ds = require('../data-sources/db.js')('oracle');
// Discover and build models from INVENTORY table
ds.discoverAndBuildModels('INVENTORY',
    {visited: {}, owner: 'LOOPBACK', associations: true},
    function (err, models) {
        models.Inventory.findOne({}, function (err, inv) {
            console.log("Inventory: ", inv);
            inv.product(function (err, prod) {
                console.log("Product: ", prod);
            });
        });
    }
)

Documentation, Blogs, and Tutorials

Powered by LoopBack logo

Add the logo to your LoopBack-powered site or app:

50px x 64px:
100px x 129px:
200px x 258px: