O'Reilly logo

PhoneGap By Example by Andrey Kovalenko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Developing a REST API

Let's plan our first REST API. With Express, it is very easy and the development itself does not really differ from website development.

Here is a summary of what we want to implement as a REST API:

Resource (URI)

POST (create)

GET (read)

PUT (update)

DELETE (destroy)

/pictures

Create new picture

List pictures

N/A (update all)

N/A (destroy all)

/pictures/1

Error

Show picture ID 1

Update picture ID 1

Destroy picture ID 1

  • The format is JSON
  • Bulk updates and bulk destroys are not safe, so we will not implement those
  • POST, GET, PUT, DELETE equals to CREATE, READ, UPDATE, DELETE, with the abbreviation CRUD

Using Express

Building a REST API is pretty popular in the Node.js community. There are a lot of different ways ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required