Professional Documents
Culture Documents
Web Services API
Web Services API
Web Services API
HTML
• Client-side Browser CSS
JavaScript
API Data
• Server side
Python SQL
Ruby SQLite
Java Postgress
Redis
API AND WEB SERVICES
TERMINOLOGY
• 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)
• 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.
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.