Introduction

REST (Representational State Transfer) is a style of software architecture that defines a set of constraints to be used for developing web applications. It is basically a set of rules that developers use when they create their API.

Now for context:

What is an API?

An API (Application Programming Interface) is a set of definitions and protocols that allow different software applications to communicate with each other.

You can think of an API as the mediator between the user and the resource or web service they want to get.

The API takes a request from the user and passes it on to the server. The server then provides a response that is passed on to the user through the API.

Here's a simple illustration: When you enter a request into the search bar on Google, that's you sending a request to an API. That API takes your request and sends it to Google's servers. The Google server then fetches the appropriate response to your request and sends it to the API, which in turn will send it back to you.

What is a REST API?

A REST API (also known as RESTful API) is an API that conforms to the constraints of the REST architectural style.

A REST API uses HTTP requests to perform basic CRUD (Create, Read, Update and Delete) operations.

REST APIs are designed around resources. A resource is a piece of data that can be identified by URIs (Uniform Resource Identifiers). For example, a user resource could be identified with the URI '/users/1' where '1' is the user ID.

A resource can be accessed and manipulated using the HTTP methods.

What are HTTP Methods?

HTTP (HyperText Transfer Protocol) is a protocol that allows for the exchange of information over the World Wide Web. It is the system of rules which define how clients make request messages and servers make response messages.

The HTTP specification includes several methods that are used to interact with server-side resources.

The most commonly used HTTP methods are:

  • GET - Used to retrieve a resource or collection of resources

  • POST - Used to create a new resource

  • PUT - Used to update an existing resource

  • DELETE - Used to delete a resource

The data gotten as a response to these methods can either be in JSON, XML or HTML format.

Conclusion

In summary, REST APIs are designed to be simple and easy to use. They are quite popular and easy to maintain.

Furthermore, the HTTP protocol which they rely on is widely supported by web browsers and servers.

Finally, REST APIs are also flexible and can be used with different programming languages and platforms.