Introducing REST

Objectives

After completing this lesson, you will be able to:

  • Introduce REST

Introduction to REST

In this lesson, the following topics are discussed:

  • What is REST?
  • Realization as a Web API.

What is REST?

Generally REST describes a machine to machine interface. In Web development, REST allows content to be rendered when it is requested, often referred to as Dynamic Content. RESTful Dynamic content uses server-side rendering to generate a Web site and send the content to the requesting Web browser, which interprets the server’s code and renders the page in the user’s Web browser.

Architectural properties

The constraints of the REST architectural style affect the following architectural properties:

  • Performance in component interactions, which can be the dominant factor in user-perceived performance and network efficiency.
  • Scalability allowing the support of large numbers of components and interactions among components.
  • Simplicity of a uniform interface.
  • Modifiability of components to meet changing needs (even while the application is running).
  • Visibility of communication between components by service agents.
  • Portability of components by moving program code with the data.
  • Reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data.

Architectural constraints

The REST architectural style defines following six guiding constraints:

  • Client–server architecture
  • Stateless
  • Cache-ability
  • Layered system
  • Code on demand (optional)
  • Uniform interface

Realization as a web API

Web service APIs that adhere to the REST architectural constraints and properties are called RESTful APIs. HTTP-based RESTful APIs are defined with the following aspects:

  • A base URL, such as http://api.example.com/.
  • Standard HTTP methods (for example: GET, POST, PUT, and DELETE).
  • A media type that defines state transition data elements (for example: Atom, microformats, application/vnd.collection+json). The current representation tells the client how to compose requests for transitions to all the next available application states.

Sources

A great deal of information can be found on the Internet as pages, videos, podcasts and much more about REST. There are also a variety of books that about this topic from different perspectives:

Summary

A RESTful Web API is created with the REST software architecture style. The interface must correspond to both the architectural properties and the constraints. This results in an implementation that, in addition to a base URI, uses standard HTTP methods and supports many media types. This placesRESTful Web APIs the heart of an API first approach (architecture).

Log in to track your progress & complete quizzes