13 min read

Two decades ago, the IT industry saw tremendous opportunities with the dot-com boom. Similar to the dot-com bubble, the IT industry is transitioning through another period of innovation. The disruption is seen in major lines of business with the introduction of recent technology trends like Cloud services, Internet of Things ( IoT), single-page applications, and social media.

In this article, we have covered the role and implications of RESTful web APIs in these emerging technologies.

This article is an excerpt from a book written by Balachandar Bogunuva Mohanram, titled RESTful Java Web Services, Second Edition.

Cloud services

We are in an era where business and IT are married together. For enterprises, thinking of a business model without an IT strategy is becoming out of the equation. Keeping the interest on the core business, often the challenge that lies ahead of the executive team is optimizing the IT budget. Cloud computing has come to the rescue of the executive team in bringing savings to the IT spending incurred for running a business.

Cloud computing is an IT model for enabling anytime, anywhere, convenient, on-demand network access to a shared pool of configurable computing resources. In simple terms, cloud computing refers to the delivery of hosted services over the internet that can be quickly provisioned and decommissioned with minimal management effort and less intervention from the service provider.


Cloud characteristics

Five key characteristics deemed essential for cloud computing are as follows:

Cloud characteristics

  • On-demand Self-service: Ability to automatically provision cloud-based IT resources as and when required by the cloud service consumer
  • Broad Network Access: Ability to support seamless network access for cloud-based IT resources via different network elements such as devices, network protocols, security layers, and so on
  • Resource Pooling: Ability to share IT resources for cloud service consumers using the multi-tenant model
  • Rapid Elasticity: Ability to dynamically scale IT resources at runtime and also release IT resources based on the demand
  • Measured Service: Ability to meter the service usage to ensure cloud service consumers are charged only for the services utilized

Cloud offering models

Cloud offerings can be broadly grouped into three major categories, IaaS, PaaS, and SaaS, based on their usage in the technology stack:

Cloud offering models

  • Software as a Service (SaaS) delivers the application required by an enterprise, saving the costs an enterprise needs to procure, install, and maintain these applications, which will now be offered by a cloud service provider at competitive pricing
  • Platform as a Service (PaaS) delivers the platforms required by an enterprise for building their applications, saving the cost the enterprise needs to set up and maintain these platforms, which will now be offered by a cloud service provider at competitive pricing
  • Infrastructure as a Service (IaaS) delivers the infrastructure required by an enterprise for running their platforms or applications, saving the cost the enterprise needs to set up and maintain the infrastructure components, which will now be offered by a cloud service provider at competitive pricing

RESTful APIs’ role in cloud services

RESTful APIs can be looked on as the glue that connects the cloud service providers and cloud service consumers. For example, application developers requiring to display a weather forecast can consume the Google Weather API. In this section, we will look at the applicability of RESTful APIs for provisioning resources in the cloud.

For an illustration of RESTful APIs, we will be using the Oracle Cloud service platform. Users can set up a free trial account via https://Cloud.oracle.com/home and try out the examples discussed in the following sections.Oracle Cloud service platform

For example, we will try to set up a test virtual machine instance using the REST APIs. The high-level steps required to be performed are as follows:

  1. Locate REST API endpoint
  2. Generate authentication cookie
  3. Provision virtual machine instance

Locating the REST API endpoint

Once users have signed up for an Oracle Cloud account, they can locate the REST API endpoint to be used by navigating via the following steps:

  1. Login screen: Choose the relevant Cloud Account details and click the My Services button as shown in the screenshot ahead:

REST API endpoint

  1. Home page: Displays the cloud services Dashboard for the user. Click the Dashboard icon as shown in the following screenshot:

cloud services Dashboard

  1. Dashboard screen: Lists the various cloud offerings. Click the Compute Classic offering:

compute classic offering

  1. Compute Classic screen: Displays the details of infrastructure resources utilized by the user:

Oracle Cloud services

  1. Site Selector screen: Displays the REST endpoint:

REST endpoint

Generating an authentication cookie

Authentication is required for provisioning the IT resources. For this purpose, we will be required to generate an authentication cookie using the Authenticate User REST API. The details of the API are as follows:

API detailsDescriptionAPI functionAuthenticate supplied user credential and generate authentication cookie for use in the subsequent API calls.Endpoint

/authenticate/

Example: https://compute.eucom-north-1.oracleCloud.com/authenticate/

HTTP method

POST

Request header properties

Content-Type:application/oracle-compute-v3+jsonAccept: application/oracle-compute-v3+jsonRequest body

  • user: Two-part name of the user in the format/Computeidentity_domain/user
  • password: Password for the specified
    userSample
  • request:{
    "password": "xxxxx",
    "user": "/Compute-586113456/[email protected]"
    }

Response header properties

set-cookie: Authentication cookie value

The following screenshot shows the authentication cookie generated by invoking the Authenticate User REST API via the Postman tool:

REST API via the Postman tool

Provisioning a virtual machine instance

Consumer are allowed to provision IT resources on the Oracle Compute Cloud infrastructure service, using the LaunchPlans or Orchestration REST API. For this demonstration, we will use the LaunchPlans REST API. The details of the API are as follows:

API functionLaunch plan used to provision infra resources in Oracle Compute Cloud Service.Endpoint

/launchplan/

Example: https://compute.eucom-north-1.oracleCloud.com/launchplan/

HTTP method

POST

Request header properties

Content-Type:application/oracle-compute-v3+json
Accept: application/oracle-compute-v3+json
Cookie:

Request body

      {
        "instances": [
          {
            "shape": "oc3",
            "imagelist": "/oracle/public/oel_6.4_2GB_v1",
            "name": "/Compute-586113742/[email protected]/test-vm-1",
            "label": "test-vm-1",
            "sshkeys":[]
          }
        ]
      }

Response body

Provisioned list of instances and their relationships

The following screenshot shows the creation of a test virtual machine instance by invoking the LaunchPlan REST API via the Postman tool:

LaunchPlan REST API

HTTP Response Status 201 confirms the request for provisioning was successful. Check the provisioned instance status via the cloud service instances page as shown here:

HTTP Response Status 201

Internet of things

The Internet of Things ( IoT), as the name says, can be considered as a technology enabler for things (which includes people as well) to connect or disconnect from the internet. The term IoT was first coined by Kelvin Ashton in 1999. With broadband Wi-Fi becoming widely available, it is becoming a lot easier to connect things to the internet. This a has a lot of potential to enable a smart way of living and already there are many projects being spoken about smart homes, smart cities, and so on.

A simple use case can be predicting the arrival time of a bus so that commuters can get a benefit, if there are any delays and plan accordingly. In many developing countries, the transport system is enabled with smart devices which help commuters predict the arrival or departure time for a bus or train precisely. Gartner analysts firm has predicted that more than 26 billion devices will be connected to the internet by 2020. The following diagram from Wikipedia shows the technology roadmap depicting the applicability of the IoT by 2020 across different areas:

Technology roadmap

 

IoT platform

The IoT platform consists of four functional layers—the device, data, integration, and service layers. For each functional layer, let us understand the capabilities required for the IoT platform:

Device

Device management capabilities supporting device registration, provisioning, and controlling access to devices.

Seamless connectivity to devices to send and receive data.

Data

Management of huge volume of data transmitted between devices.

Derive intelligence from data collected and trigger actions.

Integration Collaboration of information between devices.ServiceAPI gateways exposing the APIs.

IoT benefits

The IoT platform is seen as the latest evolution of the internet, offering various benefits as shown here:

IoT platform

The IoT is becoming widely used due to lowering cost of technologies such as cheap sensors, cheap hardware,  and low cost of high bandwidth network.

The connected human is the most visible outcome of the IoT revolution. People are connected to the IoT through various means such as Wearables, Hearables, Nearables, and so on, which can be used to improve the lifestyle, health, and wellbeing of human beings:

  • Wearables: Wearables are any form of sophisticated, computer- like technology which can be worn or carried by a person, such as smart watches, fitness devices, and so on.
  • Hearables: Hearables are wireless computing earpieces, such as headphones.
  • Nearables: Nearables are smart objects with computing devices attached to them, such as door locks, car locks, and so on. Unlike Wearables or Hearables, Nearables are static.

Also, in the healthcare industry, the IoT-enabled devices can be used to monitor patients’ heart rate or diabetes. Smart pills and nanobots could eventually replace surgery and reduce the risk of complications.

RESTful APIs’ role in the IoT

The architectural pattern used for the realization of the majority of the IoT use cases follows the event-driven architecture pattern. The event-driven architecture software pattern deals with the creation, consumption, and identification of events. An event can be generalized to refer the change in state of an entity.

For example, a printer device connected to the internet may emit an event when the printer cartridge is low on ink so that the user can order a new cartridge. The following diagram shows the same with different devices connected to the internet:

devices connected to the internet

 

The common capability required for devices connected to the internet is the ability to send and receive event data. This can be easily accomplished with RESTful APIs. The following are some of the IoT APIs available on the market:

  • Hayo API: The Hayo API is used by developers to build virtual remote controls for the IoT devices in a home. The API senses and transmits events between virtual remote controls and devices, making it easier for users to achieve desired actions on applications by simply manipulating a virtual remote control.
  • Mozilla Battery Status API: The Mozilla Battery Status API is used to monitor system battery levels of mobile devices and streams notification events for changes in the battery levels and charging progress. Its integration allows users to retrieve real-time updates of device battery levels and status.
  • Caret API: The Caret API allows status sharing across devices. The status can be customized as well.

Modern web applications

Web-based applications have seen a drastic evolution from Web 1.0 to Web 2.0. Web 1.0 sites were designed mostly with static pages; Web 2.0 has added more dynamism to it. Let us take a quick snapshot of the evolution of web technologies over the years.

1993-1995Static HTML Websites with embedded images and minimal JavaScript1995-2000Dynamic web pages driven by JSP, ASP, CSS for styling, JavaScript for client side validations.2000-2008Content Management Systems like Word Press, Joomla, Drupal, and so on.2009-2013Rich Internet Applications, Portals, Animations, Ajax, Mobile Web applications2014 OnwardsSinge Page App, Mashup, Social Web

 

Single-page applications

Single-page applications are web applications designed to load the application in a single HTML page. Unlike traditional web applications, rather than refreshing the whole page for displaying content change, it enhances the user experience by dynamically updating the current page, similar to a desktop application. The following are some of the key features or benefits of single-page applications:

  • Load contents in single page
  • No refresh of page
  • Responsive design
  • Better user experience
  • Capability to fetch data asynchronously using Ajax
  • Capability for dynamic data binding

RESTFul API role in single-page applications

In a traditional web application, the client requests a URI and the requested page is displayed in the browser. Subsequent to that, when the user submits a form, the submitted form data is sent to the server and the response is displayed by reloading the whole page as follows:

RESTFul API role in single-page applications

Social media

Social media is the future of communication that not only lets one interact but also enables the transfer of different content formats such as audio, video, and image between users. In Web 2.0 terms, social media is a channel that interacts with you along with providing information. While regular media is a one-way communication, social media is a two-way communication that asks for one’s comments and lets one vote. Social media has seen tremendous usage via networking sites such as Facebook, LinkedIn, and so on.

Social media platforms

Social media platforms are based on Web 2.0 technology which serves as the interactive medium for collaboration, communication, and sharing among users. We can classify social media platforms broadly based on their usage as follows:

Social networking servicesPlatforms where people manage their social circles and interact with each other, such as Facebook.Social bookmarking servicesAllows one to save, organize, and manage links to various resource over the internet, such as StumbleUpon.Social media newsPlatform that allows people to post news or articles, such as reddit.Blogging servicesPlatform where users can exchange their comments on views, such as Twitter.Document sharing servicesPlatform that lets you share your documents, such as SlideShare.Media sharing servicesPlatform that lets you share media contents, such as YouTube.Crowd sourcing servicesObtaining needed services, ideas, or content by soliciting contributions from a large group of people or an online community, such as Ushahidi.

Social media benefits

User engagement through social media has seen tremendous growth and many companies use social media channels for campaigns and branding. Let us look at various benefits social media offers:

Customer relationship managementA company can use social media to campaigns their brand and potentially benefit with positive feedback from customer review.Customer retention and expansionCustomer reviews can become a valuable source of information for retention and also help to add new customers.Market researchSocial media conversations can become useful insight for market research and planning.Gain competitive advantageAbility to get a view of competitors’ messages which enables a company to build strategies to handle their peers in the market.Public relationsCorporate news can be conveyed to audience in real time.Cost controlCompared to traditional methods of campaigning, social media offers better advertising at cheaper cost.

 

RESTful API role in social media

Many of the social networks provide RESTful APIs to expose their capabilities. Let us look at some of the RESTful APIs of popular social media services:

Social media servicesRESTFul APIReferenceYouTubeAdd YouTube features to your application, including the ability to upload videos, create and manage playlists, and more.https://developers.google.com/youtube/v3/FacebookThe Graph API is the primary way to get data out of, and put data into, Facebook’s platform. It’s a low-level HTTP-based API that you can use to programmatically query data, post new stories, manage ads, upload photos, and perform a variety of other tasks that an app might implement.https://developers.facebook.com/docs/graph-api/overviewTwitter Twitter provides APIs to search, filter, and create an ads campaign.https://developer.twitter.com/en/docs

To summarize, we discussed modern technology trends and the role of RESTful APIs in each of these areas including its implication on the cloud, virtual machines, user experience for various architecture, and building social media applications.

To know more about designing and working with RESTful web services, do check out Java RESTful Web Services, Second Edition.

Read Next:

Getting started with Django and Django REST frameworks to build a RESTful app

How to develop RESTful web services in Spring


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

IT research professional interested in learning how new technologies are making the world a better place | Low-level Astronomy enthusiast | Still learning to write better and read more.

LEAVE A REPLY

Please enter your comment!
Please enter your name here