You are on page 1of 10

REST API

Presented By :
Deeshant ( 11022210060 )
Kumud ( 11022210056 )
Introduction to REST API
• REST API, or Representational State Transfer Application Programming
Interface, is a set of rules and principles for building and interacting
with web services. It is based on the REST architectural style, which
was introduced by Roy Fielding in his doctoral dissertation in 2000.
RESTful APIs use HTTP requests to perform operations such as GET,
POST, PUT, and DELETE on resources, which are typically represented
using JSON or XML formats. REST APIs have become the standard for
modern web development due to their simplicity, scalability, and
flexibility.
Key Principles of REST
• 1. Client-Server Architecture: REST separates the client from the
server, allowing them to evolve independently.
• 2. Stateless Communication: Each request from the client to the
server must contain all the information necessary to understand and
process the request.
• 3. Cacheability: Responses from the server must explicitly indicate
whether they are cacheable or not.
• 4. Uniform Interface: REST APIs should have a uniform interface to
simplify communication between clients and servers.
• 5. Layered System: REST allows for the use of intermediaries such as
proxies and gateways, which can enhance scalability and security.
HTTP Methods in REST
• In RESTful architecture, HTTP methods, also known as verbs, are used
to perform operations on resources. The commonly used HTTP
methods in REST are as follows:
• - GET: Retrieves data from the server. It should not modify the data.
• - POST: Submits data to the server to create a new resource.
• - PUT: Updates an existing resource on the server. It replaces the
entire resource.
• - PATCH: Updates part of an existing resource on the server.
• - DELETE: Removes a resource from the server.
REST API Endpoints
• REST API endpoints are the URLs through which clients can access
resources on the server. Each endpoint corresponds to a specific
resource or collection of resources. For example:
• - /users: Represents a collection of user resources.
• - /users/{id}: Represents a specific user resource identified by its
unique identifier.
• - /posts: Represents a collection of post resources.
• - /posts/{id}: Represents a specific post resource identified by its
unique identifier.
Authentication in REST API
• Authentication is a crucial aspect of securing REST APIs. It ensures that only
authorized users can access protected resources. There are several
authentication mechanisms commonly used in RESTful architecture:
• - API Keys: A unique identifier passed along with the request to authenticate
the client.
• - OAuth: An open standard for access delegation, commonly used for user
authentication and authorization.
• - JWT (JSON Web Tokens): A compact, URL-safe means of representing
claims to be transferred between two parties.
• - Basic Authentication: Credentials (username and password) are sent in the
request header as Base64-encoded strings.
Response Formats
• REST APIs support multiple response formats to accommodate
different client requirements. The most commonly used response
formats are JSON (JavaScript Object Notation) and XML (eXtensible
Markup Language):
• - JSON: A lightweight data interchange format that is easy for humans
to read and write, and easy for machines to parse and generate.
• - XML: A markup language that defines a set of rules for encoding
documents in a format that is both human-readable and machine-
readable.
Tools for Testing REST APIs
• Testing is an essential part of developing REST APIs to ensure they perform
as expected and meet the requirements. Several tools are available for
testing REST APIs, including:
• - Postman: A popular API client that simplifies the process of testing,
documenting, and monitoring APIs.
• - Insomnia: A powerful REST API client with a beautiful interface for
organizing, running, and debugging API requests.
• - Swagger: A set of open-source tools for designing, building, documenting,
and consuming RESTful APIs.
• - SoapUI: An open-source API testing tool for functional testing, load
testing, and security testing of REST and SOAP APIs.
Real-world Examples
• REST APIs are widely used across various industries and applications. Some
notable real-world examples of REST API usage include:
• - Google Maps API: Provides access to Google Maps data, allowing
developers to integrate mapping capabilities into their applications.
• - Twitter API: Enables developers to access Twitter's data and functionality,
such as posting tweets, reading timelines, and managing user accounts.
• - GitHub API: Allows developers to interact with GitHub repositories, manage
issues, create pull requests, and more programmatically.
• - Spotify API: Provides access to Spotify's vast music catalog, allowing
developers to build applications that integrate with Spotify's music
streaming service.

You might also like