Building a

RESTful API with

(and friends)

Bio

I'm Tom: a software developer with 10 years experience building web and mobile apps.

My professional career includes:

Co-founded startup, built web-based touch-screen apps.

Head of mobile web at Bristol-based mobile app development agency.

Founded consultancy, specialising in JavaScript development and training.

Find me everywhere as @fiznool

Why APIs?

A consistent interface to your data and logic.

Why REST?

A consistent design for your API.

GET /api/dogs

GET /api/dogs/1

POST /api/dogs

PUT /api/dogs/1

DELETE /api/dogs/1

Why node.js?

Non-blocking, event-driven architecture

FAST for short, sharp connections: ideal for APIs

Why express.js?

Minimal framework for building web servers.

Supports both view based (HTML)
and data-based (JSON/XML) servers.

Very popular, strong community.

REST 101

Request resources via URLs and HTTP methods:

Respond with status code and data:

GET /api/dogs
GET /api/dogs:id
POST /api/dogs
PUT /api/dogs/:id
DELETE /api/dogs/:id
200 OK
{
  "name": "Benji",
  "breed": "labrador"
}

Use JSON.

Demo Time!

Follow along?

git clone https://github.com/fiznool/restful-api-basics

cd restful-api-basics

npm install

npm run watch

Summary

node.js is very well suited for building APIs

express.js is a popular framework to assist in building RESTful APIs

APIs provide a useful interface for consuming your data from a wide variety of devices

Want More?

Covers authentication, logging, exception reporting, deployment strategies and more

Come and say hello if you want to learn more :-)

I'm running a course in August which dives deeper into building a RESTful API with express.js

Level Complete!

Building a RESTful API with node.js

By Tom Spencer

Building a RESTful API with node.js

  • 797
Loading comments...

More from Tom Spencer