Sequelize-restful-extended: Do more with REST in seconds

A connect module based on a fork of sequelize-restful. Creates a restful API with associations from your Sequelize models and allows you to include parameters like sort, offset, limit and order. Also allows to filter by date ranges.

It uses the Sequelize function findAndCountAll instead of findAll. Thanks to this, the basic GET request returns the total count of rows in the response. This number doesn’t take account of the query parameters offset and limit. This feature makes easier to do pagination using the generated API.


var express = require('express')
, Sequelize = require('sequelize')
, http = require('http')
, restful = require('sequelize-restful-extended')
, sequelize = new Sequelize('database', 'username', 'password')
, app = express()

// define all your models before the configure block

app.configure(function() {
app.use(restful(sequelize, { /* options */ }))

http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'))


// Parameter: endpoint
// Description: Define the path to the restful API.
// Default: '/api'

endpoint: '/restful',

// Parameter: allowed
// Description: Define which models will be exposed through the restful API
// Default: 'new Array()' if it is an Empty array, all the models will be exposed by default

allowed: new Array('Model0', 'Model1', 'Model2'),

// Parameter: extendedMode
// Description: If it's true, all GET request uses the findAndCountAll function of Sequelize,
// returning the count on the response. If it's false uses the default findAll.
// Default: true

extendedMode: true

For more information I recommend you to visit my page on GitHub. You also can download this module from npm.

Good coding!


  1. Hey, the module is awesome. It made everything pretty easy. But stuck at a point, any help will be appreciable. I have two models which are associated. Now when I make two different post request to post data to them. The problem is the foreign key value in one model is not updated when the data is posted to associated model. Could that be a problem with the definition of associations in models or with sequelize-restful?


Leave a Reply

Your email address will not be published. Required fields are marked *