RESTful Web Services

A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability (e.g., communication between Java and Python, or Windows and Linux applications) is due to the use of open standards.

Web services based on REST Architecture are known as RESTful web services. These webservices uses HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, which provides resource representation such as JSON and set of HTTP Methods.

Creating RESTful for A Library

Consider we have a JSON based database of users having the following users in a file users.json:

{

“user1” : {

“name” : “mahesh”,

“password” : “password1”,

“profession” : “teacher”,

“id”: 1

},

“user2” : {

“name” : “suresh”,

“password” : “password2”,

“profession” : “librarian”,

“id”: 2

},

“user3” : {

“name” : “ramesh”,

“password” : “password3”,

“profession” : “clerk”,

“id”: 3

}

}

Based on this information we are going to provide following RESTful APIs.

URI HTTP Method POST body Result
listUsers GET empty Show list of all the users.
addUser POST JSON String Add details of new user.
deleteUser DELETE JSON String Delete an existing user.
:id GET empty Show details of a user.

I’m keeping most of the part of all the examples in the form of hard coding assuming you already know how to pass values from front end using Ajax or simple form data and how to process them using express Request object.

HTTP Methods
Listing Data

Get industry recognized certification – Contact us

keyboard_arrow_up