The World Wide Web consists of more com­pon­ents than those exposed to the users when they access a website. Both human users and machines access data from web projects. In order for this to work, website operators need to make their website available to other ap­plic­a­tions by providing a cor­res­pond­ing web service.

The social media network, Twitter, offers a good example for this; thanks to its cor­res­pond­ing web services, any ap­plic­a­tion is able to read out or write tweets on behalf of a user.

There are various tech­niques to implement such web services: remote procedure calls (RPC), the network protocol, SOAP, or the pro­gram­ming paradigm, Rep­res­ent­a­tion­al State Transfer (REST).

Cheap domain names – buy yours now
  • Free website pro­tec­tion with SSL Wildcard included
  • Free private re­gis­tra­tion for greater privacy
  • Free Domain Connect for easy DNS setup

So what’s REST?

The term, ‘Rep­res­ent­a­tion­al State Transfer’, comes from a dis­ser­ta­tion published by Roy Fielding, one of the main de­velopers of many different web standards. In abstract form, the computer scientist describes the un­der­ly­ing ar­chi­tec­ture of the World Wide Web (HTTP protocol, HTML and XML, parser, web and ap­plic­a­tion servers, etc.). Generally speaking, REST’s ar­chi­tec­ture does not depend on any specific protocols. At the center of this concept lie resources, which, according to Fielding, must meet the following re­quire­ments:

  • Ad­dress­ab­il­ity: each resource, e.g. an order, a product, or an article, must be able to be iden­ti­fied through a unique resource iden­ti­fi­er (URI).
  • Unified in­ter­faces: every resource must be easily and uniformly ac­cess­ible with the help of standard methods. For example, through HTTP methods, like ‘GET’, ‘POST’, or ‘PUT’.
  • Client-server structure: generally, the client-server principle is ap­plic­able: A server provides a service that’s able to be requested by clients when needed.
  • State­less­ness: com­mu­nic­a­tion between servers and clients is stateless. This means that all exchanged messages contain all the in­form­a­tion required for un­der­stand­ing them. The server doesn’t save any ad­di­tion­al in­form­a­tion between any two messages in the form of sessions. And given that incoming requests can be re­dis­trib­uted with the help of a load balancing scheme, state­less­ness makes REST services very easy to scale up.
  • Different rep­res­ent­a­tions of resources: every web resource may feature multiple display formats. Depending on what the client requests, these resources may need to be delivered in different languages or formats like HTML, JSON, or XML.
  • Hy­per­me­dia: resources are made available via hy­per­me­dia, e.g. in the form of ‘href’ and ‘src’ at­trib­utes in HTML documents. They can also be provided for defined in­ter­faces of JSON or XML. Con­sequently, a REST-API’s client navigates according to the ‘hy­per­me­dia as the engine of ap­plic­a­tion state’ (HATEOAS) method ex­clus­ively via URLs that have been provided by the server; these don’t require any ad­di­tion­al in­form­a­tion about the interface.

The strict standards of REST’s ar­chi­tec­ture enable services to be developed that com­mu­nic­ate via a common protocol (HTTP), are well struc­tured, and are easy to integrate.

Breaking down the design of a REST service

In order to implement a REST service, HTTP and its encrypted cousin, HTTPS, are primarily used. One reason for this is the protocols’ wide use, a fact that allows users to get by virtually any firewall. Al­tern­at­ively, the stateless Hypertext Transfer Protocol is also re­l­at­ively simply struc­tured. The HTTP standard has a complete set of commands on offer, with which resources can be accessed:

HTTP Method (Command) De­scrip­tion
GET Requests a resource from the server without changing its state on the server.
POST Creates a new resource beneath the indicated resource that is auto­mat­ic­ally addressed by the URI; or modifies an existing resource.
HEAD Only requests the header of the cor­res­pond­ing resource from the server. This is done to check a file’s validity, among other things.
PUT Creates the specified resource on the server or modifies an existing one.
PATCH Modifies a part of the indicated resource.
DELETE Deletes the re­spect­ive resource.
TRACE Returns the request in the same way that the web server has received it in order to determine if any changes took place on the way to the server.
OPTIONS Shows a list of methods supported by the server.
CONNECT Runs the request through an SSL tunnel. Usually, this is done in order to create a con­nec­tion via a proxy server.

This range of commands can be increased by im­ple­ment­ing ad­di­tion­al protocols. To this end, the WebDAV protocol is often used. This adds the methods COPY (copies resource), MOVE (moves resource), LOCK (locks resource), UNLOCK (unlocks resource), and MKCOL (creates directory).

Web hosting
The hosting your website deserves at an un­beat­able price
  • Loading 3x faster for happier customers
  • Rock-solid 99.99% uptime and advanced pro­tec­tion
  • Only at IONOS: up to 500 GB included

Which web services is the REST ar­chi­tec­ture best suited for?

Typically, standard methods like GET, POST, PUT, PATCH, and DELETE are used when de­vel­op­ing a REST service via HTTP, which suggests that the ar­chi­tec­ture has been designed only for simple data man­age­ment tasks. What’s more, the principle of REST resources’ state­less­ness also appears to sig­ni­fic­antly limit the ar­chi­tec­ture’s cap­ab­il­it­ies. By using the resources in the right way, however, the REST interface makes it possible to do more than simply add and retrieve data sets, as the following examples demon­strate.

  • Web services with trans­ac­tions: Trans­ac­tion managers are essential for realising web services with trans­ac­tions. Due to their state­less­ness, resources are always saved without ad­di­tion­al in­form­a­tion between requests. This means that a REST im­ple­ment­a­tion is re­stric­ted into two different options:
  1. Resources are designed in such a way that trans­ac­tions can be processed within a given request.
  2. A resource is created that manages trans­ac­tion requests. Each request that’s presented to this trans­ac­tion manager auto­mat­ic­ally generates a further resource that’s then iden­ti­fied via a URI and rep­res­ents a trans­ac­tion. Sub­sequently, changes can be made as rep­res­ent­a­tions to this resource on the server. A further request to the trans­ac­tion manager completes the trans­ac­tion.
  • Asyn­chron­ous web services: for certain web services, it may be desired to have requests and answers decoupled from one another in terms of time. Given that HTTP doesn’t offer any mech­an­isms for this task, the only option available to server providers is to manage pro­cessing the requests them­selves and forward these on user requests.   
  • Web services with extensive in­ter­op­er­ab­il­ity: REST services are char­ac­ter­ised by their flex­ib­il­ity. This flex­ib­il­ity is brought on by the fact that one basic protocol is focused on and that mobile clients es­pe­cially benefit from the limited demands of REST’s ar­chi­tec­ture. The fact that these resources are easily available also makes it easy for them to be found by search engines without any as­sist­ance.

Pro­gram­ming web services with REST

The REST framework offers an excellent means for drafting and im­ple­ment­ing different kinds of web services. Thanks to the fact that the Hypertext Transfer Protocol is supported by virtually every device, both desktop as well as mobile clients are able to ef­fort­lessly work with the REST interface without need for any ad­di­tion­al im­ple­ment­a­tions. The results are web services that feature a sub­stan­tial degree of:

  • Platform in­de­pend­ence,
  • scalab­il­ity,
  • per­form­ance,
  • in­ter­op­er­ab­il­ity,
  • and flex­ib­il­ity.

Using this ar­chi­tec­ture does require cor­res­pond­ing know-how. Es­pe­cially managing the in­ter­ac­tion between the in­di­vidu­al, stateless resources is both complex and difficult to achieve. Those who’ve already worked with al­tern­at­ives, like the protocol SOAP, will surely be left pondering over the unusual ap­proaches this ar­chi­tec­ture employs; however, REST proves to be a service that’s much more useful.

Your very own .uk domain name!
Short, sharp, .uk

Looking for an al­tern­at­ive to the tra­di­tion­al .co.uk extension, or want to grow your online presence? Give .uk a try today.

£1 for 1 year!

Go to Main Menu