REST (Representational State Transfer) is an architecture. It’s not a standard. It’s just a way of communicating between a client and a server. There are two things that any program works on :

  • Resources
  • Methods

While resources are like nouns, methods are more like verbs. There are 2 types of resources :

  • Collection Resource
  • Instance Resource

Collection resource as the name suggests is a bunch of resources taken together.

For eg:

Note that applications represents a collection resource, while instance resources are pointing to one and only one resource.

For eg:

Here startup is an instance resource.

In the REST architecture we have five main methods. They are

  • HEAD
  • GET
  • PUT
  • POST

If you ignore HEAD, the remaining represent CRUD (Create,  Read, Update and Delete). Although it is not a one to one correspondence.

Of these all except POST are called idempotent operations. By that what we mean is that every time you evoke one of these calls, the returned result is the same. POST unlike the rest can have different results returned. There is another method called PATCH (which is not yet a specification) which is not idempotent.

Dr. Roy Fielding is the creator of REST and he had six principles that underline the cornerstones  of this architecture. They are:

  1. Scalability
  2. Generality
  3. Independence
  4. Latency (Caching)
  5. Security
  6. Encapsulation

There are two ways of calling a program over the wire:

  • Base URL
  • Media Types

Base URL is the most common form of invoking a response. But URL’s don’t mean much in REST. Typically the URL’s are invoked as :

The other way is

The former is a much better representation.

The other treasure we can use is media types. For eg: application/json is a valid media type to specify that json is the mode of communication.

If you specify something like application/json;application/xml, this means that you can receive both json and xml as the return type but json is preferred.

We can also use media types to specify versions, rather than embedding the information in a URL. Because every time you create a new version, the developer will have to make changes to his application if he is using a URL. Hence media types are preferred.

JSON (Javascript Object Notation) is a representation of Data. For eg:

POST /application/xyz


“name”: “Rajesh”




200 OK

The above is a simple JSON data. If you notice it;s simpler than XML and now more than 80% of the communication over the wire in the world happens through JSON.

JSON Is popular because of the following factors: It’s

  • ubiquitous
  • simple
  • readable
  • scalable
  • flexible

Douglas Crockford invented JSON to make the state of data interchange simpler.

appplication/json is all you have to encode in the media type to let the server know that you are using JSON. If you use applicationm/json+foo, it means that the json data is of the type foo.

JSON and REST together comprise the majority of communications in the world.