Rest API

ยท

2 min read

REST API (sweetly explained ๐Ÿ˜…)

  • REpresentational State Transfer.

  • REST is a set of guidelines.

  • Uses HTTP as a mode of transmission (It is not necessary to use though).

  • Data can be sent in various forms, Eg: HTML, JSON, XML etc.

  • REST != HTTP

  • Headers and parameters are also important in a RESTful API HTTP request, as they contain important identifier information like the request's metadata, authorization, uniform resource identifier (URI), caching, cookies, and more. There are request headers and response headers, each with its own HTTP connection information and status codes.

  • HTTP methods: GET, POST, PUT, PATCH, DELETE, etc.

  • Idempotence: An idempotent HTTP method is an HTTP method that can be called many times without different outcomes.

  • GET, PUT, and DELETE methods are Idempotent methods.

Guidelines of REST:

1. Uniform Interface:

  • Querying resources should allow the client to request other actions and resources without knowing them in advance.

2. Client-Server

  • The client-server design pattern enforces the separation of concerns, which helps the client and the server components evolve independently.

3. Stateless

  • Statelessness mandates that each request from the client to the server must contain all of the information necessary to understand and complete the request.

4. Cacheable

  • The cacheable constraint requires that a response should implicitly or explicitly label itself as cacheable or non-cacheable.

5. Layered System

  • For example, in a layered system, each component cannot see beyond the immediate layer they are interacting with.

6. Code on Demand (Optional)

  • REST also allows client functionality to extend by downloading and executing code in the form of applets or scripts.

=================

The End!

Linkedin github ๐Ÿš€โ˜๏ธ๐Ÿ–ค

ย