DEV Community

Shish Singh
Shish Singh

Posted on • Edited on

All about APIs

As per the official definition by Mozilla

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response.

In a simple term client and server can pass the extra bit of information(contextual/meta data) with the request and response using the http headers.

These are further divided into four parts;

  • Request headers
    These are use to send information while making a client to
    sever call.

  • Response headers
    Contrary to the first one, these are use to send information
    while sending the response back to the client from the
    server.

  • Representation headers
    This holds the information about the body of the response.

  • Payload headers
    This is used to hold the information about the payload data.

Commonly used headers

  1. Accept
    Media types/data types are accepted by the server.

  2. Content-type
    This can be used both by clients and servers to identify
    the format of the data in their request or response.

  3. Accept-encoding
    This provides meta-information such as the encoding method
    client can understand.

  4. Host
    It specifies the domain name. This means information such
    as the host and the port.

  5. Authorization
    This is used to pass the credentials (such as information,
    keys or tokens) primarily to let the server authenticate
    the request.

  6. Access-control-allow-origin
    This is to restrict the origin which tries to fetch the
    resource.

  7. Accept-language
    Helps in determining the detail that client is accepting
    the response in the mentioned language.

  8. Access-control-allow-methods
    This helps in knowing which methods are allowed to access
    the cross origin resources.

Http_Calls

Http Request Methods

  1. Get
    The Get method is the most common of all these request
    methods. It is used to fetch the resources from the
    server.

  2. Post
    The Post method is used to submit the information to the
    server. Since, we are submitting the data the post method
    often changes the state of the server.

  3. Put
    The put method is used to change data already present in
    the resource collection.

  4. Patch
    Contrary to put, the patch request method is used to
    modify only the necessary part of the data or response.
    Simply stating it never modifies the entire response.

  5. Delete
    As per its name, delete request method is used to delete
    the specific resource. It requests that the origin server
    delete the resource identified the request URL.

**Resources are datasets in the above statements.

Connects

Check out my other blogs:
Travel/Geo Blogs
Subscribe to my channel:
Youtube Channel
Instagram:
Destination Hideout

Top comments (0)