Wednesday, January 19, 2011

REST API


The questions most of us have are "What exactly is REST (or REST-ful) API and what is the history behind it?, Where did it originate?" From the apperence it seems to be just URLs that usually return XML in some particular format with words REST standing for "REpresentational State Transfer".

A simple definition to start about REST is, it's the model of the web. For example when the browser makes a request to a URL and receives the response, the request can be either GET, PUT, POST and DELETE. The response can be of any format, HTML, image, PDF, XML. The process of requests and response is called REST.

According to the above definition, another question pops up abt the difference between HTTP and REST. The baseic answer would be HTTP is a application protocol whereas REST is a style of handling resources. HTTP displays many of the traits of the REST architectural style.


Rest Data Elements

Data ElementModern Web Examples
resourcethe intended conceptual target of a hypertext reference
resource identifierURL, URN
representationHTML document, JPEG image
representation metadatamedia type, last-modified time
resource metadatasource link, alternates, vary
control dataif-modified-since, cache-control


Following are some expmaples of REST implementation
  • Amazon.com offers a "REST" version of its main 'E-Commerce' developer interface;
  • eBay offers a "REST" developer interface;
  • Facebook offers a "REST" developer interface;
  • Yahoo! offers a number of "REST" developer interfaces.
  • Youtube offers a number of "REST" developer interfaces.
  • Newscloud offers a number of "REST" interfaces.
  • movideo offers a number of "REST" interfaces.
  • SharePoint version 2010

An application or architecture considered RESTful or REST-style is characterized by:
  • State and functionality are divided into distributed resources
  • Every resource is uniquely addressable using a uniform and minimal set of commands (typically using HTTP commands of GET, POST, PUT, or DELETE over the Internet)
  • The protocol is client/server, stateless, layered, and supports caching
This is essentially the architecture of the Internet and helps to explain the popularity and ease-of-use for REST.

No comments:

Post a Comment