Rest Api

Rest Api

Rest API

Rest is an architecture majoring web services. The word is shortened out of the full definition of Representational State Transfer. These web services are generally used in creating API s for web-based applications due to the pros of lightweight, huge scalability, and acceptable maintainability. Using the rest each and every single computer system can communicate over each other over the web.

In a system that uses REST, the relevant server doesn't want to know the client's current state and other surroundings. This is called as statelessness. With this condition, both client and server have acknowledged any message without observing through pre messages. Statelessness is enforced on resources out of commands.

The client has to request the server for the purpose of retrieve or modifying. The request is consists of the following things as HTTP verb, Header, Path, and Optional message body contains data.

HTTP Verbs

Here are some basic HTTP request verbs; Get: This is used for retrieving resources Post: this is to create a new resource. In a common way, this can be called an insert. Put: this is to modify the resources where we are known as an update. Delete: this can be used to remove as deleting resources. Option: this gets allowed resources. Head: get only the response header.

Here client specifically identifies the type of content to the server that he wants to retrieve for the purpose. The field is called as "Accept" field where the confirmation that the retrieving data from the server is consists of the client's understandability.

In this accept field Multipurpose Internet Mail Extensions, the shorten name of MIME type can be used as it is included with both type and subtype which can be separated using a slash mark (/). As examples following can be shown. Text file — text/html, text/css Image — image/png, image/jpeg Audio — audio/wav Video — video/mp4 Application — application/json, application/pdf, application/xml

Paths

Request required a path to reach the resource relevant to the operation. In REST API, paths help the client to take an idea and locate the resource destinations in specifications.

Response Codes

Server responses with the status code to alert the client to inform about the operation status.

Status codes with HTTP request verbs go here by;

  • GET — return 200 (OK)
  • POST — return 201 (CREATED)
  • PUT — return 200 (OK)
  • DELETE — return 204 (NO CONTENT)

WhatsApp Image 2021-05-29 at 7.07.47 PM.jpeg