REST API (Representational State Transfer Application Programming Interface) is a web service architecture. This architecture encompasses a set of standards that represent resources and define operations performed on these resources. REST typically communicates over the HTTP protocol but can also be used with other protocols.
Resource Representation: Each resource is represented by a URI (Uniform Resource Identifier). These resources are typically data represented in
Lightweight Communication: REST communicates using existing communication protocols like HTTP, contributing to the overall lightweight nature of the application.
Statelessness: Each request contains its context, and the server does not store this context. Every request must carry all the relevant information with it.
Layered Architecture: REST follows a layered architecture, making the application modular and more sustainable.
Interconnected Systems: RESTful services can interact with each other, enabling access to a resource in one system through other interconnected systems.
REST APIs often support CRUD (Create, Read, Update, Delete) operations. For example, in a book store application, CRUD operations could be as follows:
Create: Use a
POST request to add a new book.
Read: Use a
GET request to view specific book details.
Update: Use a
PATCH request to update book information.
Delete: Use a
DELETE request to remove a book.
Commonly Used Status Codes
|The request was successfully processed.
|The resource was successfully created.
|The request was successful, but there is no content to return.
|The request could not be understood or processed by the server.
|Authentication failed or user lacks necessary permissions.
|The request was valid, but the server refuses to respond.
|The requested resource could not be found.
|Method Not Allowed
|The request method is not supported for the requested resource.
|The request could not be completed due to a conflict with the current state of the target resource.
|Internal Server Error
|An unexpected error occurred on the server.
|The server is currently unable to handle the request, usually due to temporary overloading or maintenance of the server.
REST APIs can be utilized for a wide range of applications and were developed to standardize the interaction of web-based services.