HTTP, or Hypertext Transfer Protocol, is the protocol that allows us to send and receive data over the web. When we enter a URL into our web browser or when we make an API request, we're sending an HTTP request to a server.
An HTTP request includes a "method", which tells the server what kind of operation we want to perform. The most common methods are "GET" (retrieve data), "POST" (send data), "PUT" (update data), and "DELETE" (remove data).
We then receive an HTTP response from the server, which contains a status code. This code tells us if the request was successful or if an error occurred. Common status codes you might see are 200 (OK), 404 (Not Found), or 500 (Internal Server Error).
In addition to the status code, the server returns data to us. For web pages, this is usually an HTML document that your browser renders into visible webpage. For APIs, it is often a JSON or XML document with data.
For instance, if we make a request to https://www.google.com
, the server handles this request, comes back with a 200 status code (which means everything went OK), and returns the HTML file of Google's homepage. Our browser then takes this HTML file and displays the page accordingly.
Remember that these requests and responses form the basis of web communication, and APIs utilize these HTTP protocols to facilitate the interaction between different software applications.
APIs (Application Programming Interfaces) span various types, with the most important ones being SOAP
, REST
, and GraphQL
.
REST
(Representational State Transfer) defines an architectural style for APIs. APIs using this style are referred to as . They've gained widespread use because they are simple, stateless, and compatible with HTTP. Any 'memory' during communication is transmitted within the request and response, making them efficient and highly scalable — qualities vital for modern web applications.
