Ravi Chandola
Javarevisited
Published in
2 min readApr 26, 2023

--

𝐇𝐓𝐓𝐏 𝐀𝐍𝐃 π“π‡π„πˆπ‘ πŒπ„π“π‡πŽπƒπ’

HTTP (Hypertext Transfer Protocol) is a fundamental protocol used in API (Application Programming Interface) to communicate and transfer data between clients and servers over the internet. HTTP is a request-response protocol, which means that clients (such as web browsers or mobile apps) make requests to servers, and the servers respond with data.

In API, HTTP is used to define the communication between the client and the server. The client sends an HTTP request to the server, which typically includes an HTTP method (such as GET, POST, PUT, or DELETE), a URL or endpoint, and headers. The server then processes the request and sends an HTTP response back to the client, which includes an HTTP status code, headers, and a message body. APIs can use different versions of HTTP, such as HTTP/1.1 and HTTP/2, which offer various features and improvements over earlier versions of HTTP. For example, HTTP/2 supports multiplexing, which allows multiple requests to be sent over a single connection, and server push, which allows the server to send data to the client before the client requests it.

There are two main models associated with HTTP (Hypertext Transfer Protocol):

1. Client-server model: In this model, a client sends a request to a server, and the server responds with the requested data. The client initiates the communication by sending an HTTP request to the server, which processes the request and sends an HTTP response back to the client. This model is commonly used for web browsing, where the client (such as a web browser) requests web pages from a server.

2. Peer-to-peer model: In this model, multiple clients communicate with each other directly, without the need for a central server. Each client can send and receive data to and from other clients in the network. This model is commonly used in file sharing applications, where users share files with each other directly.

There are different types of HTTP Methods which helps API to communicate as given below :

GET: This method is used to retrieve data from the server. GET requests are used to read a resource.

POST: This method is used to create a new resource on the server. POST requests are used to create a resource.

PUT: This method is used to update an existing resource on the server. PUT requests are used to update a resource.

DELETE: This method is used to delete a resource from the server.

PATCH: This method is used to partially update an existing resource on the server.

HEAD: This method is similar to GET, but it only returns the headers of the response, not the response body.

OPTIONS: This method is used to retrieve the HTTP methods that the server supports for a specific resource.

CONNECT: This method is used to establish a network connection to a resource.

TRACE: This method is used to retrieve a diagnostic trace of the actions taken by the server.

We will explore them 1–1 in next post.

--

--

Ravi Chandola
Javarevisited

As a technology enthusiast, I have a passion for learning and sharing my knowledge with others. https://www.linkedin.com/in/ravi-chandola-304522133