Image for post
Image for post

Introduction to HTTP and REST API || Crio.do

This blog summarizes what I have learned about HTTP and RESTful API during Crio.do Winter of Doing program.

Image for post
Image for post
>>URL is the address of file/webpage you are looking for.>>There are 4 parts in a URL.
protocol://hostname:port/path-and-file-name
PROTOCOL: rules used for client-server data transmission.
HOSTNAME: server where web-files are stored.
PORT: specifies the port at which server is recieving requests.
PATH/FILE_NAME: specifies the location of page you are requesting.
Image for post
Image for post

What is an HTTP request??

HT: Hypertext (a text with hyperlinks = webpage)

Image for post
Image for post
Created By: Deepti Tiwari

1. GET METHOD

As the word simply means, it is used to “GET” something from the server. For every component in a webpage, every image, video, HTML, or CSS file, a different HTTP request is made. A demo is given in the below image.

Image for post
Image for post
Developer’s Mode (Ctrl+Shift+i); Flipkart’s Homepage
In the red box: 
It is showing the kind of file
In the purple box:
It shows the number of HTTP requests made for that page.
In the pink box:
It shows the amount of data downloaded.

2. POST METHOD

Post method is used when we send a new set of information to save on the server. For example, when you are creating a new account, you are sending your information for the first time. This is when the POST method is used.

3. PUT METHOD

There are cases when you modify the data already stored in the server, like editing the status, post, or a comment. Since you are modifying something the PUT method will be used.

What do we get in return for an HTTP Request?

The server sends back a RESPONSE filled with loads of information as a reply to our request. You get an HTML file, a CSS file, multimedia, etc.

A RESPONSE consists of… ???

There are mainly two components of a response: Response Header and Response Body.

Image for post
Image for post
Source: [1]
Image for post
Image for post
Developer’s Mode (Ctrl+Shift+i); Flipkart’s Homepage

What is a STATUS CODE?

During the entire process of making a request and receiving the response, there is a huge possibility of various events occurring. Every event is denoted by a unique number, on the basis of following division.

Image for post
Source: [2]
Image for post
Image for post

What is REST API??

(REpresentational State Transfer — Application Programming Interface)

How HTTP is different with REST-API ?

The response in HTTP is usually HTML, CSS, JS files which is then rendered by and displayed on browser. But in REST API, response is some data which is then processed by requesting program. JSON, XML are some standard data format which is easily understood by application.

Image for post
Image for post
JSON Data as a response of REST-API
Image for post
Image for post
>> PROTOCOL: it shows that request is made using HTTP Protocol(safer version: HTTPS)
>> ROOT-END POINT: host address of api provider.
>> PATH: locates the particular imformation requested.
>> QUERY: In case any additional value has to sent, to filter data, then that is send as a query.
Image for post
Image for post
REQUEST HEADER FOR https://www.metaweather.com/api/location/search/?query=san
Image for post
Image for post