Web Services API

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

WEB DEV FOR IS

B9IS109 Web Development for Information Systems


STRUCTURE OF A MODERN WEB APP

HTML
• Client-side Browser CSS
JavaScript

API Data
• Server side
Python SQL
Ruby SQLite
Java Postgress
Redis
API AND WEB SERVICES
TERMINOLOGY

• XML [eXtensible Markup Language]


• JSON [JavaScript Object Notation]
• HTTP [HyperText Transfer Protocol]
• SOAP [Simple Object Access Protocol] is a messaging protocol used for exchanging
structured information[XML data] over a network.
• REST [REpresentational State Transfer] is a standardized architectural style that can be
used when creating a web API.
• Web applications (Web app) are computer programs that are accessed over the internet
through a computer’s web browser.
WHAT IS A WEB SERVICE?

• A Web service is a way for two machines to communicate with each other over a network.

• A web server running on a computer listens for requests from other computers. When a
request from another computer is received, over a network, the Web service returns the
requested resources. This resource could be JSON, XML, an HTML file, Images, Audio
Files, etc.
APPLICATION PROGRAMMING INTERFACE
(API)

APIs just allow applications to communicate with one another.


Source: https://medium.com/@perrysetgo/what-exactly-is-an-api-69f36968a41f
API

• API is a set of commands, functions, protocols and


objects that programmers can use to create
software or interact with an external system.
REPRESENTATIONAL STATE TRANSFER
(REST)

• Representational State Transfer (REST) refers to a group of software architecture design


constraints that bring about efficient, reliable, and scalable distributed systems. A system is
called RESTful when it adheres to those constraints.
• Source: MDN https://developer.mozilla.org/en-US/docs/Glossary/REST
REPRESENTATIONAL STATE TRANSFER
(REST)
• REST is an architecture style for designing loosely coupled applications over HTTP, that is
often used in the development of web services.
• REST does not enforce any rule regarding how it should be implemented at lower level, it
just put high level design guidelines and leave you to think of your own implementation.
• The architectural style of REST helps in leveraging the lesser use of bandwidth to make an
application more suitable for the internet. It is often regarded as the “language of the
internet” and is completely based on the resources.
• Basically, the REST API breaks down a transaction in order to create small modules.
URI VERSUS URL
• Universal Resource Identifier (URI): URI is described as a "compact sequence of
characters "that identifies an abstract or physical resource" that "provides a simple and
extensible means "for identifying a resource.“
• A URI is an identifier of a specific resource. Like a page, or book, or a document.
• The URL, or Universal Resource Locator, is a subset of the URI. The URL not only
identifies a resource, but also explains how to access that resource by providing an explicit
method like HTTP, HTTPS or FTP.
• All URLs are URIs, but not all URIs are URLs
URI EXAMPLES

• https://restful.dev/posts/5 Universal Resource Name(URN):


• ftp://myserver.dev/files/docs/script.docx • A subset of URI
• mailto:jimmy@example.com • The URN refers to both URIs under the
• Tel:+353-899-999-777 URN scheme and to any other URI with
the properties of a name.
• urn:library:names:authors:jrh
• library:names:authors:jrh
GUIDING PRINCIPLES OF REST(1)

• Client–server – By separating the user interface concerns from the data storage concerns,
we improve the portability of the user interface across multiple platforms and improve
scalability by simplifying the server components.

• Stateless – Each request from client to server must contain all of the information necessary
to understand the request, and cannot take advantage of any stored context on the server.
Session state is therefore kept entirely on the client.
GUIDING PRINCIPLES OF REST(2)

• Cacheable – Cache constraints require that the data within a response to a request be
implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable,
then a client cache is given the right to reuse that response data for later, equivalent requests.
• Layered system: REST allows you to use a layered system architecture where you deploy
the APIs on server A, and store data on server B and authenticate requests in Server C, for
example. A client cannot ordinarily tell whether it is connected directly to the end server, or
to an intermediary along the way.
GUIDING PRINCIPLES OF REST(3)

• Code on demand (optional): Most of the time, you will be sending the static representations
of resources in the form of XML or JSON. But when you need to, you are free to return
executable code to support a part of your application, e.g., clients may call your API to get a
UI widget rendering code. It is permitted.

• Uniform interface – In order to obtain a uniform interface, multiple architectural constraints


are needed to guide the behavior of components. REST is defined by four interface
constraints: identification of resources; manipulation of resources through
representations; self-descriptive messages; and, hypermedia as the engine of
application state.
REST
• Resource: Any information that can be named can be a resource: a document or image, a
temporal service, a collection of other resources, a non-virtual object (e.g. a person), and so
on. REST uses a resource identifier to identify the particular resource involved in an
interaction between components.
• The state of the resource at any particular timestamp is known as resource representation.
• A representation consists of data, metadata describing the data and hypermedia links which
can help the clients in transition to the next desired state.
REST
• The data format of a representation is known as a media type.
• The media type identifies a specification that defines how a representation is to be
processed.
• A truly RESTful API looks like hypertext.
• Every addressable unit of information carries an address, either explicitly (e.g., link and id
attributes) or implicitly (e.g., derived from the media type definition and representation
structure).
RESOURCE METHODS
• https://www.edureka.co/blog/what-is-rest-api/

Source: https://www.edureka.co/blog/what-is-rest-api/
REST (SUMMARY)
• REST is all about simplicity, thanks to HTTP protocols.
• REST APIs facilitate client-server communications and architectures. If it’s RESTful, it’s built
on this client-server principle, with round trips between the two passing payloads of information.
• REST APIs use a single uniform interface. This simplifies how applications interact with the
API by requiring they all interface in the same way, through the same portal. This has advantages
and disadvantages; check with your developer to see if this will affect implementation changes
down the road.
• REST is optimized for the web. Using JSON as its data format makes it compatible with
browsers.
• REST is known for excellent performance and scalability. But, like any technology, it can get
bogged down or bog down your app. That’s why languages like GraphQL have come along to
address problems even REST can’t solve.
SIMPLE OBJECT ACCESS
PROTOCOL (SOAP)
• SOAP (Simple Object Access Protocol) is its own protocol, and is a bit more complex by
defining more standards than REST—things like security and how messages are sent.
• These built-in standards do carry a bit more overhead, but can be a deciding factor for
organizations that require more comprehensive features in the way of security, transactions,
and ACID (Atomicity, Consistency, Isolation, Durability) compliance.
• Reasons you may want to build an application with a SOAP API include higher levels of
security (e.g., a mobile application interfacing with a bank), messaging apps that need
reliable communication, or ACID compliance.
SOAP
• SOAP has tighter security.
• Successful/retry logic for reliable messaging functionality.
• SOAP has built-in ACID compliance.
REST VS SOAP
• SOAP is a protocol. REST is an architectural style.
• REST APIs access a resource for data (a URI); SOAP APIs perform an operation.
• REST permits many different data formats
• Security is handled differently.
• SOAP requires more bandwidth; REST requires fewer resources.
• REST calls can be cached, SOAP-based calls cannot be cached.
• An API is built to handle your app’s payload, and REST and SOAP do this differently.
IS A REST API A WEB SERVICE?

• A REST API is a standardized architecture style for creating a Web Service API. One of the
requirements to be a REST API is the utilization of HTTP methods to make a request over a
network.

• All Web Services are APIs, but not all APIs are Web services.
CREATE A REST API
https://www.edureka.co/blog/what-is-rest-api/

To know, how to install Node.js, you can refer to the article on Installation of Node.js.

You might also like