REST (short for Representational State Transfer) is an architectural style for building web services that interact via an HTTP protocol. REST was created as a simpler alternative to the older SOAP protocol with flexibility being its main advantage. RESTful systems support messaging in different formats, such as plain text, HTML, YAML, XML, and JSON, while SOAP only allows XML.
Web APIs (application program interface) that comply with REST architectural constraints are called RESTful APIs or REST APIs. The REST API paradigm contains three main elements:
- a client or software that runs on a user’s computer or smartphone and initiates communication;
- a server that offers an API as a means of access to its data or features; and
- a resource, which is any piece of content that the server can provide to the client (for example, a video or a text file).
To access a resource, the client sends an HTTP request. Main types of HTTP requests are GET, PUT, HEAD, POST, PATCH, CONNECT, TRACE, OPTIONS, and DELETE.
In return, the server generates an HTTP response with encoded data on the resource. Both types of REST messages are self-descriptive, meaning they contain information on how to interpret and process them.