What is Rest API?

Mini Vasudeva
2 min readMay 10, 2021

--

A REST API allows a user to interact with the server by creating requests and receiving responses. REST stands for Representational State Transfer and API stands for Application Programming Interface. A REST API is a type of API that follows a REST architecture.

There are six architectural constraints that all REST APIs follow:

  1. Client-Server Architecture- this indicates that the client and the server are separate from each other and must be able to function independently.
  2. Uniform Interface- the structure of the call and response must be uniform across all REST APIs.
  3. Stateless- This means the server will not store a history of previous calls made to the server. Each call will be considered new.
  4. Cacheable- all responses must be cacheable.
  5. Layered System- It is possible to have many servers. The client should not be able to tell if it is connected to the end server or an intermediary server.
  6. Code on demand (optional)- the server may return executable code to the client.

What Components are in a Request ?

HTTP Methods represent an action to the server that u would like to complete.

  1. POST: Create user information on the server.
  2. GET: Get user information on the server.
  3. PUT: Update and Replace the user information on the server.
  4. DELETE: Delete the user information on the server.

REQUEST URL:

It indicate to the server what you are trying to do.

URL is separated in parts:

1. Base Path : refers to the common path of the API.

2. Endpoint : refers to the end path of the end point.

3. Query : Query parameters are specified after the question mark in the endpoint in the Request URL.

{https://www.restapitesting.com/search?limit=3&format=json}

Base Path : https://www.restapitesting.com

End Point : /search

Query : ?limit=3&format=JSON

Request Header:

Every REST request must contain three HTTP header fields: Accept, Content-Type, and Cookie.

  1. Accept Header:The Accept header describes which format you want a response. For example, responses can be delivered either as XML or JSON .
  2. Content-Type:The content-Type describes the format the body of your request . For example, the body of your requests can be sent as JSON or XML, but you need to declare in the Content-Type header which one is being used.
  3. Cookie:The Cookie contains the authenticated session ID that you obtained after creating a REST API session.

Originally published at https://www.numpyninja.com on May 10, 2021.

--

--

No responses yet