0% found this document useful (0 votes)
19 views

Rest API & API

The document discusses REST APIs and how they work. A REST API uses HTTP requests to GET, POST, PUT, and DELETE data resources. It has a client-server request-response model where the client makes requests to endpoints on the server. The server responds with data, and each request is stateless. REST APIs decouple clients and backends by exposing endpoints for clients to access resources independently.

Uploaded by

Ayesha Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Rest API & API

The document discusses REST APIs and how they work. A REST API uses HTTP requests to GET, POST, PUT, and DELETE data resources. It has a client-server request-response model where the client makes requests to endpoints on the server. The server responds with data, and each request is stateless. REST APIs decouple clients and backends by exposing endpoints for clients to access resources independently.

Uploaded by

Ayesha Ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

REST API & API

Application Programming Interface (API)

• An Application Programming Interface (API) contains software


building tools, subroutine definitions as well as communication
protocols that facilitate interaction between systems. An API may be
for a database system, operating system, computer hardware or a
web-based system.
• An Application Programming Interface makes it simpler to use certain
technologies to build applications for the programmers. API can
include specifications for data structures, variables, routines, object
classes, remote calls etc
Request-Response Model
The client & the server have a request-
response model. The client sends the
request & the server responds with the
data.
If there is no request, there is no
response.
Request-Response Model
HTTP Protocol:
The entire communication happens over It’s a stateless protocol, every process
the HTTP protocol. It is the protocol for over HTTP is executed independently &
data exchange over the World Wide has no knowledge of previous processes.
Web.
HTTP protocol is a request response
protocol that defines how information is
transmitted across the web.
Request-Response Model
HTTP Protocol:
REST API & API
Endpoints
Speaking from the context of modern N-tier
web applications, every client has to hit a
REST end-point to fetch the data from the
backend.
The backend application code has a REST-
API implemented which acts as an interface
to the outside world requests.
Every request be it from the client written
by the business or the third-party developers
which consume our data have to hit the
REST-endpoints to fetch the data.
What Is A REST API
REST stands for Representational State Transfer.
It’s a software architectural style for implementing web services.
Web services implemented using the REST architectural style are known as the
RESTful Web services.
It acts as an interface. The communication between the client & the server happens
over HTTP. A REST API takes advantage of the HTTP methodologies to establish
communication between the client and the server.
REST also enables servers to cache the response that improves the performance of the
application.
What Is A REST API
The communication between the client and the server is a stateless process.
And by that, I mean every communication between the client and the server is like a new
one.
There is no information or memory carried over from the previous communications. So,
every time a client interacts with the backend, it has to send the authentication
information to it as well.
This enables the backend to figure out that the client is authorized to access the data or
not.
With the implementation of a REST API the client gets the backend endpoints to
communicate with. This entirely decouples the backend & the client code.
What Is A REST API
REST Endpoint:
An API/REST/Backend endpoint means the url of a service.
For example, https://myservice.com/getuserdetails/{username}
is a backend endpoint for fetching the user details of a particular user from the
service.
The REST-based service will expose this url to all its clients to fetch the user details
using the above stated url.
REST API

• A RESTful API is an architectural style for an application program


interface (API) that uses HTTP requests to access and use data. That
data can be used to GET, PUT, POST and DELETE data types, which
refers to the reading, updating, creating and deleting of operations
concerning resources.
What Is A REST API
Decoupling Clients & the Backend Service:

With the availability of the endpoints, the backend service does not have to worry
about the client implementation. It just calls out to its multiple clients & says
“Hey everyone, here is the url address of the resource/information you need. Hit it
when you need it. Any client with the required authorization to access a resource can
access it”.
What Is A REST API
Decoupling Clients & the Backend Service:

Developers can have different implementations with separate codebases, for different
clients, be it a mobile browser, a desktop browser, a tablet or an API testing tool.
Introducing new types of clients or modifying the client code has no effect on the
functionality of the backend service.
This means the clients and the backend service are decoupled.
API Gateway
The REST-API acts as a gateway, as a
single entry point into the system. It
encapsulates the business logic.
Handles all the client requests, taking care
of the authorization, authentication,
sanitizing the input data & other necessary
tasks before providing access to the
application resources
REST Request Response
GET https://restexample.com/users?name=John

{
"name": "John",
"age": 5,
"address": "Greenville"

}
SOAP Request Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope /"
xmlns:sch="http://www.soapexample.com/xml/user s">
<soapenv:Header/>
<soapenv:Body>
<sch:UserDetailsRequest>
<sch:name>John</sch:name>
</sch:UserDetailsRequest>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope /">
</soapenv:Body>
<soapenv:Header/>
</soapenv:Envelope> <soapenv:Body>
<ns2:UserDetailsResponse xmlns:ns2="http://www.soapexample.com/xml/user s">
<ns2:User>
<ns2:name>John</ns2:name>
<ns2:age>5</ns2:age>
<ns2:address>Greenville</ns2:address>
</ns2:User
</ns2:UserDetailsResponse>
</soapenv:Body>

</soapenv:Envelope>
HTTP Method
HTTP HEADER FIELDS
HTTP STATUS CODES

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
HTTP 2

You might also like