Building APIs with Restify

About Me


JS Developer

Client-side, server-side, robotics


Node.JS is an excellent platform to build APIs and Web Services with.

But we keep forcing Express into an API-framework role, which it just wasn't made for.


  • Node.JS Framework
  • Based on Express
  • Just for building RESTful APIs
  • Nothing extra (no client-side app features)

Building an API

  1. Establish your server
  2. Write your routes
  3. Add your middleware

Example Information

The example is a registry for Red Pandas at a zoo.

Red Pandas have a name, an age, and a short description

What's already there is Mongoose models and a GET route to return all pandas

We will write a GET method to look up pandas by name, and a POST method to register a panda.


Why Restify?

  • Tool that does one job, well
  • Stop shoehorning Express
  • Concise, Helpful API
  • Thorough Documentation/Support

Other Benefits

  • Complete control of request, response variables
  • Easy-to-use CORS, versioning plugins
  • Support for nearly all existing middleware

HTTP Clients with Restify

You can wrap requests to other APIs with clients

Allows you to abstract third-party API usage

 var client = restify.createJsonClient({        url: '',        version: '*'});
client.get('/foo/bar', function(err, req, res, obj) { assert.ifError(err); console.log('%j', obj);});



Building APIs with Restify

By kperch

Building APIs with Restify

  • 1,038
Loading comments...

More from kperch