Know about Rest API’s in Software Engineering

Vaibhav Gupta
2 min readMar 19, 2022

--

Hello Everyone, today we are going to learn about REST API’s.

Rest stands for Representational State Transfer. It is called so because it transfers the state of the object to the endpoint.

A RESTful api is an architectural style for an application program interface(API) that uses HTTP requests to access and use the data.

REST is an architectural style that doesn’t follow any strict standard but follows six constraints defined by Roy Fielding in 2000. Those constraints are — Uniform Interface, Client-Server, Stateless, Cacheable, Layered System, Code on Demand.

Consider REST API as an intermediary between your client and the server. It will access http methods from the client and will return the data from the server in XML/JSON format.

An example for an application that uses REST API can be WEATHER app. It fetch weather data for the requested location and return the data from the server using REST API.

What is a resource?

Resources are the basic building block of a RESTful service. Examples of a resource from an online book store application include a book, an order from a store, and a collection of users. Resources are addressable by URLs and HTTP methods can perform operations on resources.

You can also perform CRUD operations on a resource by using below methods:

  1. Create: POST
  2. Read: GET
  3. Update: PUT, PATCH
  4. Delete: DELETE

Let’s further understand about the methods in detail:

POST: This method is used for creating a REST API resource.

GET: Retrieve information about the REST API resource

PUT: Update a REST API resource

PATCH: Making partial changes to an existing resource.

DELETE: Delete a REST API resource or related component.

Status Codes in REST API:

Whenever he hit one of the above methods, then the server sends state of the requested resource. This state is generally sent as the status of that resource.

The status codes are divided into five categories:

  • 1xx: Informational — Communicates transfer protocol-level information.
  • 2xx: Success — Indicates that the client’s request was accepted successfully.
  • 3xx: Redirection — Indicates that the client must take some additional action in order to complete their request.
  • 4xx: Client Error — This category points the finger at clients. Either the request contains bad syntax or cannot be fulfilled
  • 5xx: Server Error — The server takes responsibility for these error status codes. The server failed to fulfil an apparently valid request.

Hope that you understood this article. If yes, please hit like!

Keep Learning and Growing :)

--

--

Vaibhav Gupta
Vaibhav Gupta

No responses yet