Book Image

Node.js By Example

Book Image

Node.js By Example

Overview of this book

Table of Contents (18 chapters)
Node.js By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introducing the REST API concept


REST stands for Representational State Transfer. By definition, it is an architectural principle of the Web. In practice, it is a set of rules that simplify client-server communication. A lot of companies provide REST APIs because they are simple and highly scalable.

To better understand what REST exactly means, let's take a simple example. We have an online store and we want to manage the users in our system. We have the backend logic implemented in various controllers. We want to trigger functionalities there via HTTP requests. In other words, we need an application program interface for these controllers. We start by planning the URLs to access our server. If we follow the REST architecture, then we may have the following routes:

  • GET requests to /users return a list of all the users in the system

  • POST requests to /users create new user

  • PUT requests to /users/24 edit the data of a user with the unique identification number 24

  • DELETE requests to /users...