What is a RESTful API?

With all the hype surrounding RESTful web services, you'd think it was suddenly a new concept that burst forth on the scene only a year or two ago. Truth is, the concepts underlying RESTful APIs are as old as the web itself and are really best understood from that perspective.

Before diving into what RESTful APIs are, let's address why you should care. Hundreds of methods have sprung up over the years to get computers connected together via a network talking the same language. The evolution of these methods, or "protocols", has led to the acceptance of a stack of agreed upon standards, each addressing computer communication in a specific way. At the top of this stack are the Application and Presentation layers, where business logic and the data resulting from it is exchanged.

REST sits on this stack in a way that makes it easy for humans to understand what's being exchanged while allowing computers to talk to one another efficiently. You may have also heard of some of the other technologies that can reside here, such as SOAP (which requires a fair amount of data and computing power and is not really appropriate for the constrained resources of mobile applications), JMS (which is specific to Java applications) and XML-RPC (which has many of the same problems as SOAP without any of the benefits of standardization).

REST allows for a minimum amount of data to be passed using the same well-established mechanisms that define the web without a lot of the encumbrances introduced by fatter protocols. This allows programmers to more rapidly build programs that access and act upon data exposed via APIs, even in environments with unreliable network speeds and limited computing power.

REST works almost exactly like a website in a browser. A resource is exposed to a program via a URL. The program can access that URL and receive data about the resource, not unlike when you type in a URL to your browser and get a web page back. Well designed RESTful APIs include additional links the program can follow to request related information - similar to how you would click on a link to visit a new page - or to submit data to update the given resource - similar to how you would fill out a web form to create a new account for a web site.

The tradeoff for all of this flexibility is a lack of strongly set standards. REST really describes the method by which the data is transferred, but implementers have been left mostly on their own to figure out how this data should look. That's rapidly changing, especially as the number of mobile devices accessing data across the network increases, but it will be a while before these formats coalesce into something resembling true standards.