Representation State Transfer (commonly known as REST) is an architectural paradigm that is based on the stateless HTTP protocol and is used for designing applications that can intercommunicate. In REST, resources are used to represent state and functionality, and these resources are in turn represented using user-friendly URLs. Note that the REST architecture style can be applied to other protocols as well. The word "stateless" implies the HTTP/HTTPS protocols. The REST architectural style is popular in the HTTP world and gives better results when used in combination with the HTTP protocol.
The key goals of REST include the following:
Scalability
Compatibility with other technology and platforms
Generality of interfaces
Discoverability; that is, interconnectivity between resources
Components that can be deployed independently of one another
Reduced latency
Better security
Extensibility
A RESTful Web API is a web API that conforms to the REST principles. The main principles of REST include:
Identification of resources
Stateless communication
Manipulation of resources through representations
Self-descriptive messages
In this section, we will examine the popular REST-based service frameworks.
Here is the list of the popular REST-based service frameworks or APIs:
Ruby on Rails
Restlet
Django
Flickr
Google
Yahoo
Ruby on Rails is an optimized open source web application framework that runs on top of the Ruby programming language. Ruby on Rails follows the basic software engineering patterns and principles. The Rails Web API is a framework that facilitates the creation of web applications based on the Model-View-Controller (MVC) framework. The view layer is composed of "templates," and most of these templates are HTML-based with embedded Ruby code. The model layer represents the domain model, the business logic classes, and the data access classes. The controller layer handles incoming HTTP requests. Note that the Rails controller can generate XML, JSON, PDFs, and also mobile-specific views. You can get more information on this framework from http://api.rubyonrails.org/.
Restlet provides support for an extensive list of extensions that include the following:
Spring
WADL
XML
JSON
JAX-RS API
The benefits of Restlet include the following:
Support for a fully symmetric client and server API
Support for connector protocols other than HTTP
Support for complete URI routing control through the Restlet API
Fast and scalable
Powerful filtering support
Support for a consistent client and server API
You can explore more on this API from http://restlet.org/discover/features.
The Django REST framework provides a powerful and flexible API, using which you can build Web APIs seamlessly. This API provides an extensive documentation and excellent community support. You can know more about this framework from http://django-rest-framework.org/.
The Flickr REST API is simple and easy to use. Flickr also has some JSON APIs that you might make use of for invoking the API through JavaScript. You can get more information about this from http://www.flickr.com/services/api/request.rest.html.
The Custom Search JSON/Atom API from Google enables developers to write applications that can leverage this API and retrieve and display custom search in the applications. This API allows you to use RESTful calls for web search and get the results in JSON or Atom format. You can know more on this API from https://developers.google.com/custom-search/json-api/v1/overview.
Note that Google provides a much wider range of API services than APIs, such as Google Maps, AdWords, Translate, Google Analytics, and so on.
The Yahoo Social REST APIs provide a collection of URI resources that can provide access to the following:
Users' profiles
Status messages
Status updates
These URIs are actually grouped into APIs, depending on the information that they return. For more information, you can refer to http://developer.yahoo.com/social/rest_api_guide/web-services-intro.html.
The Open Data Protocol (OData) is a protocol that is built on web standards, such as HTTP, Atom, and JSON, and standardizes how data is exposed and consumed. It is a data access protocol that provides a uniform way of performing CRUD operations on the data. It is used to expose and access information from different data sources; that is, relational databases, filesystems, content management systems, and so on.
OData is a standardized protocol that builds on top of core protocols, such as HTTP and architecture paradigms, such as REST. Like RSS, Atom is a way to expose feeds. Note that AtomPub makes use of HTTP verbs such as GET
, POST
, PUT
, and DELETE
, to facilitate the publishing of data. OData v4 is now an OASIS standard. It is an open protocol that enables the creation and consumption of queryable and interoperable RESTful APIs.
OData is a REST-based protocol that uses HTTP, JSON, and ATOM, and supports any platform that has support for HTTP, XML, or JSON. You can use it to expose data retrieved from relational databases, filesystems, or data services. OData enables you to perform CRUD operations on top of a data model or a data service. In essence, it is an HTTP-based, platform-independent protocol that supports REST. In OData, data is provided through the usage URIs and common HTTP verbs, such as GET
, PUT
, POST
, MERGE
, and DELETE
. Note that WCF Data Services (previously known as ADO.NET Data Services) is the implementation of OData Protocol in .NET applications.
The official website of OData Protocol exposes data as an OData Service. The service URL is http://services.odata.org/website/odata.svc.
When you open the page in a browser, this is what the XML markup looks like:
<service xml:base="http://services.odata.org/Website/odata.svc/"> <workspace> <atom:title>Default</atom:title> <collection href="ODataConsumers"> <atom:title>ODataConsumers</atom:title> </collection> <collection href="ODataProducerApplications"> <atom:title>ODataProducerApplications</atom:title> </collection> <collection href="ODataProducerLiveServices"> <atom:title>ODataProducerLiveServices</atom:title> </collection> </workspace> </service>