Slide 1

Slide 1 text

Wiring API’s in Node.js by Rahul Trikha @rahult

Slide 2

Slide 2 text

What is an API Image: http://blogs.msdn.com/b/martinkearn/archive/2015/01/05/introduction-to-rest-and-net-web-api.aspx

Slide 3

Slide 3 text

What is REST? REST stands for ‘Representational State Transfer’ and it is an architectural pattern for creating an API that uses HTTP as its underlying communication method. Image: http://maxoffsky.com/code-blog/building-restful-api-in-laravel-start-here/

Slide 4

Slide 4 text

What is REST? • Resources – REST uses addressable resources • Request Verbs – [GET, POST, PUT, DELETE] • Request Headers – These are additional instructions that are sent with the request. These might define what type of response is required or authorisation details. • Request Body - Typically sent as the request body in the format of JSON or XML. • Response Body – Returned by the API, this might be a JSON or XML document. • Response Status codes – These codes are issues with the response and give the client details on the status of the request.

Slide 5

Slide 5 text

Popular REST API Examples • https://developer.github.com/v3/ • https://developers.google.com/maps/ • https://www.flickr.com/services/api/ • https://dev.twitter.com/rest/public • https://www.twilio.com/docs/api/rest • https://developer.paypal.com/docs/api/ • https://stripe.com/docs/api#intro

Slide 6

Slide 6 text

What is Node.js • Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. • Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. • Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Slide 7

Slide 7 text

Why to use Node.js for API’s • Building light-weight REST / JSON api's is something where node.js really shines. • Its non-blocking I/O model combined with JavaScript make it a great choice for wrapping other data sources such as databases or web services and exposing them via a JSON interface.

Slide 8

Slide 8 text

Node.js Web Frameworks • http://expressjs.com/ • http://hapijs.com/ • http://sailsjs.org/ • https://strongloop.com/

Slide 9

Slide 9 text

Strongloop • The StrongLoop API Platform features the popular open source LoopBack framework. LoopBack enables you to quickly compose scalable APIs, runs on top of the Express web framework and conforms to the Swagger 2.0 specification. • LoopBack is built on top of Express, the world’s most popular web framework for Node • Easily create REST API endpoints • Support for social logins via Passport.js • Swagger 2.0 Compliant

Slide 10

Slide 10 text

Demo

Slide 11

Slide 11 text

ORMs • http://knexjs.org/ • http://bookshelfjs.org/ • http://sequelizejs.com/ • https://thinky.io/

Slide 12

Slide 12 text

Questions? 12