0% found this document useful (0 votes)
3 views21 pages

Rest API Fundamentals

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views21 pages

Rest API Fundamentals

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

FUNDAMENTALS

A Beginner’s Guide
API A software intermediary that allows two
applications to talk to each other. APIs are
Application Programming an accessible way to extract and share data
Interface within and across organizations.

API is a collection of communication protocols and


subroutines used by various programs to
communicate between them.
API acts as an
interface between
different applications.
REST API REST is an architectural style for
networked applications that uses HTTP
Representational State requests to access and manipulate data.
Transfer

It’s an architectural style to


develop web applications

It uses Hyper Text


Trasnsfer Protocol as
communication interface

It transfers data through


HTTP methods
Diagram GET / POST /
PUT / DELETE

REST API Example


JSON / XML

Client REST API DB


Request Anatomy
REST API Request

URL It is the address to


Uniform Resource identify a resource and
Locator
specify how to access it

In an API, the URL can be named as


Base URL, which means that is the
base address used in every request

Example: http://sefism.vercel.app
Request Anatomy Every URL is a URI, but not
every URI is also a URL
REST API Request

URI It is used in URL to specify


Uniform Resource
whichce and sp the client would
Identifier
like to access in a request

Example: http://sefism.vercel.app/emails?
community=slack
URI highlighted
in white

Here, the client actually


communicates to the server that
the request is to retrieve emails
with community equals to slack
Body Params Only used in requests that must
send information such as create
or delete
Request Body Params

Body of the request which contains all the


data that the server needs to successfully
process the request

Request Example

{
“email”:”[email protected]

“community”:”sefism”
“isJoined”:”true”
}
Parameters There are two types of
parameters, Query & Path.
Request Parameters

Information that can be sent in a request by


the client in order to get the response from
the server

Example: http://sefism.vercel.app/emails?community=slack
Example: http://sefism.vercel.app/helpful-resources/beginner/interviewtips
Query Parameters community=slack is a query
paramter (variable) which retrieves
emails for slack community
Request Parameters
Type

A variable in URI path that helps in


querying / filtering through a list of
resources.

Example: http://sefism.vercel.app/emails?community=slack
Path Parameters beginner is the path parameter
(variable) which points to
interviewtips of beginner levels
Request Parameters
Type

A variable in URI path that helps in


pointing towards specific resource.

Example: http://sefism.vercel.app/helpful-resources/beginner/interviewtips
Headers Used to send extra data, specifying
proper format and data to retrieve
Request Headers

Body of the request which contains all the


data that the server needs to successfully
process the request

Request Header

Authorization: Bearer token


Accept: Application/json
REST Methods Others REST API Methods are
HEAD, TRACE, CONNECT and
REST API Methods OPTIONS

GET
POST
Retrieve information
about an API resource. Create an API resource.

PUT

PATCH Update an API resource.

Modifies an API resource.

DELETE

Deletes an API resource.


HTTP Status Codes With every request made to
the server, we get http status
Response/Status Codes / response codes in return

1XX : Information
2XX : Success
3XX : Redirection
4XX : Client Error
5XX : Server Error
Why REST APIs

Advantages of RESTful
APIs

Simplicity and
Clarity

RESTful APIs follow a straightforward architectural style based


on familiar web concepts like HTTP methods (GET, POST, PUT,
DELETE) and resource representations (JSON, XML). This makes
them intuitive to learn and use for developers of all skill levels.
Why REST APIs

Advantages of RESTful
APIs

Flexibility and
Scalability

RESTful APIs can be adapted to a wide range of applications, from


simple web services to complex enterprise systems. They can also
be easily scaled to handle increasing traffic and data volumes as
your needs grow.
Why REST APIs

Advantages of RESTful
APIs

Interoperability and
Openness

RESTful APIs are based on open standards and widely used


protocols, making them compatible with diverse software and
hardware platforms. This fosters collaboration and simplifies
integration with existing systems.
Why REST APIs

Advantages of RESTful
APIs

Maintainability and
Reliability

The clear separation of concerns in RESTful APIs (client, server,


resources) promotes modularity and code reusability. This leads to
improved maintainability and reduced development costs in the
long run.
REST API Usage

Things to consider before


RESTful APIs Real-time communication: Not ideal for
applications requiring continuous data updates like
chat or streaming, consider WebSockets or event-
driven messaging.

Complex workflows: Intricate operations requiring


Simple data access: Need to expose simple data multiple chained requests might be less efficient
for use by other applications, especially web and than custom protocols.
mobile clients.
Highly secure environments: If security is
Integration with existing systems: Easy to paramount, custom protocols with stronger
integrate with existing platforms due to familiar authentication and authorization might be
HTTP and JSON/XML format. preferred.

Scalability and flexibility: Can handle various Resource-intensive tasks: Transferring large files or
applications and scale with increasing traffic and data streams may be more efficient with
data volumes. specialized protocols like FTP or WebDAV.

Open standards and interoperability: Promotes


collaboration and simplifies integration with
diverse software and hardware.
API Architectures

Other available API Declarative data fetching with


GraphQL precise control, ideal for
Architectural Styles complex data structures

High-performance remote
procedure calls optimized for gRPC
microservices communication.

Loosely coupled, real-time data


Event-Driven exchange through event streams
and messaging.

Mature, XML-based protocol


emphasizing security and Soap
interoperability.

Continuous bi-directional
Web Sockets communication between client
and server.
Like and Share

Like and Share with your


Network

You might also like